开发者

Monotouch embeding a pdf in app

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://


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://


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜