What is the best way to manipulate an existing PDF-Document under iOS? - ios

I need to individualize documents within an iOS-App. I could provide the origin-documents as DOCX, PDF, PPT etc. The output-format has to be PDF.
My minimun requirement is to fill some text-fields. Nice to have would be to replace an image, too.
I´m quite used to generate PDFs programmatically using UIGraphicsBeginPDFContextToFile etc. But in my current case I don´t want to create the whole document programmatically, I just want to replace some content.
Any hints / tipps?
Thank you in advance.

DOCX is a zip - format file so you can process the contents programmatically and the reconstruct the zip file. PPT is a binary format though newer versions of PowerPoint might also construct zip-oriented versions that you can programmatically process. You mentioned though that you need don't want to programmatically process these documents - which I would probably also do only as a last resort.
For your DOCX origin/source documents (or doc,odt,rtf but not ppt/pdf) you could use Docmosis cloud services if your app can have the external dependency. You would upload your DOCX origin documents with placeholders for text-fields or images as a one-off/occasional task. Your iOS app then calls Docmosis sending instructions and data to create the output PDF and either stream it back to the app or email/store it or both.
The upside is it takes all the load and coding away from the iOS application (there is an SDK). The downside is it is an external depdendency. Please note I work for the company the created Docmosis.
Hope that helps.

Why not just load a page in a webView modal that points to a URL of a page you create? The main parts of the page would be static, and then the fields you need to customize would be populated via Javascript or PHP.
For example, we have a contact form in our app that gives you an option to view the details of your completed form after you submit. When the user clicks on the button to view the Contact Confirmation, it loads example.com/confirmation.php in a modal view within the iOS App.
On the confirmation.php page (on the web), I use PHP to pull in $_GET variables from the URL parameters which then populates the page with my static content, and their customized information that they entered into the form.

Related

Editing a PDF in UIDocumentInteractionController and saving..?

I've got an 'interactive PDF' that I need to be able to edit and save in an iOS app and I'm looking at how to achieve it. It's got text boxes and radio buttons which I can interact with in the UIDocumentInteractionController preview (or QLPreviewController) but there doesn't seem to be a way to save those changes to the file that was loaded and if I share the live and edited file to my mac via AirDrop it doesn't send the changes, rather it seems just the original file.
I don't really know anything about interactive PDFs so not sure how added text would normally be saved. I've found that the 'Files' app (added in iOS 11) actually saves the edits you make, so that's basically what I want to be able to do.
At the end of the day I just need a way to be able to interact with a PDF in my app and save the changes. Do I maybe need to use a custom PDF viewer rather than trying to piggy back off the standard iOS file previewer functionality?
Looks like this library solves my problem: https://github.com/derekblair/ILPDFKit
It lets you edit a PDF, access and set individual fields and save out as a static PDF.

iOS - Download files to application folder

I do have a UIWebview inside one of my UIViewControllers. The destination URL to be displayed within the WebView is a page on my server (therefore I have access to make changes on it).
That page basically has a list of PDFs to be downloaded (imagine an un-ordered list of hyperlinks each pointing to a PDF file).
I need a way to tell my App that whenever a file is downloaded from that WebView by clicking on one of the links, I need it to be saved inside my application folder instead of the iPhone/iPad memory.
Is there any way I can achieve that? Are there alternatives?
You can allow UIWebView to call your Objective-C delegate function. This link provides an overview of how to do it: http://dblog.com.au/iphone-development/iphone-sdk-tip-firing-custom-events-when-a-link-is-clicked-in-a-uiwebview/ Basically, the delegate function will be called on all requests from the UIWebView. You can examine if they are for links to a pdf files, and if so, write your own objective-c code to download the file and store it in your Application directory. You'll probably want to add some UI to let the user know what is happening. Otherwise you let the request go on as normal and it will be displayed in the web browser.

How to fill the fillable PDF in iPhone?

PDF Expert is an iPhone application that enables user to fill the editable PDF and can save it. means It is editable form.
I used UIWebView to show the PDF, It showing exactly as it is, but the text field on it is un-editable.
I tried using the UIDocumentInteractionControllerto view the pdf, It showing well, but I can't edit on that file.
In safari browser of mac It supports only viewing the file, but Google Chrome supports editing of the file. and While opening the file using Preview application on mac, It allows edition to the user and can save it.
Please suggest me, How to edit and save the file in this..
Thank you...
I was after the same thing and found this to be a seemingly good solution: https://github.com/derekblair/ILPDFKit
Lets you fill in a form, access/set fields and then save out as a static copy.

PDF generation in XCode

I am a newbie in iPhone development. I am planning to do a PDF application for iPhone. The functionality is:
User will type their input in a text field (which is going to be the content of the PDF file).
I have to modify the PDF file through code while saving (paragraphs, tables, bullets etc).
User can save it in their own name.
User can send the PDF file as attachment of MFMailComposer.
So I have searched and got many links. However I didn't find any leading details to create and modify a PDF file in iPhone/iPad.
Can anyone please provide me a good reference to do this. Are there any alternatives to do this?
I've used this reference: https://developer.apple.com/library/ios/#documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_pdf/dq_pdf.html
It contains theoretical explanations and source code examples
Please use the below link to download sample apps for PDF Reader/Viewer in iOS
PDF Reader/Viewer in iOS
Also please look at detail about pdf creation, manipulation etc in below links
developer.apple: PDF Document Creation, Viewing, and Transforming
Fast-and-lean-pdf-viewer-for-iphone
If you were doing a Phonegap app I'd say got for jsPDF, which would enable you to create (basic) PDF files in Javascript. I don't do Obj-C, but a quick look on SO provides good links.

Pdf modification on iOS

I am looking to be able to open a pdf file (done) and then be able to use the touch screen to sign the pdf and then save it with the modification. From what i have read this is no easy task, and i have no idea where to begin. Any of you know any tutorials or frameworks that will help me with this ?
Also if possible being able to modify fields of a pdf file, on the desktop the pdf can have fields you can click on then type in to fill out the form, without the need to ever print. If this is possible as well that would be perfect.
Thanks.
Maybe libHaru (http://libharu.org/wiki/Main_Page) does what you want, it's worth a try.
Does your starting point have to be a PDF? steipete's suggestion of using a system to create the PDF would work if your app workflow could create the PDF (sans signature) and display it, the user "signs" it in your app, and you create the PDF again this time with the signature embedded. It depends on whether this flow is an option for your app. Often it seems easier if you treat PDF as a final document and produce the PDF in it's final form each time (final meaning that you're not going to try modifying it).

Resources