创建 iPad 屏幕视图的 1 页 PDF - 如何?

发布于 2024-08-28 05:05:16 字数 567 浏览 4 评论 0原文

我在其他几个论坛上问过这个问题,但回复为零,所以我希望这里有人能帮助我指出正确的方向。我的工作有一个非常简单的单屏应用程序。它基本上只是一页纸质报告的重新创建,其中包含公司徽标、一些标签、一些文本框和报告的滚动文本框。

我需要能够填写报告,然后单击按钮以图形形式保存,以便稍后可以传真、打印或通过电子邮件发送。目前,我只是以编程方式进行屏幕捕获并将其保存到照片库(屏幕捕获的默认值)。然后我就可以从照片中通过电子邮件发送它。这工作正常,但充其量只是有点hacky。

我已经通读了新的 iPad 3.2 创建 PDF 指南(显然它应该比以前容易得多),但我无法让它工作,而且我现在已经在它上面花费了无数的时间。我希望有人能给我答案。

或者,如果有人知道我如何重定向屏幕捕获的存储位置(默认位于相册中),那么也许我可以使该功能发挥作用。如果我可以重定向屏幕捕获以存储在我的应用程序文档文件夹中,那么我可以使用 MFMailCompose 将其附加到电子邮件中。

最后,顺便说一句,有人知道通过触摸捕获数字签名的好方法吗?例如,我希望我的用户能够在我转换为 PDF 或进行屏幕截图之前通过触摸文档底部来签署他们的名字。

预先感谢您的帮助。 -射线

I've asked this question on a couple other forums and have had zero response, so I'm hoping someone here can help point me in the right direction. I have a pretty simple one screen application for my work. It's basically just a recreation of a 1 page paper report that has a company logo, some labels, a few text boxes and a scroll text box for the report.

I need to be able to fill out the report then click a button to save it in a graphical form so I can fax, print or email it later. Currently, I'm just programmatically taking a screen capture and saving it to the photo's library (default for screen capture). Then I can just email it from photo's. This works ok, but is kind of hacky, at best.

I've read through the new iPad 3.2 guide for creating PDF's (apparently it's supposed to be much easier than before) but I can not get it to work and I've spent countless hours on it now. I'm hoping someone has the answer for me.

Alternatively, if anyone knows how I can redirect where the screen capture is stored (default is in the photo album) then maybe I can make that function work. If I could redirect the screen capture to store in my applications document folder, then I can use MFMailCompose to attach it to an email.

Lastly, on a side note, does anyone know of a good way to capture a digital signature via touch. For instance, I'd love to have my users be able to just sign their name via touch at the bottom of the document before I convert to PDF or take a screen capture.

Thanks in advance for your help.
-Ray

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

放飞的风筝 2024-09-04 05:05:16

我正在使用以下代码片段。它适用于单页 PDF 生成
它使用您拥有内容的任何视图,并将其捕获为 PDF 文件并存储到文档目录中。

在某些功能上

{
 ....
    // here container view is my content to be converted to PDF file
    // filepath is the path to where it should be write in our documents directory
    CGContextRef pdfContext = [self createPDFContext:containerView.bounds path:(CFStringRef)filePath];  
    NSLog(@"PDF Context created");
    CGContextBeginPage (pdfContext,nil); // 6

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

    //Draw view into PDF
    [containerView.layer renderInContext:pdfContext];   
    CGContextEndPage (pdfContext);// 8  
    CGContextRelease (pdfContext);

 ....
}

- (CGContextRef) createPDFContext:(CGRect)inMediaBox path:(CFStringRef) path    
{   
    CGContextRef myOutContext = NULL;   
    CFURLRef url;   
    url = CFURLCreateWithFileSystemPath (NULL, // 1                                      
                                         path,                                       
                                         kCFURLPOSIXPathStyle,                                       
                                         false);

    if (url != NULL) {      
        myOutContext = CGPDFContextCreateWithURL (url,// 2                                                
                                                  &inMediaBox,                                                
                                                  NULL);        
        CFRelease(url);// 3     
    }   
    return myOutContext;// 4    
}

I am using the following snippet. it works fine with single page PDF generation.
It uses any View where you have content and capture it as a PDF file and stores into the document directory.

on some function

{
 ....
    // here container view is my content to be converted to PDF file
    // filepath is the path to where it should be write in our documents directory
    CGContextRef pdfContext = [self createPDFContext:containerView.bounds path:(CFStringRef)filePath];  
    NSLog(@"PDF Context created");
    CGContextBeginPage (pdfContext,nil); // 6

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

    //Draw view into PDF
    [containerView.layer renderInContext:pdfContext];   
    CGContextEndPage (pdfContext);// 8  
    CGContextRelease (pdfContext);

 ....
}

- (CGContextRef) createPDFContext:(CGRect)inMediaBox path:(CFStringRef) path    
{   
    CGContextRef myOutContext = NULL;   
    CFURLRef url;   
    url = CFURLCreateWithFileSystemPath (NULL, // 1                                      
                                         path,                                       
                                         kCFURLPOSIXPathStyle,                                       
                                         false);

    if (url != NULL) {      
        myOutContext = CGPDFContextCreateWithURL (url,// 2                                                
                                                  &inMediaBox,                                                
                                                  NULL);        
        CFRelease(url);// 3     
    }   
    return myOutContext;// 4    
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文