2011-02-01 12 views
1

次のコードでPDFを生成できます。誰かが私にこのテキストを追加する方法を教えてくれますか?前もって感謝します。iPadからの書き込み

-(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); 
} 

答えて

1

私は決してこれをやっていない(まだ、私は明日それに乗る予定です)。しかし、適切な場所はQuartz 2D programming guideだと思います。オフラインにする必要がある場合は、デベロッパーのドキュメントから入手することもできます。

投稿したのと同じですが、drawRectを呼び出すことでappartします。そのコンテキストで必要なすべてのテキスト描画を実行します。

私はそれが役に立てば幸いthis guide

に単純な文字列の記述に関する有用な情報があります。それは確かに私を助けた!

+0

ありがとうございました。その記事はとても役に立ちます。なぜ私がそれを見たことがないのか分からない。 – intomo

関連する問題