gpt4 book ai didi

iphone - 在 iOS 上生成 PDF 时定位元素

转载 作者:行者123 更新时间:2023-11-28 17:44:59 24 4
gpt4 key购买 nike

我正在我的 ipad 应用程序中生成 PDF,我需要添加分页符,因此我还需要在呈现第二页之前移动元素。例如,在呈现第二页、第三页等之前,我的长表格 View 需要垂直调整...

创建 PDF 非常简单,我已经完成了该部分,并且第一页生成完美,但是当我尝试设置我的框架以移动我的下一页的表格 View 时,没有任何反应:

    -(void) createPDF {

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"tmp.pdf"];

CGContextRef pdfContext = [self createPDFContext:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height) path:(CFStringRef)writableDBPath];

NSLog(@"PDF Context created");
CGContextBeginPage (pdfContext,nil); // 6

//turn PDF upsidedown
CGAffineTransform transform = CGAffineTransformIdentity;
transform = CGAffineTransformMakeTranslation(0, self.view.bounds.size.height);
transform = CGAffineTransformScale(transform, 1.0, -1.0);
CGContextConcatCTM(pdfContext, transform);

//Draw view into PDF
self.view.frame=CGRectMake(0, 0,self.view.bounds.size.width, self.view.bounds.size.height);
[self.view.layer renderInContext:pdfContext];

CGContextEndPage (pdfContext);// 8

CGContextBeginPage (pdfContext,nil);

//turn PDF upsidedown
CGContextConcatCTM(pdfContext, transform);

// moving the table to an arbitrary position for testing, nothing happens in the PDF - view itself is updated
self.itemsTableView.frame = CGRectMake(100, 100, self.view.bounds.size.width, self.view.bounds.size.height);
[self.itemsTableView.layer renderInContext:pdfContext];

CGContextEndPage (pdfContext);// 8

CGContextRelease (pdfContext);
}

最佳答案

如果您的应用可以选择使用云服务创建 PDF,请查看 Docmosis . PDF 基于文档模板,因此您无需在代码中计算即可控制分页符等。您的应用必须发送请求和数据来填充文档并交付 PDF,因此它依赖于连接。

关于iphone - 在 iOS 上生成 PDF 时定位元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6493885/

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