-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for appending to existing PDF / TIFF files #2959
Comments
I'm aware of that, but as far as I can tell, you can only create new PDF files (and yes, then append more images to them). (I have actually since realized that I'm stupid and what I really need is merge two PDFs into one (or, open a PDF image and append it to another PDF). But appending images to an existing PDF is potentially still at least half a solution, and I have it done, so I might as well contribute it.) |
You're right, sorry, I have forgotten that Pillow does not read PDFs. Regarding the TIFF format though, that at least should be able to be handled by Pillow, yes? |
Well in the sense that you can open a TIFF file and then write it back from scratch while appending another image, yes. If you want to avoid the overhead of reading and writing back, there actually is an existing solution in Pillow called TiffImagePlugin.AppendingTiffWriter, but there is no standard API and I don't even think AppendingTiffWriter is documented. (It is used internally by TiffImagePlugin for writing multipage TIFFs.) |
So, here's my attempt at an implementation for PDFs. Supports PDFs up to version 1.4. Tested with Python 3.6 and as far as I can tell, works great. The pdfReader module itself is tested with Python 2.7 as well, but not the PdfImagePlugin part. I haven't touched the documentation at all yet. |
…remnants of text writing from PdfImagePlugin
So this has turned into a major rework of PdfImagePlugin. :) I have now added tests and am confident it works nicely, and in fact opens the path for some more new features, such as specifying key+value metadata when saving PDFs, specifying margins or placing on the page and perhaps even opening bitmap PDFs. Any feedback, please? Pretty please? :) |
I'll take a look. |
…thods to support writing, eliminate the passing of file or buffer
I'm now reasonably satisfied with the result. Documentation and tests are done as well. What do you say? |
Sorry to nag but... merge please? Or more feedback? Thanks. :) |
I'm not going to have time to look at this until friday at the very earliest. |
Would it help, hypothetically, if I somehow split this into multiple smaller pull requests? |
I need the ability to append images as pages to existing PDF files.
I have an implementation for PDFs up to version 1.4. Seems to be working fine as far as I can tell, but if anyone knows of any tools to verify the correctness of a PDF, or in general an idea for how to test this other than verify that I can open the PDF file and it looks right...
Would a pull request be welcome for this?
The same could also easily be done for TIFFs, I believe.
The text was updated successfully, but these errors were encountered: