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

Import a multipage-pdf in PS

Community Beginner ,
Jan 23, 2023 Jan 23, 2023

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

 

 

6.8K
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 , Jan 23, 2023 Jan 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
...
Translate
Adobe
Community Expert ,
Jan 23, 2023 Jan 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

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 ,
Jan 23, 2023 Jan 23, 2023

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

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
New Here ,
Apr 05, 2024 Apr 05, 2024

This script will be a real timesaver for me - thank you so much.

 

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 12, 2025 Mar 12, 2025
quote

This script will be a real timesaver for me - thank you so much.

 


By @Jonathan33602961t8pp

 

You're welcome, if you need to do the opposite and save a multi-layered file as a multi-page PDF direct from Photoshop:

 

https://community.adobe.com/t5/photoshop-ecosystem-ideas/new-feature-request-layers-to-pdf/idc-p/149...

 

Export Layers to Multipage PDF.png

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 15, 2025 Mar 15, 2025

Adding a user interface and other enhancements to the original 2014 script from Heike Herzog-Kuhnke:

 

PDF Pages to Layers.png

 

 

/*
PDF Pages To Layers ScriptUI.jsx
Stephen Marsh
v1.0 - 15th March 2025
https://community.adobe.com/t5/photoshop-ecosystem-discussions/import-a-multipage-pdf-in-ps/m-p/13512431
Based on the original script:
https://www.kuhnke-owl.de/index.php?id=48
https://www.kuhnke-owl.de/fileadmin/Downloads/MultipageLayers/pdf_pages_to_layers.zip
*/

#target photoshop;

// Save and set the dialog display settings
var savedDisplayDialogs = app.displayDialogs;
app.displayDialogs = DialogModes.NO;

// Set the variables
var theCounter = 1;
var docRes = 200;
var docColorMode = OpenDocumentMode.RGB;
var enableWhitePage = true;
var layerName = true;
var cropToType = CropToType.MEDIABOX;
var maxPageCount = 100;

// Create the UI
var mainWindow = new Window("dialog", "PDF Pages To Layers (v1.0)", undefined, { resizeable: false });
mainWindow.orientation = "column";
mainWindow.alignChildren = "fill";
mainWindow.preferredSize = [500, -1]; // Set window width to 500px

// Create a panel to contain the main content
var mainPanel = mainWindow.add("panel");
mainPanel.orientation = "column";
mainPanel.alignChildren = "left";
mainPanel.margins = 10;

// PDF file selection
var pdfGroup = mainPanel.add("group");
pdfGroup.orientation = "row";
var pdfButton = pdfGroup.add("button", undefined, "Select PDF");
var pdfPath = pdfGroup.add("statictext", undefined, 'No PDF file selected', { truncate: 'middle' });
pdfPath.preferredSize = [350, 20];

pdfButton.onClick = function () {
    var thePDF = File.openDialog("Select the Multi-page PDF File");
    if (thePDF) {
        pdfPath.text = thePDF.fsName;
    } else {
        //alert("No file selected.");
    }
}

// Document resolution field
var resGroup = mainPanel.add("group");
resGroup.orientation = "row";
resGroup.add("statictext", undefined, "Resolution (PPI):");
var resInput = resGroup.add("editnumber", undefined, docRes); // Use editnumber to restrict input to numbers
resInput.characters = 5;

// Document color mode dropdown list
var colorModeGroup = mainPanel.add("group");
colorModeGroup.orientation = "row";
colorModeGroup.add("statictext", undefined, "Color Mode:");
var colorModeDropdown = colorModeGroup.add("dropdownlist", undefined, ["RGB", "CMYK", "LAB", "GRAYSCALE"]);
colorModeDropdown.selection = 0; // Default to the first item in the array

// Crop page type dropdown list
var cropGroup = mainPanel.add("group");
cropGroup.orientation = "row";
cropGroup.add("statictext", undefined, "Crop To:");
var cropDropdown = cropGroup.add("dropdownlist", undefined, ["MEDIABOX", "CROPBOX", "BLEEDBOX", "TRIMBOX", "ARTBOX"]);
cropDropdown.selection = 0; // // Default to the first item in the array

// Enable White Page Checkbox
var whitePageGroup = mainPanel.add("group");
whitePageGroup.orientation = "row";
var whitePageCheckbox = whitePageGroup.add("checkbox", undefined, "Transparency to White");
whitePageCheckbox.value = enableWhitePage;
whitePageCheckbox.helpTip = "Create white pages";

// Get the current panel width to use as reference
var panelWidth = mainPanel.preferredSize.width;

// Create the group for the layer name checkbox
var layerNameGroup = mainPanel.add("group");
layerNameGroup.orientation = "row";
layerNameGroup.alignChildren = "fill";
layerNameGroup.alignment = ["fill", "top"];
layerNameGroup.margins = 0;
layerNameGroup.spacing = 0;

// Add the checkbox for the layer name
var layerNameCheckbox = layerNameGroup.add("checkbox", undefined);
layerNameCheckbox.alignment = ["fill", "center"];

// Set minimum width to prevent truncation
layerNameCheckbox.minimumSize.width = panelWidth - 30;
layerNameCheckbox.value = layerName;

// Add onClick event handler
layerNameCheckbox.onClick = function () {
    this.text = this.value ? "Layer Name: Page No. Only" : "Layer Name: Filename + Page No.";
}

// Set initial text based on default value
layerNameCheckbox.text = layerNameCheckbox.value ? "Layer Name: Page No. Only" : "Layer Name: Filename + Page No.";
layerNameCheckbox.helpTip = "Select the layer naming convention";

// Max Page Count field
var maxPageGroup = mainPanel.add("group");
maxPageGroup.orientation = "row";
maxPageGroup.add("statictext", undefined, "Max Page Count:");
var maxPageInput = maxPageGroup.add("editnumber", undefined, maxPageCount); // Use editnumber to restrict input to numbers
maxPageInput.characters = 5;
maxPageInput.helpTip = "Limit the opened pages";

// OK and Cancel Buttons
var buttonGroup = mainWindow.add("group");
buttonGroup.orientation = "row";
buttonGroup.alignment = "right";
var cancelButton = buttonGroup.add("button", undefined, "Cancel");
var okButton = buttonGroup.add("button", undefined, "OK");

// Handle OK button click
okButton.onClick = function () {
    docRes = parseInt(resInput.text);
    docColorMode = OpenDocumentMode[colorModeDropdown.selection.text];
    enableWhitePage = whitePageCheckbox.value;
    layerName = layerNameCheckbox.value;
    cropToType = CropToType[cropDropdown.selection.text];
    maxPageCount = parseInt(maxPageInput.text) + 2; // Add 2 to the max page count to account for the first page

    // Check if no PDF is selected
    if (pdfPath.text === "" || pdfPath.text === "No PDF file selected") {
        alert("Error: No PDF file selected!" + "\n" + "Please select a PDF file before proceeding.", "No PDF file selected");
        return; // Keep the dialog open
    }

    var thePDF = new File(pdfPath.text);
    var thePath = thePDF.fsName;
    var theExtension = thePath.match(/\.[^\.]+$/)[0];
    if (theExtension !== ".pdf") {
        alert("Error: No PDF file chosen!" + "\n" + "Please select a valid PDF file.", "Invalid File Type");
        return; // Keep the dialog open
    }

    processPDF(thePDF);
    mainWindow.close(); // Close the dialog only after successful validation
};

// Handle cancel button click
cancelButton.onClick = function () {
    mainWindow.close();
};

// Show the dialog
mainWindow.center();
mainWindow.show();

// Function to process the PDF
function processPDF(thePDF) {
    try {
        // Set the PDF open options
        var pdfOpenOptions = new PDFOpenOptions;
        pdfOpenOptions.antiAlias = true;
        pdfOpenOptions.mode = docColorMode;
        pdfOpenOptions.bitsPerChannel = BitsPerChannelType.EIGHT;
        pdfOpenOptions.resolution = docRes;
        pdfOpenOptions.suppressWarnings = true;
        pdfOpenOptions.cropPage = cropToType;
        pdfOpenOptions.page = theCounter;

        // Open the first page of the PDF
        open(thePDF, pdfOpenOptions);
        var theDoc = app.activeDocument;
        var myLayerName = app.activeDocument.name;
        if (layerName) {
            theDoc.activeLayer.name = " Page " + theCounter;
        } else {
            theDoc.activeLayer.name = myLayerName + " Page " + theCounter;
        }
        if (enableWhitePage) {
            whitePage();
        }

        // Loop through the remaining PDF pages
        for (theCounter = 2; theCounter < maxPageCount; theCounter++) {
            try {
                pdfOpenOptions.page = theCounter;
                open(thePDF, pdfOpenOptions);
                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 = theDoc;
                theDoc.paste();
                if (layerName) {
                    theDoc.activeLayer.name = " Page " + theCounter;
                } else {
                    theDoc.activeLayer.name = myLayerName + " Page " + theCounter;
                }
                if (enableWhitePage) {
                    whitePage();
                }
            } catch (error) { }
        }

        // End of script notification
        alert("Script completed with " + app.activeDocument.layers.length + " pages processed to layers!");

    } catch (error) {
        alert(error + ', Line: ' + error.line);
    } finally {
        // Reset the original dialog display
        app.displayDialogs = savedDisplayDialogs;
    }
}

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.MULTIPLY, 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)

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

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 ,
Jan 23, 2023 Jan 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

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 ,
Jan 23, 2023 Jan 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.

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
Participant ,
Mar 15, 2025 Mar 15, 2025
LATEST

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

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