Viewport parameters

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

gauthierDC
User
Posts: 7
Joined: Thu Apr 09, 2026 12:04 pm

Viewport parameters

Post by gauthierDC »

Hi,
I would like to open a document to a specific region through the command line using the /A argument.
The idea is to open the file and fit the view to the red rectangle:
image.png
image(1).png
In the documentation, I can read:
viewrect=<left>,<top>,<width>,<height> – sets the view rectangle using float or integer values in a coordinate system where 0,0 represents the top left corner of the visible page, regardless of document rotation. Use the page parameter before this command.
I tried this:

Code: Select all

.\PXCEditor.exe /A "page=1; viewrect=100,100,200,300" test.pdf
With these arguments, I expected the program to open the document and fit the view to the red box. The rectangle is located at 100,100 from the top left corner and is 200 pixels wide and 300 pixels high. Instead, I got this:
image(2).png
What am I missing?
test.pdf
You do not have the required permissions to view the files attached to this post.
User avatar
Dimitar - PDF-XChange
Site Admin
Posts: 2697
Joined: Mon Jan 15, 2018 9:01 am

Re: Viewport parameters

Post by Dimitar - PDF-XChange »

Hi,
In the documentation, I can read:
May I ask in which page of the manual you saw these instructions?

EDIT: Found it.

It does work on my end.

May I ask for you full command line and tell me how you excute it?
gauthierDC
User
Posts: 7
Joined: Thu Apr 09, 2026 12:04 pm

Re: Viewport parameters

Post by gauthierDC »

Here is the link to the documentation I used: https://help.pdf-xchange.com/pdfxe11/in ... ns_ed.html

The previous command line is exactly what I am trying on my example file.
I run it in the PowerShell terminal, in the PDF-XChange installation directory:

Code: Select all

PS C:\Program Files\PDF-XChange\PDF Editor> .\PXCEditor.exe /A "page=1; viewrect=100,100,200,300" test.pdf
With these arguments on my test file, the view does not fit to the entire red box as I would like (screen #2 in the first post). Instead, I get the result shown in screen #3.

Thank you for the help.
User avatar
rakunavi
User
Posts: 2205
Joined: Sat Sep 11, 2021 5:04 am

Re: Viewport parameters

Post by rakunavi »

Hello all,

Just for reference regarding the coordinate system of the command-line parameters (like FitH, top):
The value in PDF-XChange Editor is calculated based on the following relationship (referencing RFC 8118 Section 3):

  • (inch) x (Windows display scale) x 96
  • (inch) x (PDFXCE resolution value)
  • https://www.rfc-editor.org/rfc/rfc8118.html#section-3
If the position is shifted, it's usually because the input value doesn't account for the current Windows display scale or the application's DPI resolution. The editor itself is rendering exactly where it is told to.

You may also find the following topic helpful:
viewtopic.php?t=44201

Best regards,
rakunavi
Top needs for PDFXCE
forum.pdf-xchange.com/viewtopic.php?t=39665 LassoTool
forum.pdf-xchange.com/viewtopic.php?t=38554 CmtGarbled
forum.pdf-xchange.com/viewtopic.php?t=37353 FullScrnMultiMon
forum.pdf-xchange.com/viewtopic.php?t=41002 DisableTouchSelect
gauthierDC
User
Posts: 7
Joined: Thu Apr 09, 2026 12:04 pm

Re: Viewport parameters

Post by gauthierDC »

Ah! Thanks a lot for the tip!
It was indeed related to screen resolution.

Adding the usept=yes argument works perfectly:

What does work for me:

Code: Select all

PS C:\Program Files\PDF-XChange\PDF Editor> .\PXCEditor.exe /A "page=1; viewrect=100,100,200,400, usept=yes" test.pdf
I've always had trouble understanding the concepts of resolution and zoom.
In my mind, an A4-sized PDF viewed at 100% zoom should have the same magnification as if I were printing it on A4 paper at 100%.
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19942
Joined: Mon Jan 12, 2009 8:07 am

Re: Viewport parameters

Post by Stefan - PDF-XChange »

Hello gauthierDC,

Glad to see you sorted it out.
And yes - when Windows scaling is involved, some setting up is required for the on screen 100% to match the 100% on paper.

Kind regards,
Stefan