user156888
user156888

Reputation:

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

Upvotes: 1

Views: 1357

Answers (2)

Krumelur
Krumelur

Reputation: 33048

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

Upvotes: 0

user156888
user156888

Reputation:

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

Upvotes: 1

Related Questions