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

Create Print PDF using ExtendScript

Explorer ,
Jun 27, 2023 Jun 27, 2023

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);
}
TOPICS
PDF output , Scripting
516
Translate
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
Community Expert ,
Jun 27, 2023 Jun 27, 2023

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

Translate
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
Explorer ,
Jun 27, 2023 Jun 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);
}
Translate
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
Community Expert ,
Jun 27, 2023 Jun 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.

Translate
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
Explorer ,
Jun 27, 2023 Jun 27, 2023

Unfortunately same result in the same row (undifined is no object):

Udo29519402o23a_0-1687874217713.pngexpand image

 

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.FP_PDFPageHeight);
    params[i].propVal.ival = 54059448; //291 mm
    i = GetPropIndex (params, Constants.FP_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);
}
Translate
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
Community Expert ,
Jun 27, 2023 Jun 27, 2023

I am sorry about that. PDFPageHeight and PDFPageWidth are not save parameters, but document and book properties. So, remove those lines from your code and add these to your code:

book.PDFPageHeight = 54059448; // 291 mm
book.PDFPageWidth = 41241228; // 222 mm
Translate
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
Explorer ,
Jun 27, 2023 Jun 27, 2023
LATEST

Thanks again. The PDF was created this time but the size is still the same:

Udo29519402o23a_0-1687875565860.pngexpand image

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);
    i = GetPropIndex (params, Constants.FS_CropMarks);
    params[i].propVal.ival = true;
    book.PDFPageHeight = 54059448; // 291 mm
    book.PDFPageWidth = 41241228; // 222 mm
    res = book.Save (name, params, returnParams);
    alert(res);
}
Translate
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