Unable to use XSLT 2.0 versoned XML-FO template to create PDF

I am trying to create PDF file from XML using XML-FO file. XML-FO file is written through XSLT 2.0. It Throws syntax error in “pdf1.BindFO(foData, foStyle);”.

However If i generate XML-FO file through XSLT 1.0 IT works perfect. I am attaching the XML and XML-FO file.

Hi Jay,


Thanks for your inquiry. While testing the scenario with Aspose.Pdf for .NET 8.7.0, I have noticed an exception message “Data at root level is invalid Line1, position 1” and logged it as PDFNEWNET-36175 in our issue tracking system for further investigation and resolution. We will keep you updated about the issue investigation and resolution progress.

Meanwhile, can you please share your sample code and error details. It would help us to investigate your issue properly, that we are on same page.

We are sorry for the inconvenience caused.

Best Regards,

Hi Jay,


Thanks for your patience. I am afraid currently XSLT 2.0 is not supported in Aspose.Pdf since Aspose.Pdf internally uses NET implementation of XSLT processor, which in turn does not support XSLT2.0 . So we have changed issue type of above logged issue to new feature. As soon as this feature is implemented then we will notify you via this forum thread.

Moreover, as a work around you can use some third-party utility (e.g : http://p2p.wrox.com/xslt/42785-does-net-2-0-framework-support-xslt-2-0-a.html ) and then just pass summary XML to BindFO() method, with single argument.

We are sorry for the inconvenience caused.

Best Regards,


The issues you have found earlier (filed as PDFNEWNET-36175) have been fixed in Aspose.Pdf for .NET 8.8.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

I tried version 8.8.0. I am still having same error.

Hi Jay,


Thanks for your patience.

In order to generate the correct output, please try using the following code snippet. Please note that following example uses free version of Saxonica xslt processor. Free Saxonica XSLT20 processor can be download from this link.

[C#]

using System;<o:p></o:p>

using System.Collections.Generic;

using System.Linq;

using System.Text;

using Saxon.Api;

namespace SaxonicaTestDrive

{

class Program

{

static void Main(string[] args)

{

// please put here path to Your license file for Aspose.Pdf.dll

// otherwise only very simple source documents can be processed

new Aspose.Pdf.License ().SetLicense(@" C:\SaxonicaTestDrive\ProcessedFiles\Aspose.Total_Fresh.lic");

// do XSLT to get result XSLFO

string sourceXmlFile = @"C:\SaxonicaTestDrive\ProcessedFiles\Data.xml";

string xsltFile = @"C:\SaxonicaTestDrive\ProcessedFiles\XSLT-FO-XSLT 2.0.xsl";

string productXslFoFile = @"C:\SaxonicaTestDrive\ProcessedFiles\result.xml";

DoXsltTransformation(sourceXmlFile, xsltFile, productXslFoFile);

// convert product XslFo to PDF with Aspose.Pdf.dll

Aspose.Pdf.XslFoLoadOptions foToPdfLoadOptions= new Aspose.Pdf.XslFoLoadOptions();

foToPdfLoadOptions.UseOldXslFoEngine=false;

Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(productXslFoFile,foToPdfLoadOptions);

// save result

string pdfOutputPath = @"C:\SaxonicaTestDrive\ProcessedFiles\output.pdf";

pdfDocument.Save(pdfOutputPath);

}

public static void DoXsltTransformation(String sourceUri, String xsltUri, String productXml)

{

// sample can be found here :

// http://www.xmlplease.com/saxonaspnet

// Create a Processor instance.

Processor saxProcessor = new Processor();

// Load the source document.

XdmNode rootNode = saxProcessor.NewDocumentBuilder().Build(new Uri(sourceUri));

// Create a transformer for the stylesheet.

XsltTransformer transformer = saxProcessor.NewXsltCompiler().Compile(new Uri(xsltUri)).Load();

// Set the root node of the source document to be the initial context node.

transformer.InitialContextNode = rootNode;

// BaseOutputUri is only necessary for xsl:result-document.

transformer.BaseOutputUri = new Uri(xsltUri);

// Create a serializer.

Serializer serializer = new Serializer();

serializer.SetOutputFile(productXml);

// Transform the source XML to System.out.

transformer.Run(serializer);

}

}

}

I am getting This error with trial version of Aspose.Pdf 8.8.0 “{“At most 4 text fragments can be added in evaluation mode.”}”

I have licence for older version and before I upgrade to newest version I wan to make sure it is working as I wanted. can you help me on to achive that with trial version of aspose.pdf 8.8.0

Hi Jay,

Thanks for your inquiry. To test the feature with Aspose.Pd for .NET 8.8.0 without evaluation limitation, you may request for 30 days temporary license. Hopefully it will help you to accomplish your requirements.

Please feel free to contact us for any further assistance.

Best Regards,

It worked, Thank you.

When I tried To generate PDF, PDF generated successfully but It does not contains images I am trying load using URL. I am getting this messages while it is generating “Attempt to resolve URI ‘http://nanonull.com/nanonull.gif’ failed”

Please find attached FO file from which I am generating PDF as an Example.

Here is the code in FO file seems not working.
“<fo:external-graphic content-height=“0.79in” scaling=“non-uniform” content-width=“1.59in” src=“url(http://nanonull.com/nanonull.gif)”/>”

Hi Jay,


Thanks for contacting support.

I have tested the scenario using Aspose.Pdf for .NET 8.8.0 where I have used the following code snippet and as per my observations, the image appears in resultant PDF file but the text formatting is lost. For the sake of correction, I have logged this
problem as PDFNEWNET-36311 in our issue tracking system. We will
further look into the details of this problem and will keep you updated on the
status of correction. Please be patient and spare us little time. We are sorry
for this inconvenience.

[C#]

// load XSL-FO file<o:p></o:p>

Document doc = new Document(@"C:\pdftest\images-embedded.fo", new XslFoLoadOptions());

// save the output in PDF format

doc.Save(@“C:\pdftest\images-embedded_DOM.pdf”);




PS, for your reference, I have also attached the resultant PDF generated over my end.

<o:p></o:p>


I tried and noticed that if I generate PDF using new XslFoEngine than It does not include Image,
Try following code.

[C#]

// convert product XslFo to PDF with New XslFoEngine

Aspose.Pdf.XslFoLoadOptions foToPdfLoadOptions= new Aspose.Pdf.XslFoLoadOptions();

foToPdfLoadOptions.UseOldXslFoEngine=false;


// load XSL-FO file

Document doc = new Document(@"C:\pdftest\images-embedded.fo",foToPdfLoadOptions);


// save the output in PDF format

doc.Save(@"C:\pdftest\images-embedded_DOM.pdf");

Hi Jay,


Thanks for sharing the details.

I have observed that when setting the value of UseOldXslFoEngine property as false, the image does not appear but text is properly formatted. However when setting value as true, the image appears but text formatting is lost (problem is already logged). For
the sake of correction, I have separately logged this problem as PDFNEWNET-36314 in
our issue tracking system. We will further look into the details of this
problem and will keep you updated on the status of correction. Please be
patient and spare us little time. We are sorry for this inconvenience.

<o:p></o:p>

The issues you have found earlier (filed as PDFNEWNET-36314) have been fixed in Aspose.Pdf for .NET 9.6.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi Jay,


Thanks for your patience. As stated above your reported issue, PDFNEWNET-36314 is fixed. Since referenced image (http://nanonull.com/nanonull.gif) not online anymore, so we have changed source file ‘images-embedded_corrected.fo’ for tests.


// convert product XslFo to PDF with
New XslFoEngine
<o:p></o:p>

Aspose.Pdf.XslFoLoadOptions foToPdfLoadOptions = new Aspose.Pdf.XslFoLoadOptions();

foToPdfLoadOptions.UseOldXslFoEngine = false;

// load XSL-FO file

Document doc = new Document(@"C:\pdftest\images-embedded.fo", foToPdfLoadOptions);

// save the output in PDF format

doc.Save(@"C:\pdftest\images-embedded_DOM.pdf");


Please feel free to contact us for any further assistance.

Best Regards,