user3776374
user3776374

Reputation: 33

Apache FOP using CQ5

How can we handle pages with different designs when there is a pdf rewriter that is inbuild with Adobe Experience manager. I know that there is a file page2fo.xsl which automatically generates pdf and we need to specify the rules in page2fo.xsl. But the website im working on is not just one design it is in different countries and different languages with their own designs. In this situation how can we convert the html to pdf by just giving url as .pdf. Do we need to write xsl for every design>? Do we have any mechanism that will handle this situation in Adobe Experience Manager that comes with Apache FOP? If there is any mechanism can you please give the sample of it to handle different designs?

Upvotes: 3

Views: 1281

Answers (1)

Thomas
Thomas

Reputation: 7078

I had a look into PDF generation with the page2fo.xsl and was even in contact with Adobe support regarding this. There can be only one file for all your designs as it is hardcoded in the final XSLTTransformer service running in OSGi. You can only overlay the configuration "/libs/cq/config/rewriter/pdf" with your custom one below apps, e.g. "/apps/cq/config/rewriter/pdf" where you can reference a different page2fo.xsl thatn the foundation one. To support multiple designs in your XSL I would suggest a template matching the cq:designPath of your page. The only problem here you would need this property on every page and not rely on the inheritance like in the Edit UI. Something along the line of:

<xsl:template match="*[contains(@cq:designPath,'/etc/designs/yourdesign')]">
    <xsl:apply-templates select="yourdesign"/>
</xsl:template>

But I can guarantee you, it will be a mess and hard to maintain as you really only have this single file for all your custom XSLTTransformation.

I think in your case I would consider using another PDF Framework:

  • PDFBox from Apache. I made a PoC with it and it is painful for PDF creation as you need to know PDF Syntax
  • DynamicPDF: I was able to rewrite my PDFBox PoC within 2 days and even add features. So I would recommend it. You can download an evaluation copy and there are many examples around.

Upvotes: 2

Related Questions