Monotouch 在应用程序中嵌入 pdf

发布于 2024-09-04 22:21:35 字数 90 浏览 2 评论 0原文

如何在我的应用程序中嵌入 pdf?我应该将 pdf 文件 url 传递到 Web 视图并让它处理它,还是有更好的方法/

干杯

w://

How can I emded a pdf inside my app? Should i just pass the pdfs file url to a web view and let that take care of it or is there a better way/

Cheers

w://

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

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

发布评论

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

评论(2

风情万种。 2024-09-11 22:21:35

窥探之后我发现了这一点:

CGContext context = UIGraphics.GetCurrentContext();

context.SaveState();

CGPDFDocument pdfDoc = CGPDFDocument.FromUrl(_pdfFileUrl);
if(pdfDoc.Pages >= 1)
{
    CGPDFPage pdfPage = pdfDoc.GetPage(1);  

    context.ScaleCTM(SCALE.Width, SCALE.Height);
    // the PDFRectangle is the media box rect of the page, which is hardcoded
    // for now
    context.TranslateCTM(-this.PDFRectangle.X, -this.PDFRectangle.Height - this.PDFRectangle.Y);

    context.DrawPDFPage(pdfPage);
}

pdfDoc.Dispose();

context.RestoreState();

从这里:

MonoTouch CoreGraphics PDF内存issues with CGPDFDocument and CGPDFPage

这是一个关于内存泄漏的问题,但在这个过程中回答了我的问题。

w://

after snooping about I found this:

CGContext context = UIGraphics.GetCurrentContext();

context.SaveState();

CGPDFDocument pdfDoc = CGPDFDocument.FromUrl(_pdfFileUrl);
if(pdfDoc.Pages >= 1)
{
    CGPDFPage pdfPage = pdfDoc.GetPage(1);  

    context.ScaleCTM(SCALE.Width, SCALE.Height);
    // the PDFRectangle is the media box rect of the page, which is hardcoded
    // for now
    context.TranslateCTM(-this.PDFRectangle.X, -this.PDFRectangle.Height - this.PDFRectangle.Y);

    context.DrawPDFPage(pdfPage);
}

pdfDoc.Dispose();

context.RestoreState();

from here:

MonoTouch CoreGraphics PDF memory issues with CGPDFDocument and CGPDFPage

Which was a question about memory leakage but answered my q in the process.

w://

故事与诗 2024-09-11 22:21:35

您可能想看看 UIDocumentInteractionController,它允许查看各种文件格式。

You might want to have a look at UIDocumentInteractionController which allows viewing all kinds of file formats.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文