Skip to main content
Participant
August 19, 2024
Answered

Spawning page template always in Letter Size

  • August 19, 2024
  • 2 replies
  • 1171 views

Hi,

 

I've got a document with multiple pages. All pages sized are A4.

I have a script adding a blank page before spawning the the selected template using a button (js).

The added blank page is always a Letter size which is wider and shorter, resulting in issues.

How can I set pages default size, or how can I code the size to be A4 once i create the blank page?  

 

Thanks all.

This topic has been closed for replies.
Correct answer PDF Automation Station

this.newPage() takes width and height parameters in points.  If they are ommitted the default is 8.5 inches by 11.  Change this this.newPage(1) to this.newPage(1, 595, 842);

2 replies

PDF Automation Station
Community Expert
Community Expert
August 19, 2024

What is your script to add the blank page?  If you are using this.insertPages(), the blank page you add should be one that is size A4.  To create a blank page you can run app.newDoc() in the console.  It takes 2 input parameters:  width in points, and height in points.  For A4 I believe the script is:

app.newDoc(595,842);

You could also crop the page, but this won't work if the end user has Reader.  Inserting pages won't either.  In this case you could spawn a hidden blank template page.  If the page you spawn is the correct size you shouldn't have any issues.

Participant
August 20, 2024
I've been using this.newPage() instead. I just tried this.insertPages() and it does nothing.

My original code (works) looks something like this:

this.newPage(1);

this.spawnPageFromTemplate({
cTemplate: this.getNthTemplate(0),
nPage: 1,
bRename: false
});

this.pageNum = 1;

this.getField("Button3").readonly = true;


How can I get the new page to be size A4?
Participant
August 20, 2024

this.newPage() takes width and height parameters in points.  If they are ommitted the default is 8.5 inches by 11.  Change this this.newPage(1) to this.newPage(1, 595, 842);


Awesome! Thank you so much. "this.newPage(1, 595, 842);" Worked like a charm.

 

Could you please tell me how exactly you can inpect the current page size for my future reference? 

Again, many thanks!

Bernd Alheit
Community Expert
Community Expert
August 19, 2024

How do you add the blank page?

Participant
August 20, 2024

this.newPage()