Does UXP have native support for exporting an Indesign file to PDF? If not, what would be the next best way to accomplish this?
1 Like
It seems that exportFile
is the way to do it.
/**
* @file UXP Script for export PDF.
* For whatever reason, the documentation for exportFile exists on the page for objects such as TextFrame.
* https://developer.adobe.com/indesign/dom/api/t/TextFrame/#methods
* @version 1.0.0
* @author sttk3.com
* @copyright © 2024 sttk3.com
*/
const { app, ExportFormat } = require('indesign') ;
(() => {
if(app.documents.length <= 0) {return ;}
const doc = app.activeDocument ;
const docName = doc.name.replace(/\.[a-z0-9]{2,4}$/i, '') ;
const targetPath = `/Users/username/Desktop/${docName}.pdf` ;
const pdfPreset = app.pdfExportPresets.item(0) ;
doc.exportFile(ExportFormat.PDF_TYPE, targetPath, false, pdfPreset) ;
})() ;
1 Like