如何在ios6中创建多页PDF? [英] How to create a multiple page PDF in ios6?

查看:269
本文介绍了如何在ios6中创建多页PDF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以编程方式创建pdf的示例代码有用于生成包含多个页面的PDF的代码,但我无法理解我必须放置或实现该代码的位置。

In "Sample code to create pdf programmatically" there is code for generating a PDF with multiple pages, but I can't understand where I have to put or implement that code .

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

First answer: generate PDF that I've already done in my project.

第二回答:对于多页,我很困惑。谁能告诉我在哪里放这个代码来生成一个包含多个页面的PDF?

Second Answer: for multiple page in that I am confuse. Can anyone tell me where I put this code to generate a PDF with multiple pages?

推荐答案

用于创建多个页面

在.m文件的顶部定义 NSInteger currentPage = 0;

Define NSInteger currentPage = 0; at the top in .m file

和generatePdfWithFilePath方法写

and in generatePdfWithFilePath method write

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

这篇关于如何在ios6中创建多页PDF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆