-
-
Save cg-method/9350adb247e36175984e642e7b5b8ee7 to your computer and use it in GitHub Desktop.
【Photoshop】複数のPDFをまとめれレイヤーで読み込むスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Open a multipage PDF in Photoshop Layers | |
// Script opens every Page of the PDF single, Copys them intor 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 | |
// Unfortunally I couldnt 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; | |
// 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 Mximum 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; | |
} | |
catch (e) { | |
alert("Done"); | |
myCounter = myMaxPages; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment