長いhtmlページがあり、それを複数ページのPDFファイルに変換する必要がありました。iOS - HTMLコンテンツから複数ページのPDFを作成する
私は appleとhere - how to make multi page PDFに記載されている指示に従っています。
しかし、NSString(いくつかのデータのようなもの)のフォーマットはhtmlページの作成よりも難しいです。私はこのhtmlを作成し、それをUIWebViewに表示しています。
このHTMLのPDFをマルチページ PDFファイルに作成します。
私が使用しているコードでは、単一のPDFを作成できます。
- (void)createPDFfromUIView:(UIWebView *)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(); CGContextRef pdfContext = UIGraphicsGetCurrentContext(); // draws rect to the view and thus this is captured by UIGraphicsBeginPDFContextToData [aView.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); }
助けてもらえますか?
あなたは男です。私はちょうど私が探していたサンプルアプリケーションとそのすべてを見てきました。しかし、私の要求は変わり、何かをしました。しかし、これは素晴らしいです。私はこれを将来使用するかもしれない。努力と特別なことを説明してくれてありがとう。 – Viraj
このフレームワークの問題は、テキストボックスなどのデータをキャプチャしないことです。彼らはすべて空白になります。 – GuybrushThreepwood
素晴らしいです!素晴らしい男 !!! – Rudi