Solved: Re: Create a single tall image from a multi

您所在的位置:网站首页 《满江红》朗诵稿件图片大全 Solved: Re: Create a single tall image from a multi

Solved: Re: Create a single tall image from a multi

2023-04-20 23:47| 来源: 网络整理| 查看: 265

Well, the Script actually operates based on an unjustified assumption anyway, namely that all pages in the pdf are of the same dimensions.

But editing pdfs in Photoshop is problematic in general, as vector and type content is rasterized.

Try this:

// opens all pages of pdfs cropped to trimbox with set settings and arranges them;

// 2011, use it at your own risk;

#target photoshop

// dialog for pdf-selection;

var theFiles = app.openDialog();

if (theFiles) {

     for (var m = 0; m < theFiles.length; m++) {

          var theFile = theFiles;

          if (theFile.name.slice(-4) == ".pdf") {

               var thePdf = openMultipagePDF(theFile);

               }

          else {alert (theFile.name + " is not a pdf-file")}

          }

     };

////// function to open all pages of a pdf //////

////// influenced by PlaceMultipagePDF.jsx //////

function openMultipagePDF(myPDFFile) {

// pdf open options;

     var pdfOpenOpts = new PDFOpenOptions;

     pdfOpenOpts.antiAlias = true;

     pdfOpenOpts.bitsPerChannel = BitsPerChannelType.EIGHT;

     pdfOpenOpts.cropPage = CropToType.TRIMBOX;

     pdfOpenOpts.mode = OpenDocumentMode.CMYK;

     pdfOpenOpts.resolution = 150;

     pdfOpenOpts.suppressWarnings = true;

     pdfOpenOpts.usePageNumber  = true;

// change pref;

     var originalRulerUnits = app.preferences.rulerUnits;

     app.preferences.rulerUnits = Units.PIXELS;

// suppress dialogs;

     var theDialogSettings = app.displayDialogs;

     app.displayDialogs = DialogModes.NO;

// iterate through pages until fail;

     var myCounter = 1;

     var myBreak = false;

     var theWidth = 0;

     var theHeight = 0;

     while(myBreak == false){

          pdfOpenOpts.page = myCounter;

          try {

               var thePdf = app.open(myPDFFile, pdfOpenOpts);

               if (thePdf.width > theWidth) {theWidth = thePdf.width};

               var offset = thePdf.height;

               thePdf.layers[0].name = myPDFFile.name+"_"+myCounter;

               if (myCounter == 1) {

                    var theFile = thePdf

                    }

               else {

                    thePdf.layers[0].duplicate(theFile, ElementPlacement.PLACEATBEGINNING);

                    thePdf.close(SaveOptions.DONOTSAVECHANGES)

                    };

               myCounter = myCounter + 1;

               var theLayer = app.activeDocument.activeLayer;

               theLayer.translate(0, theHeight);

               theHeight = theHeight + offset;

               }

          catch (e) {myBreak = true};

          };

// reset dialogmodes;

     app.displayDialogs = DialogModes.ERROR;

     app.preferences.rulerUnits = originalRulerUnits;

// resize canvas;

     theFile.resizeCanvas(theWidth, theHeight, AnchorPosition.TOPLEFT);

// add white layer;

     var white = new SolidColor;

     white.hsb.hue = 0;

     white.hsb.saturation = 0;

     white.hsb.brightness = 100;

     var bgLayer = theFile.artLayers.add();

     bgLayer.move(theFile, ElementPlacement.PLACEATEND);

     theFile.selection.selectAll();

     theFile.selection.fill(white);

     theFile.selection.deselect();

     bgLayer.name = "background";

// save psd;

     psdOpts = new PhotoshopSaveOptions();

     psdOpts.embedColorProfile = true;

     psdOpts.alphaChannels = false;

     psdOpts.layers = true;

     psdOpts.spotColors = false;

     var filePath = myPDFFile.path+"/"+myPDFFile.name.slice(0, -4)+".psd";

     if (File(filePath).exists == true) {

          var theConfirmation = confirm("overwrite existing file" + filePath + "?");

          if (theConfirmation == true) {theFile.saveAs(File(filePath), psdOpts, false)}

          else {};

          }

     else {theFile.saveAs(File(filePath), psdOpts, false)};

     return theFile

     };



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3