I'm trying to figure out if there is any way to insert an image into a specific page on a pdf file. I was analying this example http://www.raywenderlich.com/6818/how-to-create-a-pdf-with-quartz-2d-in-ios-5-tutorial-part-2 and other, and they always create a new PDF file.
Is there any way to draw above the PDF page with already existing content using Quartz 2D?
seems to be a duplicate question. Look at my question and the answers -> What is the best way to manipulate an existing PDF-Document under iOS?
Related
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Get PDF hyperlinks on iOS with Quartz
All are in title.
I want to display a PDF with hyperlinks in iPad.
At this time i have a display of PDF (page by page with 2 button that increase or decrease the current number of page in PDF) with CoreGraphic but not the hyperlink and i search a sample that make that because i don't really understand the specify of CGPDFDictionary and other function like that.
Thanks in advance for your answer.
P.S : Sorry for my bad english i am not very in this langage at this time but learn for remedy that.
Depending on what you are trying to accomplish, rendering the PDF using a UIWebView may be a better option as link rendering will be automatic. Keep in mind that using a UIWebView will force the entire PDF to load and it will scroll vertically as opposed to horizontally by page.
I want to create PDF with proper format like proper text and image would be on proper format like normal PDF file.
I know how to create PDF with image and text but I don't know how to format it & I also know that PDF can be converted from HTML by displaying it's content on webview and capturing its screen in image and converting it into PDF.
But is there any another way or any tag available like HTML.
Or is there any third party tool available for this issue.
You can create a PDF drawing contect with CGPDFContextCreate and then draw with standard Cord Graphics 2D functions as you would draw on the screen. See also this question: iOS SDK - Programmatically generate a PDF file
I am doing something like extracting the pdf text in a string format so as to annotate the text and in the same process i need to find the image positions covered in the same pdf file so as to maintain its position. Now the problem is that i am not getting the exact positions of the images in the same pdf file. Is it possible to use some thing like OCR,if yes,how to use that?
Can anybody help me in finding the exact position of the image in the pdf file? I need to implement some pdf reader kind of application for ipad,that's just for the knowledge.
Thank you.
Isn't OCR a little bit heavy weight for iphone?
Take look on tools like pdftotext from Xpdf. It is much simpler to read data, as to render and recognize it back again.
is UIWebView the only way to open a pdf document on the iphone? how can i interact with the document? eg: getting the current page number?
You should read the Apple documentation about Drawing with quartz 2d. There's a section just about handling with PDF documents.
If you don't like to show a PDF in a UIWebView, you create your own view. Just subclass UIView and overwrite the method -(void)drawRect:(CGRect)rect for your custom drawing. Create a CGContextRef a draw your PDF directly in that context using the specific function of core graphics. Core Graphics provides a lot of other functions for PDF documents, like Kalle already mentioned.
If you're not really used to core graphics, it's really difficult sometimes and you probably need a lot time to get used to it, so I recommend using UIWebView to display a PDF. It relatively simple.
It's not the only way. There's a whole toolkit built in which lets you render PDF pages to a UIView. Check out:
CGPDFDocumentCreateWithURL
CGPDFDocumentGetNumberOfPages
CGPDFDocumentGetPage
CGContextDrawPDFPage
to name a few (core graphics) functions that relate to PDF rendering.
Beside UIWebView, if you want a high level interaction class, check out: UIDocumentInteractionController, QLPreviewController.
Depending on your needs, check out the accepted answer to this question.
Check Apple's ZoomingPDFViewer for a simple example: http://developer.apple.com/library/ios/#samplecode/ZoomingPDFViewer/Introduction/Intro.html
In my iPad application I want to add signature in my pdf file.
I already do perform following steps:
Open pdf in UIView (zooming is not implemented yet).
Add one transparent subview (UIImageView) and draw signature on that.
Save all screen using UIGraphicsGetImageFromCurrentImageContext() as a image.
Convert and save the image as a pdf.
This is works fine but pdf quality is very poor.
But now I want to add a signature/image as a pdf metadata. Same as a markup and commenting features of PDF.
Is there any help or sample code is available for the same?
It should be possible to improve the quality of the output by skipping the image/pdf conversion, but afaik there's no lib that will help you editing the metadata of a pdf on the iPad (at least, none that's freely available).
Depending on what exactly you want to do, you may have to write a parser from scratch to know what exactly you have to append to your document to see the wanted effect:
It is very easy to append data to a pdf, but it has to be "registered" in the right locations so that a reader can use this information.