# Export Pages as PDFs?

**URL:** <https://forums.creativeclouddeveloper.com/t/export-pages-as-pdfs/7190>\
**Category:** InDesign\
**Created:** [November 29, 2023, 7:24pm UTC](https://forums.creativeclouddeveloper.com/t/export-pages-as-pdfs/7190 "2023-11-29T19:24:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![oiver55](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/oiver55/32/3371_2.png) [@oiver55](https://forums.creativeclouddeveloper.com/u/oiver55)\
**Post date:** [November 29, 2023, 7:24pm UTC](https://forums.creativeclouddeveloper.com/t/export-pages-as-pdfs/7190/1 "2023-11-29T19:24:43Z")

</div>

How can I export files through my plugin? When I check the App.ActiveDocument module, I see PdfExportPreferences, but no export function. I’d like to export as pdf in code(want to avoid dialog appering).

---

<div class="post-metadata">

**Author:** ![medium\_jon](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/medium_jon/32/2371_2.png) [@medium\_jon](https://forums.creativeclouddeveloper.com/u/medium_jon)\
**Post date:** [November 29, 2023, 7:49pm UTC](https://forums.creativeclouddeveloper.com/t/export-pages-as-pdfs/7190/2 "2023-11-29T19:49:40Z")

</div>

So while there are both PDFExportPreferences and Adobe PDF Presets, the export is a method of the document (and maybe other elements)

I believe it is either  
.exportFile(ExportFormat.PDF\_TYPE…  
.asynchronousExportFile(ExportFormat.PDF\_TYPE…

But that requires you to have the `ExportFormat` enumeration

I’ve not tried either in UXP yet, however.

---

<div class="post-metadata">

**Author:** ![oiver55](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/oiver55/32/3371_2.png) [@oiver55](https://forums.creativeclouddeveloper.com/u/oiver55)\
**Post date:** [November 30, 2023, 2:10pm UTC](https://forums.creativeclouddeveloper.com/t/export-pages-as-pdfs/7190/3 "2023-11-30T14:10:41Z")

</div>

Perfect okay, hey where does the ExportFormat.PDF\_TYPE come from, it’s undefined when I try to call it in UDT.

---

<div class="post-metadata">

**Author:** ![medium\_jon](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/medium_jon/32/2371_2.png) [@medium\_jon](https://forums.creativeclouddeveloper.com/u/medium_jon)\
**Post date:** [November 30, 2023, 7:09pm UTC](https://forums.creativeclouddeveloper.com/t/export-pages-as-pdfs/7190/4 "2023-11-30T19:09:57Z")

</div>

the `ExportFormat` is an enumeration. When you see InDesign values starting with a capital letter, it’s likely an Enumeration - especially when the part after the `.` is in ALL\_CAPS. And they have to be added to your UXP code. Perhaps there is an easier way, but I’m using something like this:

`var { ExportFormat } = require {'indesign'};`

there’s a boatload of them! My current list is:

```auto
var {
		AnchorPoint,
		ContentType,
		ExportFormat,
		FitOptions,
		LinkStatus,
		MeasurementUnits,
		PNGExportRangeEnum,
		PNGQualityEnum,
		RulerOrigin,
		VariableTypes,
	} = require(appName_s);

```

where `appName_s` is ‘indesign’

jsw

---

<div class="post-metadata">

**Author:** ![oiver55](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/oiver55/32/3371_2.png) [@oiver55](https://forums.creativeclouddeveloper.com/u/oiver55)\
**Post date:** [November 30, 2023, 7:13pm UTC](https://forums.creativeclouddeveloper.com/t/export-pages-as-pdfs/7190/5 "2023-11-30T19:13:48Z")

</div>

Crystal Clear, okay I’ll try it out

---

<div class="post-metadata">

**Author:** ![salinsley](https://avatars.discourse-cdn.com/v4/letter/s/b3f665/32.png) [@salinsley](https://forums.creativeclouddeveloper.com/u/salinsley)\
**Post date:** [December 4, 2023, 10:27pm UTC](https://forums.creativeclouddeveloper.com/t/export-pages-as-pdfs/7190/6 "2023-12-04T22:27:18Z")

</div>

If anyone was looking for a plug-and-play solution to export a PDF of your currently open document, here you go:

```auto
let ID = require("indesign");
const exportPath = "/Users/username/Desktop/test.pdf"; // Change this to where you want the file to be exported

// if you just want the PDF exported with the most recent export preset, use this
app.activeDocument.exportFile(ID.ExportFormat.PDF_TYPE, exportPath);

// if you want the file exported with a specific pdf export preset, use this:
const presetName = "[High Quality Print]"; // Change this to whichever PDF Export preset you want to use
const pdfExportPreset = app.pdfExportPresets.itemByName(presetName);
app.activeDocument.exportFile(ID.ExportFormat.PDF_TYPE, exportPath, false, pdfExportPreset);

```

As an addendum, you can get a list of all the PDF preset names in your application with:

```auto
app.pdfExportPresets.everyItem().name

```

This code should all work from the debug console assuming you have a document open.

---

<div class="post-metadata">

**Author:** ![oiver55](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/oiver55/32/3371_2.png) [@oiver55](https://forums.creativeclouddeveloper.com/u/oiver55)\
**Post date:** [December 5, 2023, 1:08am UTC](https://forums.creativeclouddeveloper.com/t/export-pages-as-pdfs/7190/7 "2023-12-05T01:08:51Z")

</div>

Dynamite, thanks a million
