Export Indesign File to PDF

Does UXP have native support for exporting an Indesign file to PDF? If not, what would be the next best way to accomplish this?

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) ;
})() ;

Hi everyone,

Could you please confirm whether there is NO asynchronous PDF export available in UXP at the moment?

The ExtendScript version is not very stable, so I had to stop using it in my scripts. I was hoping that a UXP implementation could be a possible workaround. Currently, UXP PDF export works just fine, but it doesn’t provide any real added value compared to the ExtendScript version.

Has anyone heard of a roadmap or future plans to support asynchronous PDF export in UXP?

Thanks.

InDesign’s UXP Object Model is using the same bindings as the ExtendScript one, so in 99.9% of the cases, if something exists in ExtendScript it also exists in UXPScript. Now if it works ok or not, that’s a different question.
But specifically for your problem:

app.activeDocument.asynchronousExportFile(ExportFormat.PDF_TYPE, 'd:/test.pdf')

Seems to be working just fine in UXP

Thanks for the feedback. Seems straightforward, and it works indeed.
I don’t know what I was doing wrong here. Got confused… anyway. Thank you.