在我的應用程序中,用戶可以將一些信息添加到他的列表中,最後他想通過電子郵件將該列表發送給其他人。我只是想知道如何導出該列表?將它導出爲pdf或txt文件可以嗎?!導出文本或pdf
Q
導出文本或pdf
0
A
回答
1
好,我用這個代碼,不幸的是我失去了我找到了答案約不引用它很抱歉的頁面。這是魔碼:
-(void)createPDFfromUIView:(UIView*)aView saveToDocumentsWithFileName:(NSString*)aFilename
{
// Creates a mutable data object for updating with binary data, like a byte array
NSMutableData *pdfData = [NSMutableData data];
// Points the pdf converter to the mutable data object and to the UIView to be converted
UIGraphicsBeginPDFContextToData(pdfData, mainView.bounds, nil);
UIGraphicsBeginPDFPage();
CGContextRef pdfContext = UIGraphicsGetCurrentContext();
// draws rect to the view and thus this is captured by UIGraphicsBeginPDFContextToData
[mainView.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:aFilename];
// instructs the mutable data object to write its context to a file on disk
[pdfData writeToFile:documentDirectoryFilename atomically:YES];
// NSLog(@"documentDirectoryFileName: %@",documentDirectoryFilename);
}
1
如果您要搜索iOS5,請檢查this Link。
http://www.raywenderlich.com/6581/how-to-create-a-pdf-with-quartz-2d-in-ios-5-tutorial-part-1
編輯:使用UI
elements
這樣的:
[yourView.layer renderInContext:UIGraphicsGetCurrentContext()]
相關問題
- 1. spark-highcharts導出到文件(PNG或pdf)
- 2. 導出爲PDF到本地文件夾
- 3. 導出爲PDF文件
- 4. 用Java導出PDF文件
- 5. Illustrator腳本大量PDF導出出血
- 6. Asp.Net - 導出兩個GridQuery的excel或pdf
- 7. 將HTML表單導出爲.PDF或.DOC
- 8. 將Sqlite數據導出爲PDF或Excel
- 9. 劍道圖導出爲pdf或png
- 10. MOSS 2007 Wiki導出到MS Word或PDF
- 11. SmartGWT pdf導出
- 12. 導出爲PDF
- 13. 在文本框中按下文本的「輸入」不會出現在PDF導出
- 14. 用pdf導出HTML用pdf
- 15. 如何使用iText將越南文文本導出爲PDF
- 16. 用CSS將HTML導出爲PDF腳本
- 17. 谷歌腳本導出後打開PDF
- 18. 將php數據導出爲pdf版本
- 19. 如何將listbox或datagridview導出爲pdf文件?
- 20. 導出文件excel或pdf所需頁面標題
- 21. GWT:將CellTable導出爲圖像或pdf文件
- 22. pdf導出在導軌
- 23. 將Python輸出導出爲CSV或文本文件(初學者)
- 24. OpenOffice PDF導出庫
- 25. Richfaces DataTable PDF導出
- 26. DataList to PDF導出
- 27. DXChart WPF導出PDF
- 28. PDF導出問題
- 29. Vaadin導出爲pdf
- 30. KendoUI導出爲PDF
感謝思巴,我前紅認爲,教程,我只是想知道,而不是NSString的,如果它可以使用,我已經在我的廈門國際銀行文件創建當前的UILabel或UIView的,* textToDraw = @「Hello World」 – Rudi
http://stackoverflow.com/questions/9554670/how-to-export-uiview-to-pdf-file這可能會幫助你。 –