Skip to main content
Inspiring
June 27, 2023
Question

Create Print PDF using ExtendScript

  • June 27, 2023
  • 1 reply
  • 756 views

I want to create an enlarged PDF file with crop marks from my book using ExtentScript.
For the enlarged output of the PDF file I found in the documentation the properties FS_PageHeight and FS_PageWidth.
In the script I entered the desired sizes 222*291 mm in Metric specifications. But the size of the PDF file does not change.
All other properties are taken over. What am I doing wrong?

 

function saveBookAsPdf (book, name)
{
    var params, returnParams, i, res;
    params = GetSaveDefaultParams();
    returnParams = new PropVals();
    i = GetPropIndex (params, Constants.FS_FileType);
    params[i].propVal.ival = Constants.FV_SaveFmtPdf;
    i = GetPropIndex (params, Constants.FS_ShowBookErrorLogPublishing);
    params[i].propVal.ival = Constants.FV_DoYes;
i = GetPropIndex (params, Constants.FS_PDFUseDistiller);
    params[i].propVal.ival = 0;
    i = GetPropIndex (params, Constants.FS_PDFPrimaryOutput);
    params[i].propVal.ival = Constants.FV_DoPrint;
    i = GetPropIndex (params, Constants.FS_PDFPages);
    params[i].propVal.ival = true;
    i = GetPropIndex (params, Constants.FS_PageHeight);
    params[i].propVal.mval = 54059448; //291 mm
    i = GetPropIndex (params, Constants.FS_PageWidth);
    params[i].propVal.mval = 41241228; //222 mm
    i = GetPropIndex (params, Constants.FS_CropMarks);
   params[i].propVal.ival = true;
    res = book.Save (name, params, returnParams);
}
This topic has been closed for replies.

1 reply

frameexpert
Community Expert
Community Expert
June 27, 2023

Try setting the PDFPageHeight and PDFPageWidth properties to the desired values.

Inspiring
June 27, 2023

Thanks for the reply.
I tried it but I got the error "undefined is no object" for line:

params[i].propVal.ival = 54059448; //291 mm

The constant seems to be unknown. I am using Fraemaker 2019.

 

function saveBookAsPdf (book, name)
{
    var params, returnParams, i, res;
    params = GetSaveDefaultParams();
    returnParams = new PropVals();
    i = GetPropIndex (params, Constants.FS_FileType);
    params[i].propVal.ival = Constants.FV_SaveFmtPdf;
    i = GetPropIndex (params, Constants.FS_ShowBookErrorLogPublishing);
    params[i].propVal.ival = Constants.FV_DoYes;
i = GetPropIndex (params, Constants.FS_PDFUseDistiller);
    params[i].propVal.ival = 0;
    i = GetPropIndex (params, Constants.FS_PDFPreset);
    params[i].propVal.sval = 'PxC_Print_RGB_v02';
    i = GetPropIndex (params, Constants.FS_PDFLayout);
    params[i].propVal.ival = 5; //Two-up (Cover Page)
    i = GetPropIndex (params, Constants.FS_PDFPrimaryOutput);
    params[i].propVal.ival = Constants.FV_DoPrint;
    i = GetPropIndex (params, Constants.FS_PDFPages);
    params[i].propVal.ival = true;
    i = GetPropIndex (params, Constants.FS_PDFPageHeight);
    params[i].propVal.ival = 54059448; //291 mm
    i = GetPropIndex (params, Constants.FS_PDFPageWidth);
    params[i].propVal.ival = 41241228; //222 mm
    i = GetPropIndex (params, Constants.FS_CropMarks);
    params[i].propVal.ival = true;
    res = book.Save (name, params, returnParams);
    alert(res);
}
frameexpert
Community Expert
Community Expert
June 27, 2023

The constants are actually:

Constants.FP_PDFPageHeight

Constants.FP_PDFPageWidth

Most properties are prefixed by FP. Some of your other ones may be wrong too.