So I need to download PDFs that are password protected, unlock them, and then display them via the UIDocumentInteractionController. So far, I'm downloading the password protected PDFs and found out how to unlock a PDF using the CG framework (CGPDFDocumentRef) but I can't figure out how to get the unlocked document back as an NSData from CG. Plus I'm not sure how to pass UIDocumentInteractionController an NSData object. If anyone has done this before, please help.
The answer is no. UIDocumentInteractionController only works with NSURL objects and there is no way to pass UIDocumentInteractionController in-memory data. Since I didn't want to spend any more time on this, I decided to instead, each time a user taps the document, to decrypt the PDF, save it to disc and then pass UIDocumentInteractionController the path to the temp file (temp file must exist on disc while UIDocumentInteractionController is open). I'll probably have to role my own PDF viewer if this doesn't fly with the client's security requirements.
Related
My app downloads a PDF file from a web server and stores it locally on the iOS device. I then display it to the user using a UIDocumentInteractionController which is declared as a property named "controller" in the .h file.
NSURL *urlToFileToPreview = [NSURL fileURLWithPath:pathToFile];
self.controller.URL = urlToFileToPreview;
[self.controller presentPreviewAnimated:YES]
This works perfectly, but the UIDocumentInteractionController preview provides the ability to highlight text and add comment boxes, and I can't find an example of how to save those annotations so that when the file is opened again they are persistent.
Since I already have the URL of where the file is stored in the device's Documents directory, it would be a simple matter to overwrite it, but I have no idea how to extract the "changed/highlighted" file once the user presses the done button.
Since I can't find a way to save the changed file I simply want to disable highlighting so that the user doesn't have the expectation that the changes they have made will be persistent.
We have this big web project where the user can print the html to pdf. We are using dompdf, and have somewhat fixed the long cell issues that cause the pdf to have several blank pages. Now the issue is that the saved pdf, when closing, always asks if the user wants to save changes. I have verified that the pdf has the proper %%EOF, and have checked for object consistency. What else could be causing this problem?
After reading this introduction to pdf I realized that if the pdf was modified, I had to accomodate all the object offsets so that they would point to the object start location.
I have an app opening URLs that may be PDFs.
I can detect a PDF is opened in the UIWebView control, and if so, I propose to save it locally, in the iPad.
To date, the only solution I found (as described in this topic : Save PDF which is displayed by UIWebView locally, is to RELOAD the remote PDF file in a new NSData object, then save it to disk.
Is it possible to use the UIWebView's NSData property, and write it directly on the disk, to avoid reloading a potentially large PDF file that is already loaded and displayed ? Thanks to all.
I think you can't access the data that the UIWebView caches. But, you can download first the PDF and later display in UIWebView from the local PDF.
EDIT
Reading your question I understand that:
First you display the PDF in you UIWebView.
You ask the user for download.
You download the PDF (Second request for the PDF).
I propose you:
Check that the URL is a PDF.
Ask user to download.
Download it.
Display the PDF in UIWebView loading the local file.
Did you examine the UIWebView content, using...
NSString HtmlCOntent = [NSMutableString stringWithString:[self.webView stringByEvaluatingJavaScriptFromString:#"document.body.outerHTML"]];
It could help you to understand how the WebView deals with the content of the PDF file
Situation:
(Large) PDFs are stored on an iOS device
The PDFs are encrypted using a Rijndahl algorithm
When tapping one of the PDFs, it gets decrypted and afterwards viewed using a PDF viewer I implemented. The viewer is using the Core Graphics functionality to render the document page by page.
Issue:
With the documents being large enough, encrytion will take a while.
Viewing can only be started after the whole document has been decrypted into a temp file.
I'm wondering, if there is a way to...
Pass some kind of stream to CGPDFDocument instead of a file URL
Or any other alternative to be able to view as many pages as possible whil decrpytion is continued in the background?
If you cannot split your original PDF files down to single pages (as I suspect), then the following approach should work:
A: When still decrypting:
try to open the PDF document as you already do;
try accessing the document page you are interested in;
if it does not fail, render the page;
if it fails, then you know that page is not available yet (while decrypting);
while decrypting, release the pdf document each time you try to get a new page.
B: when decryption is done: do as you are already doing.
Please note that this is just a suggestion, I have not tried this while decrypting a document, but if point 1. does not fail, then this should work.
I've got a form that I downloaded, I'd like to prefill some content on the form (this is easy using cfpdfform).
Where it gets tricky is I would like to allow the user to modify the contents of that form, and then somehow have those modified contents accessible to me. I didnt build the source PDF so I dont know how to allow the user to "save" the new contents so they can be read.
Any ideas on where I might start on this one?
You can also use the cfpdfform tag to read/write data to a PDF file which has a form. The important thing is that the PDF document already have the form fields available, or that you add them.
I just recently completed a task where I had to have a user fill out a normal web form, and then create a filled version of an existing PDF document. It worked like a breeze!
I think that depending on what you are trying to accomplish, having the user fill out the data in a web form is less confusing than serving up a PDF and expecting them to save that to update a file on a remote server. Just my opinion, though.
http://www.cfquickdocs.com/cf8/?getDoc=cfpdfform#cfpdfform
It's possible for users to complete most PDF forms in Adobe Reader, but when user's try to save the changes they get a popup prompting them that the PDF cannot be saved and would need to upgrade to Adobe Acrobat to have this functionality.
Since Acrobat 7 (or possibly) 8 it's possible to create a form so that it can be completed and saved in reader. In Acrobat open your PDF, and select Advanced -> Enable usage right in reader from the menu. This will prompt you to save the form and then anyone using Adobe reader can complete it.
Once that's done you can open the form in ColdFusion, populate some of the fields and serve it up to the user. Once they fill it in, save it and get it back in ColdFusion you can read the contents using the PDF related tags.
Please note: It's currently not possible to set the "enable usage rights in reader" flag from ColdFusion, you need a copy of Adobe Acrobat or access to Adobe LifeCycle server to do this.
This document may help you:
http://www.adobe.com/education/instruction/teach/coldfusion/CF8-2_advanced_cf8_development_unit8.pdf