'''' This code is part of Document Solutions for PDF .NET demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.IOImportsSystem.DrawingImportsGrapeCity.Documents.PdfImportsGrapeCity.Documents.Pdf.Annotations '' This sample shows how to use the Page.AdjustCoordinates() method'' to convert visual coordinates (measured from the top left corner'' of the page according to DsPdf rules) to correct coordinates in a PDF'' that was loaded into GcPdfDocument And may have arbitrary unknown '' transformations applied to its pages. The adjusted coordinates can be'' used to position annotations (redact in this case) etc.'''' The PDF used in this sample has one page containing the scan of a sample invoice'' that was rotated 90 degrees clockwise. The PDF page Is rotated 270 degrees to'' compensate (so that visually the page has correct portrait orientation).PublicClassAdjustCoordsFunctionCreatePDF(ByVal stream AsStream) AsIntegerDim doc = NewGcPdfDocument()Using fs = File.OpenRead(Path.Combine("Resources", "PDFs", "invoice-scan-rot270.pdf")) doc.Load(fs) If doc.Pages.Count <> 1ThenThrowNew Exception("Unexpected: sample invoice should have exactly one page.")EndIf Dim page = doc.Pages(0) '' The bounding rectangle of the area to redact,'' measured from the top left corner of the PDF page.'' If this rectangle Is used as Is, it will miss the target content:Dim rectToRedact = NewRectangleF(20, 170, 200, 40) '' The adjusted bounding rectangle, taking into consideration'' any possible page transformations (rotation in this case):Dim adjusted = page.AdjustCoordinates(rectToRedact) '' Note If 'rectToRedact' is used instead of 'adjusted','' the redact will miss the target (customer name/address):Dim redact = NewRedactAnnotation() With { .Rect = adjusted, .OverlayFillColor = Color.Orange, .OverlayText = "Redacted", .page = page }'' Apply the redact: doc.Redact(redact) '' Done doc.Save(stream)Return doc.Pages.CountEndUsingEndFunctionEndClass