Hey Use Nfop thats very easy to use and you can use xsl-fo for the transformation. This code snippet is from one of my projects - had a hard time finding a good example.
// Load the style sheet.
string xslfofile = m_Process.Root + @"\Custom\Components\FrontEnd\Xsl\-pdfxslfo.xsl";
// Execute the transform and output the results to a file.
string xslfo = InventIt.SiteSystem.Library.CommonXml.TransformXsl(xslfofile, m_Process.XmlData, m_Process.Cache); java.io.StringReader streamFO = new java.io.StringReader(xslfo); InputSource src = new InputSource(streamFO);
java.io.ByteArrayOutputStream streamOut = new java.io.ByteArrayOutputStream(); Driver driver = new Driver(src, streamOut); driver.setRenderer(1); driver.run();
System.Web.HttpResponse response = m_Process.HttpPage.Response; m_Process.OutputHandledByModule = true; response.Clear();
response.AddHeader("Content-Disposition", "attachment; filename=pension.pdf");
sbyte[] sB = streamOut.toByteArray();
byte[] b = new byte[sB.Length + 1];
for (int i = 0; i < sB.Length; i++) {
b[i] = (byte)sB[i]; }
response.BinaryWrite(b);
response.Flush(); response.Close(); streamOut.close();
|