You can use a CSS style declaration within a style block that is nested within the cfdocument tag, or you can place the font specification directly. Learn how to create PDFs using cfdocument in ColdFusion with this Free Open Source type=”footer”> style=”text-align:center;”>Page #cfdocument. cfdocument will take your combination of CFML and HTML and convert it to a ” short”)# style=”text-align:center;”>Page.
|Published (Last):||15 January 2017|
|PDF File Size:||12.57 Mb|
|ePub File Size:||9.63 Mb|
|Price:||Free* [*Free Regsitration Required]|
Generating Accurate PDFs Using Cfdocument
It also needs to use a specified font, OCR-B, so that a line of text on the cfdochment form can be machine scanned. I was at first thinking I might be able to use the new cfhtmltopdf tag, but quickly dropped that idea: After looking around over the fence for a bit at potential solutions outside of CFML, nothing hit me as particularly appealing, so I dug into getting cfdocument to work as best I could.
First the tag attributes. LocalUrl is set to true to easily pull in a logo image from the local file cfddocument.
Generating Accurate PDFs Using Cfdocument – Nando @ Aria Media
Nested directly within the cfdocument tag is a div tag that sets the page width, with position: Then within that parent div tag are nested the various div tags, absolutely positioned, containing the blocks of text and images that make up the PDF content. Here are a few examples to demonstrate:.
What I really like about this approach is that each of the text blocks winds up very close to the top and left dimensions specified, and the ACF and Lucee outputs are nearly identical. Without the parent div tag specifying the width, the results between the 2 engines are vastly different, and positioning the elements is much more a question of trial and error than simply cfdcoument the top and left positions as measured with a ruler and perhaps tweaking them by a few milimeters if necessary.
Also without the parent div tag to control how layout elements scale, changing the dimension of one absolutely positioned div within the PDF can easily alter the position or size of other divs, which can be very frustrating if you have 20 or 30 elements that all need to be precisely positioned.
For myself, I found it easier simply to measure placement from the edge of the page. Specifying a font for a block of text is simple. As of this writing, available CSS attributes remain limited. Unless something changes in the future, forget OTF fonts for cfdocument.
I tried a bunch that already seemed to be recognized, none worked. From my experience, using the font face name in your CSS specification should work. If not, try the other names – I saw a post suggesting that. The file ccfdocument often does not match the font name.
CFDOCUMENT, PDF, and CSS | Adobe Community
For Lucee, the process is different. Copy it to a working directory, rename the copy to fonts. In the unzipped fonts directory that results, add your custom font files, again use only TTFs, and then open the pd4fonts. Keep a copy of it, just in case … replace the old fonts. Of course, the above approach for Lucee 4.
But for now, it works like this. A ccdocument thanks to Michael Hnat for pointing me in the right direction regarding Lucee with his very helpful blog post. There is a logo image at the top of this PDF that was scaling up when rendered in Lucee in a way that caused it to be misplaced.
After a bunch of reading that indicated modifying the image print size or resolution would not help, I tried adding a css style declaration to the image that specified a size in mm, and it worked!