Posted in Development | Posted on 07-26-2007 | 2,913 views
Every needed to extract a page from a PDF document? Yesterday I blogged my new little CFC called PDFUtils. The idea was to take the power of CFPDF and wrap up some utility functions. The first function contained a simple getText() utility that would return all the text in a PDF.
Today I added getPage(). As you can guess, it grabs one page from a PDF. How? Well CFPDF doesn't support getting one page, but it does support deleting pages. All I did was add logic to "flip" a page number into a delete order. This then lets you do:
2
3<cfset mypdf = expandPath("./paristoberead.pdf")>
4
5<cfset page2 = pdf.getPage(mypdf, 2)>
6<cfdump var="#page2#">
7
8<cfpdf action="write" source="page2" destination="page2.pdf" overwrite="true">
Running this gets you a dump of the PDF object and a new file named page2.pdf that is just - you guessed it - page 2.
I've reattached the code plus sample files and PDFs.


<cfpdf action="merge" source="sourcefile1.pdf" pages="#n#" destination="destination.pdf">
The attribute source specified in the CFPDF tag is either empty or invalid. <br>The error occurred on line 31.
I tried this line:
<cfpdf action="merge" source="arguments.pdf" pages="#arguments.page#" name="result">
I have tested the below code. It works.
<cfpdf action="merge" source="source1.pdf" pages="7" destination="desti1.pdf" overwrite="true">
Thanks,
-ahamad
http://pdfutils.riaforge.org/
/B5A372B72DB18C75852572C3006068E2/$file/2007cpf.pdf?OpenElement) and I'm grabbing out page 5, for example. When <cfpdf> writes this single page back the file size is about 381kb, but if I do this same thing directly in Acrobat 8, open full document and simply delete all pages but the one I want, the single page size is a measly 13kb. What's with that? An issue with the PDF write in CF8? Very frustrating for the system I'm creating as this is a space issue on the server now. Having 57mb of single PDF pages is much better than 1.6gb of single pages!
Any insight into this? Cheers.
http://www.ppinapod.us/pdf/2007cpf.pdf
I was having similiar issues with the file size of the pdf being quite large. A one page PDF was coming out as 483 kb. In my document I was using a JPG for a header and a JPG for a footer by using the processddx command. The header was 150 kb and the footer jpg was 180 kb. The dimension of each of the jpg was somewhere around 2000 x 400. (I was given these images by another employee), but in my img tag I was specifying the height as 150px.
I ended up reducing the size of the jpg images to just a little more than 150 px in height and changed the file type to gif (I have found from other posts that cfdocument does not like jpg files) Both images combined are now under 30 kb.
The good news is that my pdf went from being 483 kb to 72 kb. Not sure if you are using images in your pdfs, but I thought this might help someone.
No images in the first PDF, but I am now working on a project for my local church district website. This PDF does have some images, but even on pages that have no images I get this issue.
The new PDF that I'm having issues with is http://www.enynewesleyan.org/pdf/journal.pdf, which is 6.52MB - and I delete all pages but one which only has text and the PDF is still 6.52MB. I then download this, open in Acrobat and re-saved as PDF Optimized and now the file is only 67KB - this is a HUGE difference. This is a 133 page document, and 6.52MB for one page is just too big.
Paul,
who did you contact at Adobe? This seems to be to be a major issue since. Any additional help would be greatly appreciated. Cheers!
thanks for this blog...it helped me alot..just one question
is there any way we can use remote url of pdf for merge or thumbnail process..as it only works with local path..
any help would be appreciated..
thanks
[Add Comment] [Subscribe to Comments]