I am trying to display a CGPDFPage (selected from CGPDFDocument) in a UIImage for display in a view.
I have the following code in MonoTouch that gives me part of the way.
RectangleF PDFRectangle = new RectangleF(0, 0, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height); public override void ViewDidLoad () { UIGraphics.BeginImageContext(new SizeF(PDFRectangle.Width, PDFRectangle.Height)); CGContext context = UIGraphics.GetCurrentContext(); context.SaveState(); CGPDFDocument pdfDoc = CGPDFDocument.FromFile("test.pdf"); CGPDFPage pdfPage = pdfDoc.GetPage(1); context.DrawPDFPage(pdfPage); UIImage testImage = UIGraphics.GetImageFromCurrentImageContext(); pdfDoc.Dispose(); context.RestoreState(); UIImageView imageView = new UIImageView(testImage); UIGraphics.EndImageContext(); View.AddSubview(imageView); }
The CGPDFPage section is displayed, but rotated back and forth. My question is: how do I select the full pdf page and turn it around to display it correctly. I saw several examples of using ScaleCTM and TranslateCTM, but could not get them to work.
Any examples in ObjectiveC are fine, I will take all the help I can get :)
thanks
James antrobus
source share