0
我試圖從UIView創建一個PDF並且效果很好,如「How to Convert UIView to PDF within iOS?」所做的那樣。
但我的iPad是風景,是一種形式,冗長的形式,身高3K。
當我轉換爲PDF時,它只轉換iPad的高度,即748而不是我需要的3k的大小。在iOS 5.1中創建UIView的PDF格局不起作用
出了什麼問題? iOS版本?
編輯:繼承人像@wain代碼問
-(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, aView.bounds, nil);
UIGraphicsBeginPDFPage();
// draws rect to the view and thus this is captured by UIGraphicsBeginPDFContextToData
[aView drawRect:aView.bounds];
// 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);
}
顯示您正在使用的代碼。 – Wain
是的,一分鐘 –