gpt4 book ai didi

iphone - 是否可以在 iphone 中以编程方式将多个 pdf 文件组合成一个 pdf 文件?

转载 作者:可可西里 更新时间:2023-11-01 03:08:20 24 4
gpt4 key购买 nike

是否可以在 iphone 中以编程方式将多个 pdf 文件合并到一个 pdf 文件中。我已经从程序的不同部分创建了单独的页面,现在需要将它们合并到一个文件中

最佳答案

是的,你可以做到。请按照以下代码

//Open a pdf context for the single file
UIGraphicsBeginPDFContextToFile(oldFile, paperSize, nil);

//Run a loop to the number of pages you want
for (pageNumber = 1; pageNumber <= count; pageNumber++)
{
//Open a pdf page context
UIGraphicsBeginPDFPageWithInfo(paperSize, nil);

//Get graphics context to draw the page
CGContextRef currentContext = UIGraphicsGetCurrentContext();

//Flip and scale context to draw the pdf correctly
CGContextTranslateCTM(currentContext, 0, paperSize.size.height);
CGContextScaleCTM(currentContext, 1.0, -1.0);

//Get document access of the pdf from which you want a page
CGPDFDocumentRef newDocument = CGPDFDocumentCreateWithURL ((CFURLRef) newUrl);

//Get the page you want
CGPDFPageRef newPage = CGPDFDocumentGetPage (newDocument, pageNumber);

//Drawing the page
CGContextDrawPDFPage (currentContext, newPage);

//Clean up
newPage = nil;
CGPDFDocumentRelease(newDocument);
newDocument = nil;
newUrl = nil;

}

UIGraphicsEndPDFContext();

所以你必须在绘制页面之前写下从适当的pdf中获取适当页面的必要条件。您已经从多个来源创建了一个 pdf!

关于iphone - 是否可以在 iphone 中以编程方式将多个 pdf 文件组合成一个 pdf 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9646203/

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