Export specified pages as jpg at defined resolution

Hello inDesign Community -
I have a script that allows me to export pages specified from a dialog prompt as jpgs at a specific resolution (500px wide).
This is great for making thumbnails, however It uses the dimensions of the active document page to set the resolution formula.
This works unless there are different sized pages, at which point you get different sized jpg.
How can use the page dimensions of each page that is being exported individually.
I assume there is a way to get an array from jpegExportPreferences.pageString that can then be looped through.
Thanks in advance
// which pages to export
var pagesToExport
// final jpg demensions
var myLargeWidth = 500;
var myLargeHeight = 500;
// create a variable for current active document
var docRef = app.activeDocument;
// remove ententions from end of file path
myFilename = docRef.name.replace(/\.[^\.]+$/, '');
// set variable to save file in same directory as active document
myFolder = docRef.filePath;
// set document measurments to points and reset ruler orgin
docRef.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;
docRef.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;
docRef.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;
docRef.zeroPoint = [0,0];
//bounds    Array of Measurement Unit (Number or String)    readonly    The bounds of the Page, in the format [y1, x1, y2, x2].
// find width of page
var myCurrentWidth = app.activeWindow.activePage.bounds[3]-app.activeWindow.activePage.bounds[1];
// find height of page
var myCurrentHeight = app.activeWindow.activePage.bounds[2]-app.activeWindow.activePage.bounds[0];
function exportJPG() {
  // export large jpg
            if (myLargeWidth > 0) {
                // Calculate the scale percentage
                var myResizePercentage = myLargeWidth/myCurrentWidth;
                var myExportRes = myResizePercentage * 72;
                // exportResolution is only accurate to 1 decimal place, so round
            else {
                // Calculate the scale percentage
                var myResizePercentage = myLargeHeight/myCurrentHeight;
                var myExportRes = myResizePercentage * 72;
            // use caluclated percentage as resolution
            app.jpegExportPreferences.exportResolution = myExportRes;
            // export jpg in myfolder add .jpg to end.
            docRef.exportFile(ExportFormat.JPG, File(myFolder+"/"+myFilename+"-500px.jpg"));
            // reset back to inches
            docRef.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.inches;
            docRef.viewPreferences.verticalMeasurementUnits = MeasurementUnits.inches;
var myName = myInput ();
// rest of the script
function myInput ()
  var myWindow = new Window ("dialog", "Pages to export as JPG");
  var myCommentGroup = myWindow.add ("group");
  myCommentGroup.add ("statictext", undefined, "export some jpgs", {multiline:true});
  //myCommentGroup.maximumSize.width = 200;
  var myInputGroup = myWindow.add ("group");
  myInputGroup.add ("statictext", undefined, "Pages: (1-3,8,10)");
  var myText = myInputGroup.add ("edittext", undefined, "1");
  myText.characters = 20;
  myText.active = true;
  var myButtonGroup = myWindow.add ("group");
  myButtonGroup.alignment = "right";
  myButtonGroup.add ("button", undefined, "OK");
  myButtonGroup.add ("button", undefined, "Cancel");
  if (myWindow.show () == 1)
  return myText.text, pagesToExport = myText.text;
  else
  exit ();
// jpg export preferences
app.jpegExportPreferences.exportingSpread= false;
app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.HIGH;
app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.EXPORT_RANGE;
app.jpegExportPreferences.pageString = pagesToExport;
app.jpegExportPreferences.embedColorProfile = false;
app.jpegExportPreferences.jpegColorSpace= JpegColorSpaceEnum.RGB;
app.jpegExportPreferences.antiAlias = true;
exportJPG();
// run function

Hi,
1. You need to insert myCurrentWidth & Height calculation into function exportJPG() and execute it for each page;
2. This function supposes to be run with each chosen page and different exportPreferences;
3. So  you need split a string variable pageToExport into array collecting separate pages.
Like this:
// which pages to export
var pagesToExport;
// final jpg demensions
var myLargeWidth = 500;
var myLargeHeight = 500;
// create a variable for current active document
var docRef = app.activeDocument;
// remove ententions from end of file path
myFilename = docRef.name.replace(/\.[^\.]+$/, '');
// set variable to save file in same directory as active document
myFolder = docRef.filePath;
// set document measurments to points and reset ruler orgin
docRef.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;
docRef.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;
docRef.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;
docRef.zeroPoint = [0,0];
function exportJPG(cPage) {
// export large jpg
//bounds    Array of Measurement Unit (Number or String)    readonly    The bounds of the Page, in the format [y1, x1, y2, x2].
// find width of page
var myCurrentWidth = cPage.bounds[3]-cPage.bounds[1];
// find height of page
var myCurrentHeight = cPage.bounds[2]-cPage.bounds[0];
if (myLargeWidth > 0) {
// Calculate the scale percentage
var myResizePercentage = myLargeWidth/myCurrentWidth;
var myExportRes = myResizePercentage * 72;
// exportResolution is only accurate to 1 decimal place, so round
else {
// Calculate the scale percentage
var myResizePercentage = myLargeHeight/myCurrentHeight;
var myExportRes = myResizePercentage * 72;
// use caluclated percentage as resolution
app.jpegExportPreferences.exportResolution = myExportRes;
app.jpegExportPreferences.pageString = cPage.name;
// export jpg in myfolder add .jpg to end.
docRef.exportFile(ExportFormat.JPG, File(myFolder+"/"+myFilename + "_" + cPage.name + "-500px.jpg"));
// SUI Dialog      
myInput ();
// jpg export preferences
app.jpegExportPreferences.exportingSpread= false;
app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.HIGH;
app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.EXPORT_RANGE;
app.jpegExportPreferences.embedColorProfile = false;
app.jpegExportPreferences.jpegColorSpace= JpegColorSpaceEnum.RGB;
app.jpegExportPreferences.antiAlias = true;
// run function (loop through chosen pages)
var b, c, d, stop;
b = pagesToExport.split(",");
while (c = b.shift() ) {
  d = c.split("-");
  stop = parseInt(d[0]);
  while (stop <= parseInt(d[d.length-1]) ) {
       exportJPG(docRef.pages.item(stop-1));
       stop++;
// reset back to inches
docRef.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.inches;
docRef.viewPreferences.verticalMeasurementUnits = MeasurementUnits.inches;
// rest of the script
function myInput ()
  var myWindow = new Window ("dialog", "Pages to export as JPG");
  var myCommentGroup = myWindow.add ("group");
  myCommentGroup.add ("statictext", undefined, "export some jpgs", {multiline:true});
  //myCommentGroup.maximumSize.width = 200;
  var myInputGroup = myWindow.add ("group");
  myInputGroup.add ("statictext", undefined, "Pages: (1-3,8,10)");
  var myText = myInputGroup.add ("edittext", undefined, "1");
  myText.characters = 20;
  myText.active = true;
  var myButtonGroup = myWindow.add ("group");
  myButtonGroup.alignment = "right";
  myButtonGroup.add ("button", undefined, "OK");
  myButtonGroup.add ("button", undefined, "Cancel");
  if (myWindow.show () == 1)
  return pagesToExport = myText.text;
  else
  exit ();
Notice that different page sizes can lead to different width/height proportions.
In this case JPGs will still differ. (by height)
Jarek

Similar Messages

  • Export current page to JGB with no confirmation?

    Hello,
    I'd like a script to export just the current page as a JPG to my desktop, with specific spec, without confirmation, with an automated filename (filename+date+time+".jpg").
    I've found one or two that export all pages, or have other needs, but nothing like this.
    My remote bosses like to see quick shots of pages I'm working on, but as they print a lot of them I'd like higher resolution than screen shots, which is how I'm doing it now. I can go the normal File>Export route, but that's too painful for the frequency and speed I need to fire these out. I just want to hit a keystroke which fires the script which results in a JPG on the desktop for me to jam into iChat.
    It would be too much to ask to have a keyline around the page, I suppose? Do dreams come true?
    I'm on CS5.5.
    Thank you for any help!

    Adjust "Export JPEG" options according to your needs (see comments).
    /* Copyright 2013, Kasyan Servetsky
    July 27, 2013
    Written by Kasyan Servetsky
    http://www.kasyan.ho.com.ua
    e-mail: [email protected] */
    //======================================================================================
    var scriptName = "Export current page to JPG - 1.0";
    Main();
    //===================================== FUNCTIONS  ======================================
    function Main() {
        if (app.documents.length == 0) ErrorExit("Please open a document and try again.", true);
        var doc = app.activeDocument;
        if (app.activeWindow.constructor.name != "LayoutWindow") ErrorExit("Unable to get page number. Quit story editor.", true);
        var page = app.activeWindow.activePage;
        with (app.jpegExportPreferences) {
            exportingSpread = false;
            jpegExportRange = ExportRangeOrAllPages.EXPORT_RANGE;
            pageString = page.name;
            exportResolution = 300; // The export resolution expressed as a real number instead of an integer. (Range: 1.0 to 2400.0)
            antiAlias = true; //  If true, use anti-aliasing for text and vectors during export
            embedColorProfile = false; // True to embed the color profile, false otherwise
            jpegColorSpace = JpegColorSpaceEnum.RGB; // One of RGB, CMYK or GRAY
            jpegQuality = JPEGOptionsQuality.HIGH; // The compression quality: LOW / MEDIUM / HIGH / MAXIMUM
            jpegRenderingStyle = JPEGOptionsFormat.BASELINE_ENCODING; // The rendering style: BASELINE_ENCODING or PROGRESSIVE_ENCODING
            simulateOverprint = false; // If true, simulates the effects of overprinting spot and process colors in the same way they would occur when printing
            useDocumentBleeds = false; // If true, uses the document's bleed settings in the exported JPEG.
        var fileName = doc.name.replace(/\.indd$/, "") + "_" + GetDate() + ".jpg";
        var file = new File("~/Desktop/" + fileName);
        doc.exportFile(ExportFormat.JPG, file);
    function GetDate() {
        var date = new Date();
        if ((date.getYear() - 100) < 10) {
            var year = "0" + new String((date.getYear() - 100));
        else {
            var year = new String((date.getYear() - 100));
        var dateString = (date.getMonth() + 1) + "-" + date.getDate() + "-" + year + "_" + date.getHours() + "-" + date.getMinutes() + "-" + date.getSeconds();
        return dateString;
    function ErrorExit(error, icon) {
        alert(error, scriptName, icon);
        exit();

  • Can I use preview to export multiple page PDF as jpegs?

    Using Preview, I export multiple page PDF as jpeg and results are the first page only as jpeg. Can I use preview to export multiple page PDF as jpeg for every page?

    Automator is great for this if you need to export many pages to JPG, or just have to do this often.
    Two other quick and dirty way sto get it done:
    (1) Enable thumbnail view, click on the ONE PAGE you want to convert to jpg, then choose "export." If you choose more than one page, only the first will get exported to jpg.
    (2) Create a copy of the file, delete all the pages except the one you want to export to JPG, and export that page. You may be able to "undo" the delete, get all your pages back again, and re-delete all but the one you want to export, etc. I would not recommend doing this on the original version of the file because of Preview's autosave so-called "feature."

  • Exporting book pages one at a time

    When I create a photobook I need to see them in JPG so I export the pages as jpg. My problem is that I can only export all the pages which takes a long time. If I find a mistake on one page which I correct in LR there is no way to export just that one page to replace the old one. (at least I can't find this)

    You could add it as a feature request at Official Feature Request/Bug Report Forum

  • Can I export the pages of a book created in Aperture

    I would lioke to export the pages of a book created in Aperture so I can import them to get the book published. Is it possible to export hte pages as jpg images? When I save it as a pdf, the whole book is one file.

    What is your Aperture version? In my version (Aperture 3.4.3) I can do the following:
    Print the book to pdf, by selecting the book in the Inspector panel and using
         File > Print Book
    In the "Print" panel I press the "pdf" button and select "Save PDF as folder to jpeg".
    This will create a folder of jpegs, one for each page.
    Regards
    Léonie

  • I am exporting a Pages document to Epub and Pages is compressing my jpg images.  How do I keep the original jpg size during the export to epub process?

    I am exporting a Pages document to Epub and Pages is compressing my jpg images (I think to 72 dpi from original 600 dpi). 
    How do I keep the original jpg size during the export to epub process?

    We are still trying learn how to use Pages to build ePub documents with high resolution graphics that will expand clearly when they are tapped. Very large screen shots are my example here.

  • Specifying page range

    Ok trying to merge some templates and scripts I have to one export an .indd file would like different options per page(s).
    Here's what I currently have, that I would like to change to specify pages 1-13:
    var myPageName, myFilePath, myFile;
    var myDocument = app.documents.item(0);
    var myBaseName = myDocument.name;
    for(var myCounter = 0; myCounter < myDocument.pages.length; myCounter++){
    myPageName = myDocument.pages.item(myCounter).name;
    app.pdfExportPreferences.pageRange = myPageName;
    and also have export as:
    myFilePath = dirPath + docType + "/" + fileName;
    myFile = new File(myFilePath);
    myDocument.exportFile(ExportFormat.pdfType, myFile, false);
    Here's is another script, that I would like to change to specify pages 14-17:
    var myPageName, myFilePath, myFile;
    var myDocument = app.documents.item(0);
    var myBaseName = myDocument.name;
    for(var myCounter = 0; myCounter < myDocument.pages.length; myCounter++){
    myPageName = myDocument.pages.item(myCounter).name;
    app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange;
    app.jpegExportPreferences.exportResolution = 96;
       app.jpegExportPreferences.pageString = myPageName; 
    and also have export as:
    myDocument.exportFile(ExportFormat.jpg, File(myFilePath), false);
    So how can I specify some pages to export as .pdf and some others to export as .jpg with a dpi. of 96?
    Thanks in advance,
    Joe

    Fixed it here it is:
       app.jpegExportPreferences.pageString = myPageName, "14-17"; 

  • Exported PDF page size too large on screen

    Fairly new to InDesign ( and loving it )
    I am creating a document using InDesign v5. which has a page size of 8.5 x 11 in and two pages to a spread.
    When I export a page or a spread to PDF the page or spread will print fine BUT when I view this PDF on screen at 100% the size is quite a bit larger than 8.5 x 11 in
    can anyone explain why and how I can view the file at 100% on screen AND at the correct printing size.
    Thanks for any help you can offer.
    Graham

    Try this in Acrobat.
    Edit > Preferences (Win) or Acrobat > Preferences (Mac). Then select Page Display > Resolution > Use System Setting

  • Export Indd to EPS/JPG and set the file name  for EPS/JPG file

    Hi,
       When I export the INDD to JPG/EPS, I want to set the file name with pageNumber  for JPG/EPS files using javascript.
    For Example
    If I set the file name as EPSFile.eps, after exporting the indd(with 2 pages) to eps
    ,files are generating in the following name EPSFile_1.eps, EPSFile_2.eps.
    but I want to set the file name as EPSFile_001.eps and EPSFile_002.eps using javascript.
    anyone knows please reply for this.
    Regards,
    Mubeen

    Hi,
      I tried the following code.
    var JPGe = new File("Applications/PDF/JPG/file.jp");
    app.activeDocument.exportFile(ExportFormat.jpg, );
    when I use this code ,exported jpg file names are
    file.jpg, file1.jpg,file3.jpg.
    but ,I want the output file names as file_001,file_002,file_003,
    Thanks,
    Mubeen

  • Possible to export a page as sRGB PDF?

    We have a client submitting PDF files to us for conversion to an image-based online (Web) reader. Our software is designed to convert only from PDF. This one client's magazine has sometimes shown poor quality after conversion, and we're not sure why. Hundreds of other magazines and only this one has trouble. We think it's their InDesign settings, but their graphic designer is relatively new. Our production manager did some research (none of us is InDesign-saavy) and decided the PDFs need to be in sRGB color instead of CMYK. Our manager used Acrobat Pro to convert some of their pages and then got better results after running them through our software. But he doesn't want to manually convert all of their PDFs with Acrobat and then have to charge the client for custom work. Problem is, when we open our only copy of InDesign, it appears the only way to get sRGB output is to output the pages as JPG files. Tips?

    When you export set the Output panel to something like this. Set compatibility to 1.3 if you need a flattened PDF.

  • Export multiple pages in InDesign...

    Did anyone try to export for print (this means with all the bleeds, marks, color coding, etc etc...) an entire magazine into single pages?
    I found various solutions but non are realistic. I shoot with a D800e and D810 (this means massive 36 megapixel files) and each page can contain up to 10 or more images making each page incredibly heavy! (why am I telling you this?) one of the solutions is to export the entire document in one single pdf and then extract each page from Acrobat X ... this is obviously impossible for the massive amount of data.
    So my question is can I export the whole magazine in one shot into single files? or I'm doomed to export single pages each time
    Thanks
    Sergio

    Hello Peter,
    I shoot with a 36Mp camera because not all the times you'll be using the whole image. Many times there is a crop of that image and obviously it has been compressed and cut (using a full size image has no sense) The final file 1:1 is 300Dpi and to reply to  Dov, yes the export is done correctly in JPEG.
    But this is not the point... let's make an example. a magazine 250 pages, all done (images, text, etc etc) is ready for the printer that requires single pages with bleed and slug (markers etc etc) imagine that the pages can contain up to 5 images each (this means something close to 1200 images) is there a way to export each single page separately with one command? If you ever exported in jpeg directly from ID (to create a file to view or send in email for approval as an example...not related to print!) you'll see that ID creates separate files for each page (obviously no JPG contains more pages) but I know that there's a script that allows the same thing in ID. It will export the whole file with multiple pages in single PDFs.
    Thank you Peter and Dov for your kindness and for your time

  • Convert pdf pages to jpg files

    How can I export all pages of a pdf to jpg files? Acrobat sucks because it doesn't anti alias text. In Photoshop I have to first open all pages of a pdf file into seperate image files. Then I have to save as jpg each file one by one. I can't think of a batch action cause it wouldn't know how many pages the pdf is. Indesign fails also: I can make a book file of all the individual indesign files, but it only exports the book file as one pdf. There isnt a save book as jpg files option.
    Photoshop is my best option, but is there a way to let it export all pages of a pdf file to separate jpg files?

    I can't think of a batch action cause it wouldn't know how many pages the pdf is.
    You touch on a relevant matter there; the page-count information can even vary depending on the way a pdf was created.
    Still a Script should be able to handle that, if need be by utilizing a try-clause.
    So you could ask in the Photoshop Scripting Forum if no one else has a better idea.

  • Exporting transparent pages for the iPad

    Confusing.
    Baffled.
    So bear with me as I attempt to explain what I'm so earnestly trying to figure out is even possible; and if so, how to do it..
    I'm attempting to export an epub for the iPad that contains images [without a background] from Photoshop. In Photoshop, the layers build on top of one another. (Think of physical transparencies printed out with different images and as they stack on top of one another they build a conglomerate image)
    So in theory, I want to export these pages from InDesign as transparencies, that when the page is turned on the iPad, you can see through it as the images stack on top of one another.
    It seems confusing to me because of the front and back of each page in InDesign.. It's like dealing with two pages instead of one. For example, in a facing pages layout, if I had an image on the 3rd page [lets imagine that's on the right in the layout], would the 4th page [on the left] be showing the transparent side of the 3rd page? I just want it to be read as a literal transparent page [the 3rd and 4th page conglomerate] that you can see through to the 5th.
    Is this possible? Do I need to set a certain transparency option in InDesign when I export?
    Or is this just not feasible..
    Please help.
    I'm lost.
    Thank you

    You're saying you want your epub to look as if it's printed on transparent acetate? I don't do epub, myself, but I don't think that's going to happen.If it were possible, you'd have to specify an opaque page (the equivalent of a piece of white paper) for all "normal" pages to keep them readable, and that's just something ID is not set up to do.
    ID simply doesn't care what sort of stock you print on. What is on the page is what will output to the medium on which your doc is printed (ID is first and foremost an application designed to make layouts for print). Nothing is genreated in terms of background other than what you yourself might add. A PDF is theoretically has no additional white background, but Acrobat displays one so your desktop doesn't show through. I imagine the same thing happens with epub readers. If no background is specified, the reader provides something.

  • How to improve quality of pdfs when exporting from pages?

    how to improve quality of pdfs when exporting from pages? Any suggestions?

    Print to pdf and don't use anything with transparency.
    Have you ensured all your images are actually high enough resolution for whatever purpose (which you haven't said) you want?
    Peter

  • Export all pages to dreamweaver

    Can you export all pages you have made in Fireworks CS4 to
    Dreamweaver at the same time, and if yes, how?
    / Lena

    Lena, resolution of your document makes a huge difference
    when printing. I'm guessing here, but are you using a resolution of
    72 dpi? If so, that won't look very good when printed (that
    includes 'printing' to a .pdf file) A resolution that low will only
    look good on screen. If you must print and have it look good,
    you'll need to use a higher resolution.
    Jim

Maybe you are looking for

  • Help: document migration RPM 4.5 to PPM 5.0

    Hello, I am looking for a solution regarding the document migration from RPM 4.5 to PPM 5.0 (document stored in a DMS Sap content server). Manually I have no problem for creating documents in PPM (config ok) but given the fact that I have a large num

  • Setting default unconditional mode(s) for a specific SID in TMS

    I am working in ECC 5.0, and I'm trying to configure one of the systems in our TMS landscape to use a specific unconditional mode (u2) by default.  Does anyone know a method by which I can set this in the TMS configuration?  I was looking at paramete

  • Arch and Slack - What's the difference?

    I'm from the Ubuntu camp.  I've been using Linux for close to three years now and getting bored.  I desperately need something more complicated. My question is - what's the difference between Arch and Slackware?  I've used Slackware in the past.  I a

  • Photos not printing

    I have a HP Deskjet 3000 wireless printer,  it will not print photos from my pc but  it will print word documents ok, I have other computers on my network and I can print a photo from another computer on the network. The Scan and Print Doctor cannot

  • WebAPI question about Hierarchy modeling

    Hi all, I have come to a issue about Hierarchy modeling. I want to use WebAPI to drill down the query in the visual composer. And I have follow every steps mentioned in this PDF file </people/prakash.darji/blog/2006/08/24/overcome-limitations-around-