gpt4 book ai didi

ios - 在 iOS 中实现交互式 pdf

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

我必须将时间表文件加载到 ipad 应用程序中,该文件为 pdf 或 xls 格式。加载这些文件(xls/pdf)后,我需要编辑时间表文件中的值并保存。我可以在 UIWebView 中加载这些文件,但我无法编辑这些文件。我需要知道,如何使这些文件 (xls/pdf) 可编辑?另一个问题是我需要将 pdf 文件转换为 xls 格式,并将 xls 文件从 ipad 应用程序内部转换为 pdf 格式。我希望这很清楚。

最佳答案

如果你想支持编辑,你应该使用 Quartz API 读取 PDF 文件并在你自己的 View 中呈现它。请参阅以下链接

Is it possible to combine multiple pdf files into a single pdf file programmatically in iphone?

PDF editing with iPhone sdk

http://www.iphonedevsdk.com/forum/iphone-sdk-tutorials/10989-pdf-creation-tutorial.html

这个想法是,如果您只想编辑文本,请使用 quartz 2D API 读取和绘制 pdf 文件,在可编辑文本元素中显示 pdf 中的所有文本对象,让用户更改并在保存时创建/替换原始 pdf 中的文本对象使用 Quartz 2D。

我得到这段代码来在 pdf 文件中绘制一个文本字符串

// Create URL for PDF file
NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *filename = @"test.pdf";
NSURL *fileURL = [NSURL fileURLWithPathComponents:[NSArray arrayWithObjects:documentsDirectory, filename, nil]];

// Create PDF context
CGContextRef pdfContext = CGPDFContextCreateWithURL((CFURLRef)fileURL, NULL, NULL);
CGPDFContextBeginPage(pdfContext, NULL);
UIGraphicsPushContext(pdfContext);

// Flip coordinate system
CGRect bounds = CGContextGetClipBoundingBox(pdfContext);
CGContextScaleCTM(pdfContext, 1.0, -1.0);
CGContextTranslateCTM(pdfContext, 0.0, -bounds.size.height);

// Drawing commands
[@"Hello World!" drawAtPoint:CGPointMake(100, 100) withFont:[UIFont boldSystemFontOfSize:72.0f]];

// Clean up
UIGraphicsPopContext();
CGPDFContextEndPage(pdfContext);
CGPDFContextClose(pdfContext);

关于ios - 在 iOS 中实现交互式 pdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9953792/

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