• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Spawning page template always in Letter Size

New Here ,
Aug 19, 2024 Aug 19, 2024

Copy link to clipboard

Copied

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.

TOPICS
PDF forms

Views

125

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Aug 20, 2024 Aug 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);

Votes

Translate

Translate
Community Expert ,
Aug 19, 2024 Aug 19, 2024

Copy link to clipboard

Copied

How do you add the blank page?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 20, 2024 Aug 20, 2024

Copy link to clipboard

Copied

this.newPage()

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 19, 2024 Aug 19, 2024

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 20, 2024 Aug 20, 2024

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 20, 2024 Aug 20, 2024

Copy link to clipboard

Copied

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);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 20, 2024 Aug 20, 2024

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 20, 2024 Aug 20, 2024

Copy link to clipboard

Copied

LATEST

In the above script, 595 is the width in points and 842 is the height in points.  There are 72 points per inch so the script could also be written like this:

this.newPage(1,Math.round(8.26*72),Math.round(11.7*72));

OR

You could use the existing size of the current page like this:

var size = this.getPageBox("Crop", this.pageNum);
this.newPage(1, size[2], size[1]);

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines