Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Export Selection As PDF - Script Help

Community Beginner ,
Mar 18, 2021 Mar 18, 2021

Hello,

 

I have recenetly come across the following function from this post on the forum:

app.activeDocument.exportSelectionAsPNG(filePath);

I was wondering if something existed along the same lines for exporting selections to PDF?

I have had a look through the docs but I cannot find the function above in the docs anywhere, let alone a PDF option.

 

Any help would be much appreciated. 

Luke.

TOPICS
Import and export , Scripting
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 18, 2021 Mar 18, 2021

I just wrote simple script that will export selected items as a PDF. I hope this will help

 

 

var doc = app.activeDocument;
var docAssets = doc.assets;
var assetIDArray = new Array();
var itemToExport = new ExportForScreensItemToExport();
itemToExport.artboards = '';
itemToExport.document = false;
var assetArray = new Array();
for (var i = 0; i < app.selection.length; i++) {
    var asset = docAssets.add(app.selection[i]);
    assetIDArray.push(asset.assetID);
}
itemToExport.assets = assetIDArr
...
Translate
Adobe
Community Expert ,
Mar 18, 2021 Mar 18, 2021

Hello,

You can export the document as PDF file. Below is the link with all available options for exporting PDF and with one example at the end.

https://illustrator-scripting-guide.readthedocs.io/jsobjref/PDFSaveOptions/?highlight=PDF 

 

Also, below link will also be helpful

https://community.adobe.com/t5/illustrator/script-export-pdf-en-serie/m-p/11158007

 

 

Best regards
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 18, 2021 Mar 18, 2021

Thanks for the quick response Charu. So from the response I can assume there is no built in function for exporting a selection to a PDF, just an entire document?

 

Cheers.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 18, 2021 Mar 18, 2021

You can use, Export Asset functionality to export assets as a PDF.

Best regards
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 18, 2021 Mar 18, 2021

Following link will give you some idea for exporting the asset

 

https://community.adobe.com/t5/illustrator/what-s-new-in-illustrator-scripting-cc2018/m-p/9422236

 

 

Best regards
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 18, 2021 Mar 18, 2021

I just wrote simple script that will export selected items as a PDF. I hope this will help

 

 

var doc = app.activeDocument;
var docAssets = doc.assets;
var assetIDArray = new Array();
var itemToExport = new ExportForScreensItemToExport();
itemToExport.artboards = '';
itemToExport.document = false;
var assetArray = new Array();
for (var i = 0; i < app.selection.length; i++) {
    var asset = docAssets.add(app.selection[i]);
    assetIDArray.push(asset.assetID);
}
itemToExport.assets = assetIDArray;
var options = new ExportForScreensPDFOptions();
app.activeDocument.exportForScreens(File('~/Desktop'), ExportForScreensType.SE_PDF, options, itemToExport);

 

 

Before you run the script, select all items that you want to export. Here is the descrtiption what script do.

 

1. First it will create assets from the selected items.

2. Export all assets as a PDF at Desktop.

 

NOTE: If you run the script second time, it will add assests back to the assets panel so assets will increase. You can handle it by checking if selected element as an assets already exists then don't add inside the Asset panel.

 

Best regards
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 18, 2021 Mar 18, 2021

This has been a huge help, thankyou very much Charu.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 18, 2021 Mar 18, 2021
LATEST

You're welcome 🙂

Best regards
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines