5
A
回答
3
你可以在以下網址的代碼。通過去........
http://ipdfdev.com/2011/04/22/convert-an-image-to-pdf-on-the-iphone-and-ipad/
1
真的是你的應用程序工作正常,但我需要.tif文件轉換爲PDF文件,並顯示UIWebView的。
+0
ANURAG能否讓我知道,如果找到任何解決方案:) – Mangesh 2013-05-11 07:24:51
-2
-(void)createPdf:(NSImage*)image
{
PDFDocument *pdf = [[PDFDocument alloc] init];
NSImage *image = [[NSImage alloc] initWithContentsOfFile:fileName];
PDFPage *page = [[PDFPage alloc] initWithImage:image];
[pdf insertPage:page atIndex: [pdf pageCount]];
[pdf writeToFile:path];
}
使用上面的方法如下:
NSImage *image = [[NSImage alloc] initWithContentsOfFile:PATH_OF_YOUR_PNG_FILE];
[self createPdf:image];
0
使用下面的代碼從圖像創建PDF文件。
UIImage* image = [UIImage imageNamed:@"sample.png"];
CGRect frame = CGRectMake(20, 100, 300, 60);
NSString* fileName = @"FileName.PDF";
NSArray *arrayPaths =
NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory,
NSUserDomainMask,
YES);
NSString *path = [arrayPaths objectAtIndex:0];
NSString* pdfFileName = [path stringByAppendingPathComponent:fileName];
// Create the PDF context using the default page size of 612 x 792.
UIGraphicsBeginPDFContextToFile(pdfFileName, CGRectZero, nil);
// Mark the beginning of a new page.
UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, 612, 792), nil);
[image drawInRect:frame];
// Close the PDF context and write the contents out.
UIGraphicsEndPDFContext();
相關問題
- 1. 如何以編程方式將PDF轉換爲iOS中的PNG
- 2. 如何使用我的C程序將PDF轉換爲圖像格式(jpeg,png,...)?
- 3. 將EPS/PDF轉換爲JPEG/PNG格式?
- 4. 將.png圖像轉換爲.gif圖像
- 5. 如何以編程方式將Word文件轉換爲PDF?
- 6. 如何將PDF轉換爲圖像?
- 7. 將PDF轉換爲圖像
- 8. 在Android中將圖像轉換爲PDF
- 9. 以編程方式將HTML頁面轉換爲圖像/ PDF的最佳Java庫
- 10. 如何到Base64 PNG圖像串爲PNG格式轉換成C#
- 11. 如何將rtf轉換爲圖像格式(jpg/png ..)
- 12. 如何將png圖像字符串數據轉換爲png?
- 13. 如何在Internet Explorer中將svg轉換爲png圖像?
- 14. pdfbox2.0.4將PDF轉換與中國爲PNG
- 15. 以編程方式將GIF轉換爲PNG
- 16. 無法在Codeigniter中將圖像轉換爲.png格式
- 17. 如何將base64 svg圖像轉換爲base64圖像png
- 18. 如何將base64_encode png圖像轉換爲簡單圖像
- 19. 如何將位圖圖像轉換爲Windows Phone 7中的png?
- 20. 如何以編程方式在iPhone中將圖像旋轉90度?
- 21. 如何將字符串轉換爲圖像格式編程
- 22. 以編程方式將kml轉換爲圖像
- 23. 將SVG轉換爲PNG圖像
- 24. 將PNG圖像轉換爲視頻
- 25. 嘗試將SVG轉換爲PNG圖像
- 26. 將PDF轉換爲php中的圖像
- 27. 如何PDF文件轉換成PNG(圖像)文件中的QT
- 28. 我如何將wav轉換爲wma編程方式在C++中?
- 29. 將閃存圖轉換爲圖像/ pdf
- 30. 在Android操作系統中將JPEG/PNG圖像轉換爲TIFF圖像格式
請參考這個 - http://stackoverflow.com/questions/1360912/how-can-i-create-a-pdf-file-programmatically-in-an-iphone-application你會findout! – 2011-01-27 12:51:14
你有一個.png文件的圖像,或者你有一組圖像將圖像轉換爲pdf? – 2013-11-21 07:59:40