|Welcome to the Monastery|
PDF::API2 text problemby samwalker04 (Initiate)
|on Aug 30, 2012 at 23:05 UTC||Need Help??|
samwalker04 has asked for the
wisdom of the Perl Monks concerning the following question:
My application receives a PDF that the user uploads, then I use PDF::API2 to open the file, print a few words in 10 point font at the top left corner of the first page of the PDF, then save it to a folder. Pretty simple.
I figured out how to do this by trial and error, and it has worked fine for months, but I recently found a problem. A user uploaded a PDF and the text was printed on the first page but instead of the top left corner in 10 point font, it was printed in the middle of the page in tiny microscopic font.
What was different about this PDF? Well it was PDF Version 1.3, which is pretty old, so I thought maybe that was the problem. But then I tested a different 1.3 PDF and it worked fine.*
*It worked fine only when I commented out the code in the API2 module that checks PDF version and actually returns an error when I try to work with a PDF of version 1.3. I have no idea why this code doesn't give an error when I upload the original, problematic 1.3 PDF. I am leaving this code commented out because I really need to be able to process older PDFs if possible.
In summary, I have no idea why my code is putting my text in the wrong place and at the wrong size for this one document that happens to be PDF Version 1.3 (Don't know if that is even relevant). Here is my ugly code that may be fraught with errors, please help!