Page 1 of 1

[javascript] Doc.setPageBoxes() weird behavior?

Posted: Sat Jan 18, 2025 3:30 am
by Mathew
I'm having three problems with the Doc.setPageBoxes() command.

The first problem:
problemCrop.pdf
For the attached pdf file, I can expand the media box by running:

Code: Select all

this.setPageBoxes({ 'cBox': 'Media',
                    'nStart' : 0,
                    'rBox':  [-187.0426025390625,792,791.093505859375,0] })
It then expands the page:
image.png
If I then reset the page by running:

Code: Select all

this.setPageBoxes({ 'cBox': 'Media',
                    'nStart' : 0,
                    'rBox':  [0,792,612,0] })
All appears good on the surface:
image(3).png
However, if I try to run the first command again, nothing happens! The undo history says a crop has happened, but I cannot find any changes. At this point, I can't figure out what's messed up in the page boxes. If I run 'Normalize Pages' for instance, it thinks they're already "normalized". Art, Bleed, BBox, Trim, Crop all seem to have the same values that they did originally:

Code: Select all

Art: 0,792,612,0
Bleed: 0,792,612,0
BBox: 67.46399688720703,753.8079833984375,565.0999755859375,27.7340087890625
Trim: 0,792,612,0
Crop: 0,792,612,0
The second problem is how javascript is responding to errors with the parameters in this method. Instead of returning a javascript error, it's popping up a dialog which makes handling any error impossible:
image(1).png
or
image(2).png
The third problem
API states that the parameter rBox is optional. If not provided, the specified box is removed.
However, if I try

Code: Select all

doc.setPageBoxes({ 'cBox': 'Trim', 'nStart':0});
I get an error popup
image(4).png

Re: [javascript] Doc.setPageBoxes() weird behavior?

Posted: Tue Jan 21, 2025 1:34 pm
by Stefan - PDF-XChange
Hello Mathew,

I see that Dan has passed the above to our devs and they said that they will look into the above and try to reply to you within the next 24h. So we are looking into this, it just can take us a bit longer to get back to you!

Kind regards,
Stefan

Re: [javascript] Doc.setPageBoxes() weird behavior?  SOLVED

Posted: Thu Jan 23, 2025 12:59 am
by Vasyl - PDF-XChange
Hi Mathew.

All problems described will be fixed in the upcoming build. Thanks for the report.

Cheers.

Re: [javascript] Doc.setPageBoxes() weird behavior?

Posted: Mon Feb 03, 2025 6:44 pm
by Mathew
All good in build 394. Thank you. :D

[javascript] Doc.setPageBoxes() weird behavior?

Posted: Tue Feb 04, 2025 1:34 pm
by Stefan - PDF-XChange
:)