Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 在ios中生成PDF文件_Iphone - Fatal编程技术网

Iphone 在ios中生成PDF文件

Iphone 在ios中生成PDF文件,iphone,Iphone,嗨,在我的应用程序中,我必须生成PDF文件。该pdf文件可能包括图像、说明、数字、边框线和页码。请告诉我如何在ios中生成pdf文件 创建自定义视图以添加图像、tableview或任何内容。将pdf转换器指向可变数据对象和要转换为pdf的UIView 试试这个: NSMutableData *pdfData = [NSMutableData data]; UIGraphicsBeginPDFContextToData(pdfData,self.bounds, nil); UIGr

嗨,在我的应用程序中,我必须生成PDF文件。该pdf文件可能包括图像、说明、数字、边框线和页码。请告诉我如何在ios中生成pdf文件


创建自定义视图以添加图像、tableview或任何内容。将pdf转换器指向可变数据对象和要转换为pdf的UIView

试试这个:

NSMutableData *pdfData = [NSMutableData data];
    UIGraphicsBeginPDFContextToData(pdfData,self.bounds, nil);
    UIGraphicsBeginPDFPage();

    CGContextRef pdfContext = UIGraphicsGetCurrentContext();

    // draws rect to the view and thus this is captured by UIGraphicsBeginPDFContextToData
    [self.layer renderInContext:pdfContext];

    // remove PDF rendering context
    UIGraphicsEndPDFContext();

    // Retrieves the document directories from the iOS device
    NSArray* documentDirectories = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);

    NSString* documentDirectory = [documentDirectories objectAtIndex:0];
    NSString* documentDirectoryFilename = [documentDirectory stringByAppendingPathComponent:@"ess.pdf"];

    // instructs the mutable data object to write its context to a file on disk
    [pdfData writeToFile:documentDirectoryFilename atomically:YES];

参考我已经找到的这个链接,我可能知道你有任何可用的实例代码。嗨,谢谢,我试过了。但在这里我有一个疑问,在这种情况下,如果(stringSize.height>=renderingRect.size.height),我们如何将文本拆分为两页?请分享这个代码。pageSize=CGSizeMake(612792);更改并尝试knowHi谢谢您的回复。事实上,我在将文本分成两页时遇到了一个问题。我不知道如何把这篇文章分成两页。我通过获取文本大小和底线位置来设置底线。我正在附上屏幕截图,请检查此截图并告知解决方案。您好,ios开发人员,请检查附件并帮助我解决问题。@ios开发人员链接不起作用,请更新。。。