Create PDF software on iPhone?

Hey, everyone was wondering if anyone could point me in the right direction. I am wondering how I will create a software PDF file on the iPhone. The documentation mentions CGPDFDocumentCreateWithProvider, but I'm not sure how to use it. Thanks!

+3
source share
3 answers

Similarly, I do not find it possible to view PDF on iPhone without an external output output

This is not true. You can make a PDF document in an instance UIWebView, for example:

NSString *urlPathStr = [[NSBundle mainBundle] pathForResource:@"myPDFFile" ofType:@"pdf"];
NSURL *url = [NSURL fileURLWithPath:urlPathStr];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
[myWebView loadRequest:urlRequest];

You can also do PDF in the object UIViewfor better performance.

PDFKit is not yet available for iPhone.

QuartzDemo Quartz2D PDF-.

+2

CGPDFDocumentCreateWithProvider CGPDFDocumentCreateWithURL - , .

CGPDFDocumentCreateWithURL.it pdf- URL-, .

, URL- -, PDF .

pdf cgcontextRef.

+1

pdf iphone:

UIWebView < UIWebViewDelegate

  NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
  NSString *documentsPath = [paths objectAtIndex:0];
  NSString *filePath = [documentsPath stringByAppendingPathComponent:@"YourPDF.pdf"]; 
 if(![[NSFileManager defaultManager] fileExistsAtPath:filePath]){
           // download file , here "https://s3.amazonaws.com/hgjgj.pdf" = pdf downloading link
         NSData *pdfData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"https://s3.amazonaws.com/hgjgj.pdf"]];
            //Store the downloaded file  in documents directory as a NSData format
         [pdfData writeToFile:filePath atomically:YES];
    }

     NSURL *url = [NSURL fileURLWithPath:filePath];
     NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
     [yourWebView setUserInteractionEnabled:YES];
     [yourWebView setDelegate:self];
     yourWebView.scalesPageToFit = YES;
     [yourWebView loadRequest:requestObj];

, / pdf , :

     NSString*  filePath= [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"pdf"]];
    /// or you can even read docs file as : pathForResource:@"sample" ofType:@"docx"]
     NSURL *url = [NSURL fileURLWithPath:filePath];
     NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
     [yourWebView setUserInteractionEnabled:YES];
     [yourWebView setDelegate:self];
     yourWebView.scalesPageToFit = YES;
     [yourWebView loadRequest:requestObj];

Or if you want to create your own pdf file from a bunch of text and lines, here is how I did it: http://iosameer.blogspot.com/2012/09/creating-pdf-file-from-simple.html

0
source

Source: https://habr.com/ru/post/1716249/


All Articles