Uncaught exception when saving to PDF via script
Hi All, I am having a problem programmatically saving a structured book to PDF with ExtendScript. I can run the code below repeatably on an unstructured book. But when I run it on my structured book, it runs fine the first time, but the second time it gives me an error and locks up FrameMaker.
Script Error :
Error Message : Uncaught exception
Script, Line# : C:\Users\rick\AppData\Roaming\Adobe\FrameMaker\15\WE-SaveActiveBookAsPdf.jsx, 22
I tried adding a try/catch block but it still fails without catching the error.
If you have a structured book and can test this on your machine, I would appreciate it. I am using FrameMaker 2019 15.8.979. Here is the code:
#target framemaker;
var book, name;
book = app.ActiveBook;
name = book.Name.replace (/[^\.]+$/, "pdf");
saveBookAsPdf (book, name);
function saveBookAsPdf (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;
}

