I'm trying to use cfpdf to transform some pages of...
# cfml-general
a
I'm trying to use cfpdf to transform some pages of a PDF in order to rotate them... for instance... I have a 4 page PDF and pages 1-3 are portrait and page 4 is landscape... I want to transform only page 4 to rotate to portrait and I've done that successfully, but it seems when you specify the pages attribute of cfpdf, then it only saves that page... i.e. pages="4" rotate="90" produces a 1 page PDF with only page 4. But I still want pages 1-3 in the PDF, they just don't need to be rotated. Any ideas?
e
Render each page individually, then merge them into a single pdf.
a
yea, I thought about that... it's already a complex process of downloading many files from the cloud, merging, adding watermarks, etc... so I was hoping to avoid another routine like that. Seems like a flaw in the design of cfpdf to me to work this way.
m
evil ware has generally the best answer. modifying pdf files is pretty bad in cf. doing what he suggested works well (for those cases where it will work haha) for a really complex process, I'd almost suggest creating a microservice in node or the like.
a
I was also thinking about just rotating the original documents when they're uploaded to the system... so that when I'm merging them they're already all in portrait mode
m
the smaller the pdf cf is working with, and the simpler the change, the better your success. then you can merge the bits together into one file (cf seems to handle merging ok enough).
a
I also came across this post but haven't tried it yet: http://stillnetstudios.com/rotating-pdfs-in-coldfusion/
of course I'd have to add logic to check the page orientation before rotating but I already have that in my existing code
I ultimately ended up going with Evil Ware's suggestion of deconstructing them into individual files, manipulating them and then merging them back together.
👍 1