I wanted to add a PDF generation button for articles. Everything is working well until I noticed that the file sizes are upwards of 4MB for a document with 200KB of JPG images and about 120KB of HTML. So, I tossed the CFDocument into the CFPDF tag which reduced it to 1.5MB. Better. Then I put it through Acrobat's web optimizer which took it down to 335KB. I cannot find an "optimizing" solution with either CFDocument or CFPDF. I was hoping for a quality setting or something. I should also note that CFDocument takes a while to process (relatively speaking). Since ColdFusion 9 added an optimize function, I'm guessing that I'm out of luck until this server is upgraded. True?
<cfdocument format="pdf"
localurl=true
name="loc.tempPDF">
<cfoutput>#loc.articleContent#</cfoutput>
</cfdocument>
<cfpdf action = "write"
destination = "#expandPath('\pdf\temp.pdf')#"
source = "loc.tempPDF"
overwrite = "yes"
saveOption = "linear" />
That's correct, there is currently no way to optimize PDFs in ColdFusion 8 with the native cfdocument or cfpdf tags. If you absolutely have to make this happen without upgrading to CF9 (which has much improved PDF compression), then you could look at the iText library for generating PDFs via Java.
I built a Document Management System using CF 6.1 a few years ago. I used GhostScript to create, concatenate and optimize PDFs.
Here's a blog post showing how you can use GS to optimize a PDF's size.
Related
We have a requirement to extract the content of an uploaded PDF and then show it in a text area with the same formatting. Our application runs on ColdFusion 10.
We used cfpdf however the extracted text is a single paragraph with No formatting.
Is there anyway in ColdFusion to read the PDF as text retaining the source formatting (100% accuracy is not expected) .
Note:
We tried itext and it works very well however it comes with a licensing cost which I don't want to spend as I'm only going to use this single feature from the bundle that itext is providing.
Tried PDFbox but the formatting is not retained.
I recently had to move several older websites that were running in Coldfusion MX7 onto a server running Railo 4.2.1. These sites all use either CFX_Image or CFX_OpenImage tags for resizing uploaded images. It looks like I could rewrite them all to use CFIMAGE, but I'm hoping to get these older sites working as is, at least for know.
Does anyone know of a way to use the C++ CFX tags in Railo 4.2.1?
Railo 4.2 is supposed to be compatible with CF 10 but it doesn't support C++ tags. It's intended to be compatible as far as cfml syntax goes but
there are however a few things railo doesn't support, c++ cfx tags being one of them. It does support Java CFX tags. Read this
But you can always use cfimage tag to perform various image manipulation operations including image resizing. Like this
<cfimage
action = "resize"
height = "number of pixels|percent%"
source = "absolute pathname|pathname relative to the web root|URL|#cfimage variable#"
width = "number of pixels|percent%"
destination = "absolute pathname|pathname relative to the web root"
isBase64 = "yes|no"
name = "cfimage variable"
overwrite = "yes|no">
Environment : ColdFusion 10 on Windows 8.1 and ColdFusion 9 on Windows Server 2008 R2 Using standard versions of IIS.
I am using cfdocument to generate a standard format letter that has variable content.
In amongst the content is a table that has a fixed width (width::700px;) The document size is A4 with left and right margins of 1.7 cm
I have found that when executing the code on ColdFusion 9, when the width of the table (irrespective of table content) causes the edge of the table to impact the document margin, then cfdocument decides that it ought to auto-scale and it proceeds to reduce the font size of the whole document.
Which would be fine, except that the client insist that the document be produced using a font size of Arial 10 pt. We don't want autoscaling.
We found that reducing the width of the table did the trick, and stopped ColdFusion 9 from messing with the document scale. We had to have a good dose of imagination to accomplish this, because the issue did not appear even when we added a border to the table.
I note that we have set scale="100" set in the cfdocument directive, but in this case it seems to be ignored, and no error message of any sort.
Now, with ColdFusion 10, behaviour seems to be different.
Having reduced the size of the table as above, running the exact same code and the exact same data, I find that cfdocument has decided to up-size everything from 10pt to 12pt just because it feels like it.
The issue for us is that we are developing on PC that runs ColdFusion 10 to a server that runs ColdFusion 9.
So you can imagine that this means extra development/testing effort. It is real pain.
I can find no documentation from Adobe that mentions changes to the behaviour of cfdocument between
ColdFusion 9 and ColdFusion 10.
Is there any way to tell cfdocument to stop messing with the scale of the document and have it stick for ColdFusion 9, 10 (and 11) ?
I've hit a weird snag developing a reports using ColdFuions 8. The report prints a number of large HTML tables and the customer wants them to be formated ins such a way that when they are printed out the user will get 2 of the tables per page.
So it wasn't hard to make a page break by using a
<p style="page-break-before: always"></p>
However, while I got the desired effect while using the development ColdFusion environment on my laptop, I get a diffent effect when printing reports generated on the test web server. There the reports print out with a much larger font so that the second table spills over onto a second page.
Has anyone else experienced this or has a recomendation for how to try and tackle it?
When a report needs to be printed, I would recommend using CFDOCUMENT to create a PDF. You get much more control over the final output including changing page orientation which is great for tables that are wide. It honors a lot of HTML and CSS including the page-break-before style so you shouldn't have to do to much conversion to use it outside of wrapping the report area with CFDOCUMENT tags. It has been available since CF7 so it should work for you on CF8.
I have a webpage, where user has a possible to Print this page OR to save it on his/her computer.
How may I save it as a Word or PDF document?
Thanks.
For the MS Word requirement, most versions of Office can interpret basic html/xml. So you might consider the old cfcontent hack as a simpler alternative to POI. (The Word package is not quite as mature as the spreadsheet package.)
Basically you generate html, but use cfheader/cfcontent to tell the browser the content is really a Word document. It is obviously not a true MS Word file. But it is simpler than most options.
http://msdn.microsoft.com/en-us/library/aa155477.aspx
<cfheader name="Content-Disposition" value="attachment; filename=someFile.doc">
<cfcontent type="application/msword">
... your html code here ...
For microsoft office documents you can use the Apache POI project. This means in your coldfusion code you need to use some basic java code to call the poi methods.
However, if you choose the pdf document things are quite easier. You can use the cfdocument tag with the PDF format option
Using the POI or OpenOffice interface (depending on your version) you can create a Word doc. Using the built-in PDF generation tools, you can create a PDF doc. HOwever, you can only present that as an option.
There is no way to override the save/print menu functions. No matter how you handle it, I cna save the source document instead of the .doc or .pdf. Similarly, you cannot prevent me from printing the original document, instead of a prepared PDF.
Here is a method that has worked for me:
Create PDF or FlashPaper with ColdFusion
However, just like printing, you will have to sacrifice some graphics, so this would be best used for exporting content (but as you did not specify, I'm just clarifying that this is possible but at a cost).
Hope that helps.
Use cfdocument to display as a PDF, then they can just click the disk image to save it to their computer. Or you can use the filename= attribute of cfdocument to assign a filename to it, and it will prompt them to save it instead of displaying in the browser.