我有问题,是否可以将PDF保存到相机胶卷?我的意思是,我知道如何保存图片,但是您是否也可以保存PDF?Xcode将PDF保存为图像?
回答
如果你试图间接地做到这一点,有些人试图它,你不能查看。 https://discussions.apple.com/thread/2479252
相机胶卷是照片。 iBooks适用于PDF。
不,这是不可能的。 Apple仅允许照片和视频存储在照片库中。 PDF格式的文件可以存储在iBook笔记本,或者可以处理PDF格式的,但在照片库不能接受其他程序PDF的
您可以将PDF转换成一组图像,并且将其导入卷。您无法将实际的PDF添加到卷筒中。
正如@ jshin47 - 下面的代码片段将让你去:
把它转换为PDF叫坐在检验.pdf在本地文件目录为PNG叫test.png。我已经使用A4尺寸的PDF,但如果你不在英国/欧洲,你可能需要美国的字母大小。
NSString* localDocuments = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES) objectAtIndex:0];
NSString* pdfPath = [localDocuments stringByAppendingPathComponent:@"test.pdf"];
// create a sample PDF (just for illustration)
UIGraphicsBeginPDFContextToFile(pdfPath, CGRectZero, nil);
UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, 612, 792), nil);
[@"Test string" drawInRect:CGRectMake(50, 50, 300, 200) withFont: [UIFont systemFontOfSize: 48.0]];
UIGraphicsEndPDFContext();
NSURL* url = [NSURL fileURLWithPath: pdfPath];
CGPDFDocumentRef document = CGPDFDocumentCreateWithURL ((CFURLRef) url);
UIGraphicsBeginImageContext(CGSizeMake(596,842));
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(currentContext, 0, 842);
CGContextScaleCTM(currentContext, 1.0, -1.0); // make sure the page is the right way up
CGPDFPageRef page = CGPDFDocumentGetPage (document, 1); // first page of PDF is page 1 (not zero)
CGContextDrawPDFPage (currentContext, page); // draws the page in the graphics context
UIImage* image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSString* imagePath = [localDocuments stringByAppendingPathComponent: @"test.png"];
[UIImagePNGRepresentation(image) writeToFile: imagePath atomically:YES];
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil); // do error checking in production code
谢谢!它似乎在工作,但图片只是白色..? – user1110365 2012-03-22 21:11:33
很可能它无法在文档文件夹中找到名为'test.pdf'的有效PDF。如果url为零 - 如果它找不到该文件,则说明 - 那么它只会生成一个空白的PNG。我添加了四行来创建PDF并将其保存在文档文件夹中。如果这样会生成一个图像OK,那么问题很可能是url不是有效PDF文件的URL。 – Obliquely 2012-03-22 22:20:15
一个问题:这工作完美:)但如何使用UIWebview(UIwebview.request.URL.absoluteString)而不是从文档文件夹的PDF? – Nils 2013-11-21 09:39:17
- 1. 将图像保存为PDF共享点
- 2. 如何将图像保存为图像/ pdf?
- 3. 将闪存图转换为图像/ pdf
- 4. 将WebView保存为PDF将返回空白图像?
- 5. 如何将Extjs4图表图像保存为PDF报告?
- 6. 如何将图表从Excel保存为图像/ PDF?
- 7. 将Qwtplot保存为图像
- 8. 将图像保存为Tiff
- 9. 将流保存为图像
- 10. 如何将图像保存为图像
- 11. 将ASP.NET图表保存为PDF
- 12. Applescript Adobe Acrobat Pro将图像保存为PDF
- 13. 将MvcHtmlString转换并保存为图像或PDF
- 14. CakePHP控制器将图像保存为PDF
- 15. 将PDF保存为文件
- 16. 将Open XML保存为PDF
- 17. 将报告保存为pdf
- 18. Xcode将图像保存为特定形状
- 19. 将PDF DataUri保存为pdf with jsPDF
- 20. 将图像保存为存储文件
- 21. 将jqPlot图保存为图像文件
- 22. 将phpgraphlib图保存为图像
- 23. 将图保存为rCharts中的图像
- 24. 将flot图保存为图像
- 25. 将Xamarin.Forms.VisualElement保存为位图图像
- 26. 将图像导出为PDF
- 27. 将PDF转换为图像
- 28. 在db4o中保存图像或pdf
- 29. 使用PDFLibNet保存PDF页面图像
- 30. 我们可以将pdf上的内容保存为新的pdf吗? Xcode的
所以我怎么可以将PDF转换为图像? – 2015-03-08 15:20:58