We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

XSL FO to PDF using Aspose.PDF for .NET - Exception occured during import of source Xslfo

Hello,

We’re currently using Aspose.Pdf for .Net to generate our PDF via un XSL-Fo, but we received this error during the initialization of Document.

—> [System.ApplicationException]: Exception occured during import of source Xslfo. *
Exception’s message is : ‘Unable to cast object of type ’ ’ to type ’ [ ]’.’ .\r\n Since in conversion’s options selected mode of ignoring validation errors, and such errors was detected, this exception can be result of that bad formatting. Here is list of found formatting errors : ============================================
Border and padding for fo:region-after “first-page-footer” should be ‘0’ (See 6.4.14 in XSL 1.1); non-standard values are allowed if relaxed validation is enabled.Line(7)\Col(8)---------------------------------
Border and padding for fo:region-after “repeat-page-footer” should be ‘0’ (See 6.4.14 in XSL 1.1); non-standard values are allowed if relaxed validation is enabled.Line(12)\Col(8)---------------------------------
“fo:block-container” is missing) child elements.[ Required content model: marker (%block;)+] Line(29)\Col(16)---------------------------------

“fo:static-content” is missing) child elements.[ Required content model: (%block;)+] Line(67)\Col(6)============================================

  • at . (Exception , )*
  • at . (Document , Stream , XslFoLoadOptions )*
  • at Aspose.Pdf.Document. (Stream , LoadOptions )*
  • at Aspose.Pdf.Document…ctor(String filename, LoadOptions options)*

After several tests, I managed to correct all the format issues mentionned. But I still get the following issue:

[System.InvalidCastException]: Unable to cast object of type ’ ’ to type ’ [ ]’.

  • at . (Exception , )*
  • at . (Document , Stream , XslFoLoadOptions )*
  • at Aspose.Pdf.Document. (Stream , LoadOptions )*
  • at Aspose.Pdf.Document…ctor(String filename, LoadOptions options)*
  • at ptoKernel.ReportHelper.AsposeReportGeneration.GeneratePdfWithAspose(String foInputPath, String pdfOutputPath)

Here are the codes where I tryied to create a document with and input of xsl fo file.

        Dim options As XslFoLoadOptions = New XslFoLoadOptions()

        Using pdfGenerated As Document = New Document(foInputPath, options)
            pdfGenerated.Save(pdfOutputPath)
        End Using

And we use the XslCompiledTransform to transform a xsl and xml file to the xsl fo file.

Basically I think there is an issue for Aspose to load the xsl fo file, can you help on this?

Cheers,
Rui

@rui.jia0408

Would you please share your sample source files in .zip format with us. We will test the scenario in our environment and address it accordingly.

Hello,

Please check the sample source file we used in the attachement.

test_Aspose.zip (4.1 KB)

Actually we use the Aspose.pdf for two of our projects, it’s working properly in one of them, but not another one. I have run the tests with both of the version we currently used (18.2) and the newest one (20.10), and I still get the same issues specified in my last comment.

Please let me know if you need anything else.

Cheers,
Rui

@rui.jia0408

We were able to reproduce the issue in our environment while using Aspose.PDF for .NET 20.10. Therefore, have logged an issue as PDFNET-48947 in our issue tracking system. We will further look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

Hello ,

Thanks for your information. So please let me know when you will include the correction about the issue.

Cheers,
Rui

@rui.jia0408

We will surely post updates within this forum thread as soon as the ticket is resolved.

Hello @asad.ali,

Do you have any updates about this issue since it has been a long time.

And FYI, I noticed that the issue reported is linked to the formatting object fo:marker/fo:retrieve-marker, we have this issue for all the xslfo with fo:marker set, just like the one I attaced as exemple. But we don’t face this issue when the fo:marker is empty. I think this is linked to the fact we use the fo:retrieve-marker to display some information in the footer, maybe the fo:retrieve-marker is not supported by Aspose library.

Can you please check this in your side?

Thanks,
Rui

@rui.jia0408

We are afraid that earlier logged ticket is not yet fully investigated. However, we have recorded the information provided by you and will surely consider it during performing the investigation. We will inform you as soon as we have some definite updates regarding issue rectification. Please spare us little time.

We are sorry for the inconvenience.

Hi @asad.ali

Does this ticket has been investigated?

Thx,

Nicolas

@nparisse

We are afraid that the earlier logged ticket could not get resolved yet. We will certainly post an update in this forum thread once the issue is fixed.

We apologize for the inconvenience.