Note that there are some explanatory texts on larger screens.

plurals
  1. PODraw content on existing PDF Document in specific Page
    text
    copied!<p>So I am implementing a specific type of PDF editor for the iPad, for personal use. I have already implemented the PDF viewer, and now i am stuck in the editing part. Here is the deal: I display each page of the document in a UIView, and then create another view, with the exact same size of the page inside it. I then let the user draw on the view</p> <p>Now, say i want to print that UIVIiew in the exact page of the PDF file it was drawn. I am aware of a way to do this, but it is taking too long for bigger documents. I was doing it like this (simplified the code for better understanding):</p> <pre><code>UIGraphicsBeginPDFContextToFile(file, pageSize, nil); for (size_t currentPage = 1; currentPage &lt;= pageCount; currentPage++) { UIGraphicsBeginPDFPageWithInfo(pageSize, nil); CGContextRef ctx = UIGraphicsGetCurrentContext(); //translates context, copies doc page to the new pdf, translates back CGContextTranslateCTM(ctx, 0, pageSize.size.height); CGContextScaleCTM(ctx, 1.0, -1.0); CGPDFPageRef page = CGPDFDocumentGetPage (document, currentPage); CGContextDrawPDFPage (ctx, page); CGContextScaleCTM(ctx, 1.0, -1.0); CGContextTranslateCTM(ctx, 0, -pageSize.size.height); //custom drawing goes here if(currentPage == desiredPage) [imageFromView drawInRect:pageSize]; } UIGraphicsEndPDFContext(); </code></pre> <p>The problem here is that this procedure recreates the entire PDF, and for larger documents, this can take minutes to finish.</p> <p>I needed a solution that prints the UIView (that the user drew on) in a page of the PDF document, without having to recreate the whole document.</p> <p>Any links, tips and other useful information are very appreciated. Thanks in advance</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload