Expand my Community achievements bar.

SOLVED

PDF Generation

Avatar

Level 2

Hi,

I want to create PDF of an page.My requirement is there will be a component as "Download as PDF" when i click on that component the current page will download as pdf.

I gone through about Apache FOP and i created a sling servlet when i clicking on the above mentioned  component made a ajax call to servlet and in my method am using Apache fop. Now i want to download the page as pdf.What should i do next?. Am unable to read page2fo.xsl file under /libs/wcm/core/content/pdf/page2fo.xsl

i will define my design of pdf in page2fo.xsl file. Now i want to access my page content to populate on pdf and convert the xsl to xslfo format then only i can convert it into pdf. Is am in right path?.

 

 Design is common for pdf.

And i don't want to use any third party bundle like itext, PDFbox

Any code snippet will heelpful.

 

Thanks,

Mohamedh Nishadh

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi,

have you tried to request the page as PDF directly?

For example, when I request http://localhost:4502/content/geometrixx/en.html, I get the HTML rendition. When I request http://localhost:4052/content/geometrixx/en.pdf I get the page as PDF.

The magic lies in the mapping of the pdf extension to xml, and then rewriter configuration, plus the page2fo.xsl. You shouldn't need to programm a servlet and invoking FOP manually.

You can find a nice article on this on [1].

kind regards,
Jörg

[1] http://www.cqblueprints.com/tipsandtricks/pdfrendering.html

View solution in original post

5 Replies

Avatar

Level 10

What version of AEM are you using?

Avatar

Level 2

AEM 5.6

Thanks,

Moahmedh Nishadh

Avatar

Correct answer by
Employee Advisor

Hi,

have you tried to request the page as PDF directly?

For example, when I request http://localhost:4502/content/geometrixx/en.html, I get the HTML rendition. When I request http://localhost:4052/content/geometrixx/en.pdf I get the page as PDF.

The magic lies in the mapping of the pdf extension to xml, and then rewriter configuration, plus the page2fo.xsl. You shouldn't need to programm a servlet and invoking FOP manually.

You can find a nice article on this on [1].

kind regards,
Jörg

[1] http://www.cqblueprints.com/tipsandtricks/pdfrendering.html

Avatar

Level 2

Yes when i tried with .pdf extension. The page is not loading.

Avatar

Level 2

Yeah i gone through that URL. If i don't want an servlet how can i download the pdf when that particular button has clicked.

 

Thanks,

Mohamedh Nishadh