Monotouch在应用程序中嵌入pdf

时间:2010-06-07 08:12:43

标签: pdf xamarin.ios

如何在我的应用中嵌入pdf?我应该将pdf文件网址传递给网络视图并让它处理它还是有更好的方法/

干杯

瓦特://

2 个答案:

答案 0 :(得分:1)

在窥探后我发现了这个:

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 memory issues with CGPDFDocument and CGPDFPage

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

瓦特://

答案 1 :(得分:0)

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