简体   繁体   中英

XML to XSL-FO C#.NET

How can I convert/transform/create an xsl-fo file from an XML document using an xsl stylesheet i C#.NET?

What I want to achieve is a REST Service that is used to "print" a PDF to the browser. The XML is loaded in via another REST Service and the stylesheet is pre-defined and located in my project as a resource.

This is the code so far, just to demonstrate the structure I'm after: (Note that the return type String is just for troubleshooting and will be replaced once I get further)

    public String GetPDFList(String apiquery, String template)
    {
        String returnString;

        /* BUILD QUERY TO GET XML CONTENT */
        string returnUrl = api_url + apiquery + api_key;

        /* BUILD XML CONTENT TO DOCUMENT */
        XmlDocument doc = new XmlDocument();
        doc.Load(returnUrl);

        /* GENERATE XSL-FO FILE FROM XML AND XSL STYLESHEET */
        /* TODO */

        /* GENERATE PDF FROM XSL-FO FILE */
        /* TODO */

        /* RETURN PDF TO CLIENT */
        /* TODO */

        return returnUrl; 
    }

EDIT: I'm currently trying to achieve this using the fo.net library but I can't find any documentation on how to perform this single task of creating the xsl-fo file.

XmlDocument oXML = new XmlDocument();

oXML = LoadXml("And xml string or do the load from file");

// if data loaded from memory save to disk first
oXML.Save(xmlpath)

XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load(FoXSLtPATH);

// Execute the transform and output the results to a file.
// Ready for the FO engine to generate PDF from
xslt.Transform(xmlpath, FoToConsumeOutputPath);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM