[xep-support] Transforming XmlDocument (Containing XSL-FO) to PDF

From: Hart, Leo (Leo.Hart@FMR.COM)
Date: Fri Oct 01 2004 - 13:23:05 PDT

  • Next message: Michael Hahn: "Re[2]: [xep-support] MathML support"

    I have a function that accepts an FO document in the form of a
    System.Xml.XmlDocument and returns a PDF in the form of a Byte array.

    Here's the function:

                    Public Shared Function TransformXslFOToPDF(ByRef
    pXslFODocument As XmlDocument) As Byte()
                            m_log.Debug("Transforming XSL-FO to PDF: " &
    vbCrLf & pXslFODocument.OuterXml)

                            'Holds the outgoing PDF stream
                            Dim lOutStream As New MemoryStream

                            'Get Xmldocument into Stream
                            Dim lInStream As New MemoryStream
                            lInStream.Position = 0

                            'Get Stream into XmlReader
                            Dim lInReader As New XmlTextReader(lInStream)

                            'Configuration settings for Formatter
                            Dim lConfigSettings As New Hashtable
                            lConfigSettings.Add("ROOT", "C:\Program
    Files\RenderX\XEP.NET 3.8")

                            'FO Formatter
                            Dim lFormatter As New
    Renderx.Xep.Formatter(lConfigSettings, Nothing)

                            lFormatter.Format("", lInReader, lOutStream,
    Formatter.OUTPUT_PDF, lConfigSettings, Nothing)

                            Return lOutStream.GetBuffer
                    End Function

    And here's the FO that exists within pXslFODocument:

                                            <fo:region-body margin="1in" />
                            <fo:page-sequence master-reference="my-page">
                                    <fo:flow flow-name="xsl-region-body">

    When I run this test case I receive the following error:

                    Exception: Renderx.Xep.XepInvalidOperationException
                    Message: startDocument: Invalid XSL FO source
    'file:/C:/WINDOWS/system32/': 1 error found during validation
                    Source: Renderx.Xep.Public
                            at Renderx.Xep.Sax.ContentHandler.endDocument()
                            at Renderx.Xep.Formatter.Format(String
    sBasePath, XmlReader reader, Stream outStream, String sOutFormat,
    Hashtable htGenProperties, Logger logger)
    pXslFODocument) in C:\Documents and Settings\a122695\My Documents\Visual
    Studio Projects\Sandbox\LibrarySandbox\Classes\XML\Transformer.vb:line
                            at Sandbox.Web.GetPDFFromXSL_FO.Page_Load(Object
    sender, EventArgs e) in
    C:\Inetpub\WWWRoot\WebSandbox\ASP\XML\GetPDFFromXSL-FO.aspx.vb:line 43

    I assume this is related to the fact that the sBasePath parameter in
    lFormatter.Format is set to a null string. I can't figure out what I'm
    supposed to use this for. I've tried various different file and http
    paths, but all of them error out. I just want to convert my
    memory-based FO document to a memory-based PDF.

    Any suggestions?

    Leo Hart

    (*) To unsubscribe, send a message with words 'unsubscribe xep-support'
    in the body of the message to majordomo@renderx.com from the address
    you are subscribed from.
    (*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/tos.html

    This archive was generated by hypermail 2.1.5 : Fri Oct 01 2004 - 13:43:36 PDT