If you set page.Rotate = Rotation.None;
the point (0,0) will be in the left bottom corner.
Unfortunately, we don’t have a simple tool (class or method) for detecting in which coordinates some particular object will be placed on an image.
Therefore, we can recommend using another approach - mark the desired object in PDF and then render a JPEG image.
Below, you can see an example of how to use annotations to mark some text.
You can also see two arrows indicating the point 0,0 and direction.
Please let us know if you find this helpful.
We see some wrong text detection and will create a task after your response.
//var license = new License();
// license.SetLicense(licensePath);
int dpi = 72; // Standard DPI value
Resolution resolution = new(dpi);
var filePathPdf = "00-90-0000-28-107.pdf";
var document = new Document(filePathPdf);
JpegDevice jpegDevice = new(resolution);
jpegDevice.RenderingOptions.InterpolationHighQuality = true;
var page = document.Pages[1];
page.Rotate = Rotation.None;
var xAxis = new LineAnnotation(page,
new Aspose.Pdf.Rectangle(0, 0, 100, 5),
new Aspose.Pdf.Point(3, 3),
new Aspose.Pdf.Point(95, 3))
{
Title = "Aspose.PDF",
Color = Aspose.Pdf.Color.Red,
Width = 3,
EndingStyle = LineEnding.OpenArrow,
Popup = new PopupAnnotation(document.Pages[1], new Aspose.Pdf.Rectangle(842, 124, 1021, 266))
};
page.Annotations.Add(xAxis);
var yAxis = new LineAnnotation(page,
new Aspose.Pdf.Rectangle(0, 0, 5, 100),
new Aspose.Pdf.Point(3, 3),
new Aspose.Pdf.Point(3, 95))
{
Title = "Aspose.PDF",
Color = Aspose.Pdf.Color.Blue,
Width = 3,
EndingStyle = LineEnding.OpenArrow,
Popup = new PopupAnnotation(document.Pages[1], new Aspose.Pdf.Rectangle(80, 10, 100, 200))
};
page.Annotations.Add(yAxis);
var textFragmentAbsorber = new TextFragmentAbsorber("RS485");
textFragmentAbsorber.Visit(page);
foreach (var tf in textFragmentAbsorber.TextFragments)
{
var annotation = new SquareAnnotation(page, tf.Rectangle)
{
Title = "Aspose.PDF",
Subject = "Text detection",
Color = Aspose.Pdf.Color.DarkRed,
};
page.Annotations.Add(annotation);
}
page.Flatten();
document.Save($"C:\\Samples\\Results\\00-90-0000-28-107-rot.pdf");
jpegDevice.Process(page, $"C:\\Samples\\Results\\test-image_rot.jpeg");