gpt4 book ai didi

iphone - 如何在 ios6 中创建多页 PDF?

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:17:25 26 4
gpt4 key购买 nike

"Sample code to create pdf programmatically"有用于生成多页 PDF 的代码,但我不明白我必须在哪里放置或实现该代码。

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

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

最佳答案

用于创建多个页面

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

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

关于iphone - 如何在 ios6 中创建多页 PDF?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13775124/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com