In this post, I'll show you how to render PDF documentation (.pdf) with an extra image page prepended to the front of the whole PDF document, and how to embed an extra image to the top of an existing page. According to a previous post - Adobe CQ Renders Pages with Custom Extension - making .pdf an accetable extention can be done in CQ. In fact, by default, the .pdf extension is already accetable by CQ, according to an existing Page.pdf.jsp file at /libs/foundation/components/primary/cq/Page/Page.pdf.jsp I'm using CQ5.6.1 which is not too reliable when I played with extension so after try and error, I modified the above file to reference proxy.jsp using full path and without carriage return at the end of line to avoid any possible 500 Internal Server Error. The Page.pdf.jsp file now saved have only one line: <%@include file="/libs/foundation/components/primary/cq/Page/proxy.jsp" %> as explained in Adobe CQ Renders Pages with Custom Extension. For rendering .pdf, I use the out of the box PDF Rewriter mechanism. CQ5 demonstrates the default PDF Rewriter in their demo sites. For example, you can change an existing URL ends with .html extension: http://localhost:4502/content/geometrixx-media/en/entertainment/summer-blockbuster-hits-and-misses.html to .pdf extension to see the default behavior of PDF Rewriter output of a page: http://localhost:4502/content/geometrixx-media/en/entertainment/summer-blockbuster-hits-and-misses.pdf If you're lucky, your browser should show you a pdf output generated by a default PDF Rewriter (an XSL-FO file named page2fo.xsl located at /libs/wcm/core/content/pdf/page2fo.xsl by default). If not, you need to configure (see references) and modify the PDF rewriter. In the sample XSL-FO file, the following lines in red are keys to prepend a front cover image page, and embed a header image banner to a page. The final output is a 2 pages PDF documentation: <?xml version="1.0"?> Here's the brief explanation for each snippet in red ... Tell page2fo.xsl the 'fox' namespace is legit so it'll recognize <fox:external-document>: xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" Include in an external image as a separate page in the front of the final PDF document. This image will be a separate pdf page before all other page sequence: <fox:external-document src="sling://content/dam/public/pdf/frontCoverLATL.jpg/jcr:content/renditions/original"/> Embed an external image as part of the page (block) in a page of the final PDF document before some other text: <fo:block> what to read nextreferences
0 Comments
Leave a Reply. |
Categories
All
Archives
May 2020
|