[JS] How do you set preferences for Interactive PDF export?
I am trying to export an Interactive PDF document with certain compression settings using a script. If I manually export it and set the compression settings to the following:
- Compression - > Automatic
- JPEG Quality - > Maximum
- Resolution (ppi) - > 72
The images in the document come out with perfect detail.
If on the other hand I try to export the Interactive PDF document via my script the images in the document come out blurry. I am setting the three settings above in my script but they seem to have no effect.
Here is my code:
openFile = File(myFolder + docToProcess);
saveFile = File(myFolder + docToProcess.substring(0,docToProcess.length - 4) + ".pdf")
var docFile = app.open(openFile, Boolean.true, OpenOptions.OPEN_ORIGINAL);
var gDoc = app.activeDocument;
with (app.interactivePDFExportPreferences) {
pdfRasterCompression = PDFRasterCompressionOptions.AUTOMATIC_COMPRESSION;
pdfJPEGQuality = PDFJPEGQualityOptions.MAXIMUM;
pageRange = PageRange.ALL_PAGES;
rasterResolution = RasterResolutionOptions.SEVENTY_TWO_PPI;
}
gDoc.exportFile(ExportFormat.INTERACTIVE_PDF, saveFile, Boolean.true);
docFile.close(SaveOptions.NO);The weird thing is if I try to export the document manually after running the script I can see that the script has changed the "Compression" settings for Interactive PDF export dialogue. So it looks like my script is changing the preferences but those preferences are having no impact on the actual exported PDF. Am I doing anything wrong here or missing anything?
As an aside, setting the third parameter in the gDoc.exportFile command to true should show the options dialogue shouldn't it? Here is what it says in the reference, "If true, displays the export options dialog.". InDesign ExtendScript API (16.0)
At the begining of my script I also have the following:
app.scriptingPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;My understanding is that the true option in the exportFile command and the scriptPreferences should allow the options dialogue to pop up when exporting the PDF in the script. When I run the script it just exports the PDF with no dialogue opening. Why is the dialogue not opening? Ideally, I would like to just export it without user interaction but I am trying all kinds of different options to debug this problem.
I am running the script via the ExtendScript Debugger 2.0 Beta 3.0 Release on Visual Studio Code.
Thank you in advance for any help provided.
