2

プログラムでPDFを作成するサンプルコード」に複数ページのPDFを生成するコードがあるのですが、どこにそのコードを入れたり実装したりすればいいのかわかりません。

最初の答え: プロジェクトで既に行った PDF を生成します。

2 番目の回答: 複数のページがあるので混乱します。このコードをどこに置いて複数ページの PDF を生成するか教えてもらえますか?

4

1 に答える 1

2

複数のページを作成する場合

NSInteger currentPage = 0;を定義します。.m ファイルの先頭

そして、generatePdfWithFilePath メソッドで書き込みます

-(void) generatePdfWithFilePath: (NSString *)thefilePath
{
    NSLog(@"\n==========\n \t the file path==  %@",thefilePath);

    UIGraphicsBeginPDFContextToFile(thefilePath, CGRectZero, nil);

    do
    {        
           currentPage++;

           if(currentPage == 1) 
              pageSize= CGSizeMake(612,2350);
           else
              pageSize = CGSizeMake(612, 2000);

           [self drawBorder];

           //Draw text fo our header.
           [self drawHeader];

           //Draw a line below the header.
           [self drawLine];

           //Draw some text for the page.
           [self drawText];

           //Draw an image
           [self drawImage];

    }while (currentPage !=2); //You can write required page number here

    currentPage=0;

    UIGraphicsEndPDFContext();
}
于 2013-03-15T05:38:57.340 に答える