There are several pixel errors in ResizeContents(PdfFileEditor )

Detailed content in the uploaded document11.zip (1.0 MB)

@78783718
You wrote “The left and right margins differ by a few millimeters in the results” - do you mean they differ from each other?
Or different from expected results?

The other edges were not tested, but only the left and right edges were tested, mainly because the examples were only left and right edges

This example has a difference of approximately 2 mm.Previously tested the others, but they were around 1-3 mm anyway.Although this is small, when converted to metric system, it will be a few millimeters, and the printed drawings can be seen clearly

@78783718
I visually, with a 10x magnification, compared the sizes of the left and right edges for the original pdf and the one obtained after conversion. Visually they coincide with each other - approximately equal before and after the transformation. I say approximately because I applied a ruler with millimeter divisions to the screen.
Or is your question that before the conversion there were 3.27 units, after the conversion it was 0.26, but it should be not 0.26 but some other value?
What kind of units are given in the document (if I correctly understood the meaning of the numbers 3.27 and 0.26)?

3.27 is centimeters, which is 32.7 millimeters. This is the original file.

0.26 is centimeters, which is 2.6 millimeters. This is the converted file.

These are all metric and need to be converted to pixels. The code for this part is included in the document sent to you.

The current problem is that the position of 0.26 centimeters should be 0, not 0.26 centimeters

@78783718

Thanks for the clarification - I understand your question.
Please explain the translation you use Metric millimeters to pixels

  • why did you choose 32.7 (and not 32.6 or 32.8 for example)
  • what the number is 25.4f
  • 72.0 as I understand it pixels per inch
    image.png (20.6 KB)

32.7 is millimeters, which is 3.27 centimeters

The margin I measured with the tool requires 32.7 millimeters (3.27 centimeters).

Even if it is 32.6mm or 32.8mm, this value will not affect it.

The difference now is an error of 2-3 millimeters, which is a bit larger.

1 inch=25.4 millimeters , 1 inch=72dpi

var leftOrRight= (32.7f / 25.4f)* 72;

@78783718
I had doubts about the correctness of the original and calculated data. I added a rectangle to the document

var sa = new SquareAnnotation(page, new Rectangle(93, 0, 94, page.MediaBox.Height))

it actually coincided with the extreme line on the document. By setting leftOrRight to 92 (as it calculated out in your code) i.e. working without recalculations, only in units, I looked the result. Indeed, the rectangle is not at the very edge. There is a flaw, I will set a task to the development team to study and fix it.

Okay, this detail is really not easy to discover

@78783718
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-55640

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.