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

How to fast copy PDF to ai file?

Explorer ,
Feb 24, 2022 Feb 24, 2022

I just want to duplicate PDF contents into a new layer of an AI file? So how to fast copy? Now I have to open the PDF file and copy pageItems one by one:

var firstLayer = docSrc.activeLayer;
var newLayer = docDest.layers.add();
if (firstLayer.pageItems.length > 0) {
for (var i = firstLayer.pageItems.length - 1; i >= 0; i--) {
var item = firstLayer.pageItems[i];
item.duplicate(newLayer, ElementPlacement.PLACEATBEGINNING);
}
}
TOPICS
Performance , Scripting , SDK
581
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
Adobe
Guide ,
Feb 27, 2022 Feb 27, 2022

Duplicating items one by one is the established and most consistent way. 

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 ,
Feb 27, 2022 Feb 27, 2022

Opening a PDF in Illustrator may desroy text and color profiles. Therefore do not open any PDF in Illustrator except those which are created and saved in Illustrator with its editing capabilities.

 

What you can do: Place a PDF file as linked file, do not embed them. So you can duplicate as any other object.

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
Explorer ,
Feb 27, 2022 Feb 27, 2022

Could you give some sample code to place a PDF file as linked file.

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 ,
Feb 27, 2022 Feb 27, 2022

how long does it take duplicating items one at a time? 

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
Explorer ,
Feb 27, 2022 Feb 27, 2022

It's slow, about 9 - 10s.

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 ,
Feb 27, 2022 Feb 27, 2022
LATEST

10 seconds is slow, how many pageItems are you processing?

 

instead of copying each item you could duplicate the ActiveLayer for an instant gratification. Unfortunately there's no API to duplicate layers.

The good news is that you can record an Action to duplicate layers and play that action with a script using

app.doScript("Action Name", "Action Set Name");

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 ,
Feb 27, 2022 Feb 27, 2022

A one page pdf?
How about place and embed?

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 ,
Feb 27, 2022 Feb 27, 2022

Embedding is the same as opening a PDF. As PDFs can have different color spaces and profiles all will be converted or changed to the AI's color space and destroy the colors of the original PDF. 
Another problem are the fonts. If the original fonts are not installed some other font will be replaced and text blocks are destroyed and the text appearance might change,

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