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

How to save as PDF from a script

Advocate ,
Aug 01, 2022 Aug 01, 2022

Copy link to clipboard

Copied

Has anyone created PDFs from an ExtendScript with FrameMaker 2020 or newer (2022 beta) ? I have tried to use the Doc.Save function with the FileType set to SaveFmtPdf but this freezes FrameMaker - after sending a couple of (for me) incomprehensible messages to the console.

Screenshot 2022-08-01 at 10.46.07.png

I am not aware of any password protection. When I choose Save as PDF from the File menu, the PDF is created without any issues. If there is another way (using CallClient to the Publish panel ?) I would like to know that, too. I am not stuck on any particular method, as long as I can automate the creation of PDFs.

 

Thanks in advance for a quick reply - especially if you have a working solution.

 

Jang

TOPICS
PDF output , Publishing , Scripting

Views

261

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

Community Expert , Aug 01, 2022 Aug 01, 2022

Here is a function I use for one of my clients. It is namespaced, but you can remove it or change it.

WE_PMO.saveBookAsPdf = function (book, name) {	
    
    var params, returnParams, i;
    
    params = GetSaveDefaultParams ();
    returnParams = new PropVals ();
    
    i = GetPropIndex (params, Constants.FS_FileType);
    params[i].propVal.ival = Constants.FV_SaveFmtPdf;
	i = GetPropIndex (params, Constants.FS_PDFUseDistiller);
    params[i].propVal.ival = 0;

    FA_errno = 0;
    book.Sa
...

Votes

Translate

Translate
Community Expert ,
Aug 01, 2022 Aug 01, 2022

Copy link to clipboard

Copied

Jang, please post your code and I will take a look. 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
Community Expert ,
Aug 01, 2022 Aug 01, 2022

Copy link to clipboard

Copied

Here is a function I use for one of my clients. It is namespaced, but you can remove it or change it.

WE_PMO.saveBookAsPdf = function (book, name) {	
    
    var params, returnParams, i;
    
    params = GetSaveDefaultParams ();
    returnParams = new PropVals ();
    
    i = GetPropIndex (params, Constants.FS_FileType);
    params[i].propVal.ival = Constants.FV_SaveFmtPdf;
	i = GetPropIndex (params, Constants.FS_PDFUseDistiller);
    params[i].propVal.ival = 0;

    FA_errno = 0;
    book.Save (name, params, returnParams);
	if (FA_errno !== 0) {
		PrintSaveStatus (returnParams);
	}
    return FA_errno;
};

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
Advocate ,
Aug 01, 2022 Aug 01, 2022

Copy link to clipboard

Copied

LATEST

Thanks, Rick.

 

I missed the FS_PDFUseDistiller parameter (as the Save as PDF no longer uses that route) and had an error in the declaration of the return parameters array. After fixing those two issues it is working as intended. Now the only issue to solve is how to get to PDF/A-2a. It looks like I will have to do some Adobe Acrobat Pro scripting to automate that part of the workflow.

 

Kind regards

 

Jang

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