I need to include some extra text to an existing PDF utilizing Python, what is the finest way to set about this and what extra modules will I require to set up.
Keep in mind: Preferably I wish to have the ability to run this on both Windows and Linux, however at a push Linux just will do.
I understand this is an older post, however I spent a long time searching for an option. I encountered a good one using just ReportLab and PyPDF so I believed I ‘d share:
read your PDF utilizing PdfFileReader(), we’ll call this input
produce a brand-new pdf including your text to add using ReportLab, conserve this as a string things
read the string object utilizing PdfFileReader(), we’ll call this text
create a new PDF object using PdfFileWriter(), we’ll call this output
repeat through input and apply.mergePage( text.getPage( 0 )) for each page you want the text contributed to, then use output.addPage() to add the modified pages to a new document
This works well for basic text additions. See PyPDF’s sample for watermarking a document.
pdfrw will let you check out in pages from an existing PDF and draw them to a reportlab canvas (comparable to drawing an image). There are examples for this in the pdfrw examples/rl1 subdirectory on github.
If you’re on Windows, this may work: PDF Developer Pilot
There’s also a whitepaper of a PDF production and editing framework in Python. It’s a little dated, however possibly can give you some useful info: Utilizing Python as PDF Editing and Processing Framework
You might have much better luck breaking the problem down into converting PDF into an editable text, composing your modifications, then converting it back into PDF. I have no idea of a library that lets you straight edit PDF but there are lots of converters in between DOC and PDF for instance.
Changing PDF straight on iPad/iPhone is actually a rather massive task because the standard API just sustains showing it (and only a little bit a lot more.) If you desire to do anything even more, you require to put in a big amount of your time to perform common pdf regulating code.
A far better idea, in my opinion, is to generate a native UI revealing the relevant information was composed of in the PDF documents using the fundamental Cocoa-Touch UIKit as well as create the PDF once the consumer is actually produced using it thus that the user can easily export it back. That approach, you perform not require to create a complicated PDF managing code.
I believe Adobe maintains PDF customizing functionality rather finalized and exclusive to ensure that they can easily offer licenses for their much better models of Performer. Maybe you can easily locate a means to automate the utilization of Artist Pro to modify it, making use of some form of macro customer interface.
I prefer the user to be capable to modify or feature discuss these PDFs, together with possess the capacity to highlight details locations in the PDF. After editing and enhancing, the use should possess the capacity to save the PDF back right into the reports listing internet site.
There is actually an open-source public library managing these, e.g. this site. I perform certainly not recognize if it accommodates your requirements.
All the same, it is actually certainly not an exceptional idea to reveal generic PDF on apple iphone, because of the reality that the display screen dimension is therefore small (iPad is actually a various worry, primarily if you assume the consumer to be actually familiarized along with those format of your pdf.). A committed UI would be actually much a lot better.
In my apple iphone/ apple ipad use, I show a person’s clinical files such as a PDF. I have actually saved the reports in the files listing and read all of them coming from there.