PDF generation using XSL FO

I am trying to generate a dynamic PDF with 'PDF from XSL FO Transformation', it is generating a PDF but after opening it I'm getting an error stating 'The file is damaged and could not be repaired.' Has anyone came across such scenario? I'm not able find the issue here.

  Discussion posts and replies are publicly visible

Parents
  • Hello Deepanshua,

    That error is commonly found when the XSL-FO is not well formed and/or the commands were not interpreted by the Apache FOP library.

    Lot of the comments from the others might help you, what I recommend you to do is the following.

    Since you are working with multiple languages at the same time(I always use the analogy with the JSP which includes html-java or php).

    Here you are mixing he XSLT(xml2xml transformation) and the FO(pdf structure) tags.

    First make sure your FO part is working as expected.

    So use the XSL-Transformation (the first section the input is the xml and The XSL) from:

    BY doing this you will get the pure FO file(I always recommend start with this then create the xsl)

    When you have this file you can review your tags and make sure that’s what you want as pdf. If the error still happen, remove sections so you can figure it out which is the cause of the error. To test it use the second section of the link above to debug the FO file.

    When ready now tweak your original XSL-Fo File to correct the issue.

    What can be happening is that the transformation is not making the things right, and it is creating an FO file with sintax problems or not valid tags. That why it’s better to first create the FO file, make sure that’s the PDF you want and then deal with the xml transformation.

    Hope this helps.

    Please feel free to ask if you have more problems, if that’s the case if you can share any file that might help to see the your issue.

    Jose

  • 0
    A Score Level 3
    in reply to josep
    Hi ,

    I am having same issues with this plugin, I have one big confusion

    Do we give the normal XSL-Transformation file as XSL File input to the plugin or the XSL-FO file. I tried both of these scenarios, If I use xslt then the pdf is corrupted and if I use xsl-fo then plugin itself is crashing
  • Hello Chanakya,

    Well I am not sure what is the difference you are making between the XSLT of the XLS-FO . For me both files should be the same. The real difference in both is that
    * XSLT is a generic transformation which transform XML(XSD-1) to XML(XSD-2)
    * XSL-FO is a transformation to a specific Type file which transform XML(XSD-1) to XML(FO).

    At the end both files are an XSLT. So, can you give an example of what you have in one file or the other?

    I think the first file you are passing is the correct one with some problems in the XSLT transformation. are you 100% sure the syntax of your file is correct? you were able to generate the PDF using the link I provided above?

    Note: to the plugin you should pass the Document id, which points to the xsl-fo and if the pdf is getting generated corrupted it means you have some error in your transformation, please take a look at the logs and paste it here, and try to generate the pdf using the link I suggested before.

    Let me know if this helps

    Jose
  • 0
    A Score Level 3
    in reply to josep
    Hi Joseph,

    So my question was should I pass generic XSLT or formatted XSL-FO which is standard for PDF conversion, btw I was able to generate PDF using XSL-FO.

    Thanks
  • Ohhh understood! As you saw it was the XSLFO. Not other Format is available in that transformation.

    That’s Great that you got it working!!
  • Hi Chanakya, 

    I am sending the xslt file in the xsl document input of the plugin. I am getting the same issue of corrupted pdf. could you let me know how you resolved this issue?

    Thanks

  • Hello Himanshu,

    Have you tested the XSLT with the xml in any XMLs tool? The complexity of doing this is that you are merging 2 languages the first is the XSLT and the second is the what I call the FO syntax

    If the ending xlsfo has wrong syntax or an invalid xml tag that kind of error could happen

    Jose

Reply Children
No Data