Iphone 如何在ios6中创建多页PDF?

Iphone 如何在ios6中创建多页PDF?,iphone,objective-c,ios,ipad,Iphone,Objective C,Ios,Ipad,里面有生成多页PDF的代码,但我不明白该把代码放在哪里或实现在哪里 第一个答案:生成我在项目中已经完成的PDF 第二个答案:对于多个页面,我感到困惑。有谁能告诉我,我把这段代码放在哪里来生成包含多个页面的PDF吗?用于创建多个页面 定义NSInteger currentPage=0位于.m文件的顶部 并在generatePdfWithFilePath方法中写入 -(void) generatePdfWithFilePath: (NSString *)thefilePath { NSLog

里面有生成多页PDF的代码,但我不明白该把代码放在哪里或实现在哪里

第一个答案:生成我在项目中已经完成的PDF


第二个答案:对于多个页面,我感到困惑。有谁能告诉我,我把这段代码放在哪里来生成包含多个页面的PDF吗?

用于创建多个页面

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

如果你展示你的代码来创建一个单页PDF,那么我们可以告诉你如何修改多页。这可能有助于-@Jagdish你面临的问题是什么?你的do while()逻辑不起作用,现在我已经用另一种方式完成了(for循环)…你是否声明了
NSInteger currentPage=0