Skip to main content
faustographic
Participant
January 23, 2023
Answered

Import a multipage-pdf in PS

  • January 23, 2023
  • 3 replies
  • 7800 views

Hi guys,

I need to import a PDF with 250 pages into one PS-File. One page = one layer. How can achieve that? Is there a workaround?

 

Thanks.

Björn

 

 

Correct answer Stephen Marsh

@faustographic – You will need a script, such as:

 

https://www.kuhnke-owl.de/fileadmin/Downloads/MultipageLayers/pdf_pages_to_layers.zip

 

I slightly modified a version by request for the layer names and white pages:

 

// Open a multi-page PDF in Photoshop Layers
// Script opens every Page of the PDF single, Copies them into a Photoshop Layer and renames the Layer with the Document-Name
// which includes the Page Number
// Heike Herzog-Kuhnke 03/2014

// Starting:
// enable double clicking from the Macintosh Finder or the Windows Explorer
#target photoshop

// in case we double clicked the file
app.bringToFront();

// Don´t show Dialogs, if Photoshop likes to....
displayDialogs = DialogModes.NO;

// Variables. Needs to be Changed if you like to have something else
// Unfortunately, I couldn't find out how to locate the num of Pages of the PDF.
// MaxPages larger tan the reality is OK, must be numPages + 1 minimum
// Resolution and Document Mode as you need it
var myMaxPages = 100;
var myCounter = 1;
var myResolution = 300;
var myColor = OpenDocumentMode.CMYK;

//Set Background Color to white (not really needed...)
app.backgroundColor.rgb.red = 255;
app.backgroundColor.rgb.green = 255;
app.backgroundColor.rgb.blue = 255;

// Start Open Dialog. If you don`t choose a File with Ending .pdf the Script stops
var _pdfDatei = File.openDialog("Choose your Multipage-PDF-File");
var myDatei = "" + _pdfDatei;
var myEndung = myDatei.substr(myDatei.length - 4, 4);

if (myEndung !== ".pdf") {
    alert("No PDF choosen!\nStop Run!", "Error choosing File");
} else {
    // Here I start with defining the OpenOptions of the PDF for the first Page (Using the Variables from above)
    var pdfOpenOptions = new PDFOpenOptions;
    pdfOpenOptions.antiAlias = true;
    pdfOpenOptions.mode = myColor;
    pdfOpenOptions.bitsPerChannel = BitsPerChannelType.EIGHT;
    pdfOpenOptions.resolution = myResolution;
    pdfOpenOptions.supressWarnings = true;
    pdfOpenOptions.cropPage = CropToType.TRIMBOX;
    pdfOpenOptions.page = myCounter;

    // Opening the PDF
    open(_pdfDatei, pdfOpenOptions);
    // The Layer renamed by the Name of the Document
    var myDocument1 = app.activeDocument;
    var myLayerName = app.activeDocument.name;
    myDocument1.activeLayer.name = myLayerName + "_Page-" + myCounter; // original code modified
    whitePage(); // original code modified

    // Starting the Processing for the other pages
    // The Counter defines the Page Number. 
    // File will be Opened,, Layer copied, File Closes withsout saving, Paste in the first Document and renamed 
    // As long as pages are existing the Procedure runs until counter is 1 less to myMaxPages -Value
    // If there is an error (if the page doesnt exist) the Script stops and Says all done) 
    for (myCounter = 2; myCounter < myMaxPages; myCounter++) {
        // try / catch to resolve Problem with to many Pages in count
        // on Errors the counter will be set to Maximum Value to stop the for / next loop
        try {
            // PDF options
            pdfOpenOptions.page = myCounter;
            open(_pdfDatei, pdfOpenOptions);
            // Saving the new Document Name for the Layer Name
            myLayerName = app.activeDocument.name;
            app.activeDocument.activeLayer.name = myLayerName;
            app.activeDocument.selection.selectAll();
            app.activeDocument.selection.copy(true);
            app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
            app.activeDocument = myDocument1;
            myDocument1.paste();
            // Renaming the new Layer in first Document
            myDocument1.activeLayer.name = myLayerName + "_Page-" + myCounter; // original code modified
            whitePage(); // original code modified

        } catch (e) {
            alert("Done");
            myCounter = myMaxPages;
        }
    }
}

// original code mofified:
function whitePage() {
    var sel = activeDocument.selection;
    var fillColor = new SolidColor();
    fillColor.rgb.red = 255;
    fillColor.rgb.green = 255;
    fillColor.rgb.blue = 255;
    sel.fill(fillColor, ColorBlendMode.DARKEN, 100, false);
}

 

  1. Copy the code text to the clipboard
  2. Open a new blank file in a plain-text editor (not in a word processor)
  3. Paste the code in
  4. Save as a plain text format file – .txt
  5. Rename the saved file extension from .txt to .jsx
  6. Install or browse to the .jsx file to run (see below)

 

If these simple instructions are too abbreviated, you may need to read on:

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html#Photoshop

3 replies

Known Participant
March 16, 2025

I would like to know what the goal is, i.e. why do you have to import all these pages into photoshop?
🙂

Stephen Marsh
Community Expert
Community Expert
January 23, 2023

You're welcome! Please come back and mark the appropriate reply as the correct answer.

 

Be sure to change the following parameters in the script as required:

 

var myMaxPages = 100;
var myResolution = 300;
var myColor = OpenDocumentMode.CMYK;

 

An alternative is to rasterize all pages into separate files and save all open docs to file using  a batch action:

 

https://github.com/Paul-Riggott/PS-Scripts/blob/master/PDF%20ProcessorII.jsx

 

Then use the default Photoshop script to stack the files into layers:

 

File > Scripts > Load Files Into Stack

faustographic
Participant
January 23, 2023

This is great. I'm learning VBA for Excel at the moment. And PS-Scripting is the next step. This is a great example to work with. Appreciate the share and time to answer. CYA.

Stephen Marsh
Community Expert
Stephen MarshCommunity ExpertCorrect answer
Community Expert
January 23, 2023

@faustographic – You will need a script, such as:

 

https://www.kuhnke-owl.de/fileadmin/Downloads/MultipageLayers/pdf_pages_to_layers.zip

 

I slightly modified a version by request for the layer names and white pages:

 

// Open a multi-page PDF in Photoshop Layers
// Script opens every Page of the PDF single, Copies them into a Photoshop Layer and renames the Layer with the Document-Name
// which includes the Page Number
// Heike Herzog-Kuhnke 03/2014

// Starting:
// enable double clicking from the Macintosh Finder or the Windows Explorer
#target photoshop

// in case we double clicked the file
app.bringToFront();

// Don´t show Dialogs, if Photoshop likes to....
displayDialogs = DialogModes.NO;

// Variables. Needs to be Changed if you like to have something else
// Unfortunately, I couldn't find out how to locate the num of Pages of the PDF.
// MaxPages larger tan the reality is OK, must be numPages + 1 minimum
// Resolution and Document Mode as you need it
var myMaxPages = 100;
var myCounter = 1;
var myResolution = 300;
var myColor = OpenDocumentMode.CMYK;

//Set Background Color to white (not really needed...)
app.backgroundColor.rgb.red = 255;
app.backgroundColor.rgb.green = 255;
app.backgroundColor.rgb.blue = 255;

// Start Open Dialog. If you don`t choose a File with Ending .pdf the Script stops
var _pdfDatei = File.openDialog("Choose your Multipage-PDF-File");
var myDatei = "" + _pdfDatei;
var myEndung = myDatei.substr(myDatei.length - 4, 4);

if (myEndung !== ".pdf") {
    alert("No PDF choosen!\nStop Run!", "Error choosing File");
} else {
    // Here I start with defining the OpenOptions of the PDF for the first Page (Using the Variables from above)
    var pdfOpenOptions = new PDFOpenOptions;
    pdfOpenOptions.antiAlias = true;
    pdfOpenOptions.mode = myColor;
    pdfOpenOptions.bitsPerChannel = BitsPerChannelType.EIGHT;
    pdfOpenOptions.resolution = myResolution;
    pdfOpenOptions.supressWarnings = true;
    pdfOpenOptions.cropPage = CropToType.TRIMBOX;
    pdfOpenOptions.page = myCounter;

    // Opening the PDF
    open(_pdfDatei, pdfOpenOptions);
    // The Layer renamed by the Name of the Document
    var myDocument1 = app.activeDocument;
    var myLayerName = app.activeDocument.name;
    myDocument1.activeLayer.name = myLayerName + "_Page-" + myCounter; // original code modified
    whitePage(); // original code modified

    // Starting the Processing for the other pages
    // The Counter defines the Page Number. 
    // File will be Opened,, Layer copied, File Closes withsout saving, Paste in the first Document and renamed 
    // As long as pages are existing the Procedure runs until counter is 1 less to myMaxPages -Value
    // If there is an error (if the page doesnt exist) the Script stops and Says all done) 
    for (myCounter = 2; myCounter < myMaxPages; myCounter++) {
        // try / catch to resolve Problem with to many Pages in count
        // on Errors the counter will be set to Maximum Value to stop the for / next loop
        try {
            // PDF options
            pdfOpenOptions.page = myCounter;
            open(_pdfDatei, pdfOpenOptions);
            // Saving the new Document Name for the Layer Name
            myLayerName = app.activeDocument.name;
            app.activeDocument.activeLayer.name = myLayerName;
            app.activeDocument.selection.selectAll();
            app.activeDocument.selection.copy(true);
            app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
            app.activeDocument = myDocument1;
            myDocument1.paste();
            // Renaming the new Layer in first Document
            myDocument1.activeLayer.name = myLayerName + "_Page-" + myCounter; // original code modified
            whitePage(); // original code modified

        } catch (e) {
            alert("Done");
            myCounter = myMaxPages;
        }
    }
}

// original code mofified:
function whitePage() {
    var sel = activeDocument.selection;
    var fillColor = new SolidColor();
    fillColor.rgb.red = 255;
    fillColor.rgb.green = 255;
    fillColor.rgb.blue = 255;
    sel.fill(fillColor, ColorBlendMode.DARKEN, 100, false);
}

 

  1. Copy the code text to the clipboard
  2. Open a new blank file in a plain-text editor (not in a word processor)
  3. Paste the code in
  4. Save as a plain text format file – .txt
  5. Rename the saved file extension from .txt to .jsx
  6. Install or browse to the .jsx file to run (see below)

 

If these simple instructions are too abbreviated, you may need to read on:

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html#Photoshop

faustographic
Participant
January 23, 2023

Stephen, I just met you ... but ... do you feel my love?! Big THANKS!!!