PDF Generation | Community
Skip to main content
Nishadh
Level 2
October 16, 2015
Solved

PDF Generation

  • October 16, 2015
  • 5 replies
  • 2049 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by joerghoh

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

5 replies

smacdonald2008
Level 10
October 16, 2015

What version of AEM are you using?

Nishadh
NishadhAuthor
Level 2
October 16, 2015

AEM 5.6

Thanks,

Moahmedh Nishadh

joerghoh
Adobe Employee
joerghohAdobe EmployeeAccepted solution
Adobe Employee
October 16, 2015

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

Nishadh
NishadhAuthor
Level 2
October 16, 2015

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

Nishadh
NishadhAuthor
Level 2
October 16, 2015

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