![]() |
Need help editing a PDF - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Need help editing a PDF (/thread-38490.html) |
Need help editing a PDF - omar - Oct-20-2022 I want to find out what I can do in Python for editing PDFs. The PDF's will have many pages, each page with have 4 labels. I need to add extra information on each label. It's super important that each label is left in it's original format and nothing is added or removed - but... I do need to read the information from each label and compare with a file in a CSV record. I want 2 versions... First version: I want to add extra information on a specific location on the label. The extra information will be a simple clipart graphic. Second version: I want to shrink the labels by 20% from the top left - so I can add my extra information below in the extra space that will be made when I reduce by 20%. Ideally... I would like to NOT reduce my reducing an image of the labels. The labels contain text and a barcode and a QR code. It's important that all these still remain in tact but just reduced. Just looking for ideas right now 🙂 What libraries and tools are there that I can use to do what I want? I want to know what I can and cannot do in Python given the above description. Thanks. RE: Need help editing a PDF - rob101 - Oct-20-2022 I've also been looking into PDF editing and I think I'll be using PyPDF2 2.11.1 Not had time to go in deep, but what I've found so far looks good (for my usage, least ways). I hope it helps you. RE: Need help editing a PDF - Pedroski55 - Oct-20-2022 I think what you need to do is make a new pdf and copy stuff from the old pdf to the new one, modifying on the way. Have a look here for a simple example. I use reportlab to create pdfs sometimes. Once you have the format set, the rest is easy! I only use pypdf2 for getting sections, chapters, pages of a pdf. reportlab seems complicated at first, but you have absolute control over everything. Read the reportlab user guide! (But I don't think it contains exhaustive info on all possibilities within reportlab, you have to ask around.) RE: Need help editing a PDF - omar - Oct-22-2022 Thanks for the replies guys. It would be much much more preferable for me to edit and add to the existing PDF as opposed to create a new one. The existing PDF has square outlines as well. Just wondering... do PDF's have some sort of structure like HTML? 🧐 That would definitely help my cause. See the pic below. I want to write code that searches for 'Code 123456' and below if inserts text and graphics that I want to add. ![]() Hoping the pic helps to explain what I want. Thanks. @Pedroski55 Your link looks perfect... just read the sample code. I think it's got the start of what I'm looking for. 🙂 My PDF will be 10 - 50 pages, for each page there are 4 sections where new content needs to be added. I'm sure if I can master editing 2 pages, then I'll be good to go from there. RE: Need help editing a PDF - Larz60+ - Oct-22-2022 FYI: If you are interested in getting down to the nitty gritty of pdf's start here, this is useful when writing partial handlers, or if you had something greater in mind. |