CGContext.DrawPDFPage(CGPDFPage) Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Esegue il rendering del file PDF page
specificato.
public void DrawPDFPage (CoreGraphics.CGPDFPage page);
member this.DrawPDFPage : CoreGraphics.CGPDFPage -> unit
Parametri
- page
- CGPDFPage
Pagina PDF di cui eseguire il rendering.
Commenti
Nell'esempio seguente viene illustrato come eseguire il rendering della prima pagina di un file PDF:
doc = CGPDFDocument.FromFile (Path.Combine (NSBundle.MainBundle.BundlePath, "Images/QuartzImageDrawing.pdf"));
if (doc == null)
throw new Exception ("Could not load document");
using (var ctxt = UIGraphics.GetCurrentContext ()) {
// PDF page drawing expects a Lower-Left coordinate system, so we flip the coordinate system
// before we start drawing.
context.TranslateCTM (0, Bounds.Height);
context.ScaleCTM (1, -1);
// Grab the first PDF page
using (CGPDFPage page = doc.GetPage (1)){
// We're about to modify the context CTM to draw the PDF page where we want it, so save the graphics state in case we want to do more drawing
context.SaveState ();
// CGPDFPageGetDrawingTransform provides an easy way to get the transform for a PDF page. It will scale down to fit, including any
// base rotations necessary to display the PDF page correctly.
CGAffineTransform pdfTransform = page.GetDrawingTransform (CGPDFBox.Crop, Bounds, 0, true);
// And apply the transform.
context.ConcatCTM (pdfTransform);
// Finally, we draw the page and restore the graphics state for further manipulations!
context.DrawPDFPage (page);
context.RestoreState();
}
}