Skip to main content
Known Participant
March 21, 2012
Question

Strange behaviour when scaling GREP styled text.

  • March 21, 2012
  • 3 replies
  • 2590 views

In the quest for the perfect scaling script I am running into another problem. I tried to scale my GREP styled text, and it came out like this:

Notice the "$" and "cents" are too small - whereas it should look like this:

Sorry I used a slightly larger image and different value, but I don't that is an issue with respect to this problem.

So on the desktop, I decide to check preference>general tab> when scaling> "apply to content" was checked.

I changed it to "adjust scaling percentage" and my $249.99 came out perfectly proportional to the original set text, (let pretend there is a 2 in front of the $49.99)

So I upload the template to the server and proceed to scale it and I get this:

In this example, the decimal has not scaled and thus allowing the "cents" to jam into the dolllar value. I am also unable to reproduce this error on the desktop.

Can anyone explain what is happening or how to compensate for these errors? Thanks for your help! My script is below:

function myTransform(myPage, myRectangle, myScaleMatrix)

{

     app.transformPreferences.whenScaling = WhenScalingOptions.APPLY_TO_CONTENT;

   

    var everything;

    var origin;

   

    if ( ssize > 1.0 )

    {

       //origin = myPage.resolve(AnchorPoint.CENTER_ANCHOR,CoordinateSpaces.PASTEBOARD_COORDINATES)[0];

       origin = myPage.resolve(AnchorPoint.CENTER_ANCHOR,CoordinateSpaces.PASTEBOARD_COORDINATES);

        myPage.transform(CoordinateSpaces.PASTEBOARD_COORDINATES,origin,myScaleMatrix);

        everything = myRectangle.everyItem();

        //origin = myPage.resolve(AnchorPoint.CENTER_ANCHOR,CoordinateSpaces.PASTEBOARD_COORDINATES)[0];

        everything.transform(CoordinateSpaces.PASTEBOARD_COORDINATES,origin,myScaleMatrix);

     }

    else

    {

        everything = myRectangle.everyItem();

        origin = myPage.resolve(AnchorPoint.CENTER_ANCHOR,CoordinateSpaces.PASTEBOARD_COORDINATES)[0];

        everything.transform(CoordinateSpaces.PASTEBOARD_COORDINATES,origin,myScaleMatrix);

        myPage.transform(CoordinateSpaces.PASTEBOARD_COORDINATES,origin,myScaleMatrix);

    }

}

This topic has been closed for replies.

3 replies

Known Participant
March 30, 2012

I will have to collect everything from my multiple posts on scaling scripts into one cohesive document when I am done.

It was brought to my attention that my bleeds are now off. I have it set in the script to use the document bleed settings but they seem to get ignored. I will set them implicitly and see if that has any affect.

The art is scaling so a 10"x10" with .125" bleeded gets scaled up to 20.5"x20.5" pdf document with no bleed box.

I would love a week long organized class in all things InDesign Scripting.

Inspiring
March 30, 2012

I tried to reproduce your issue on InDesign Server CS5 7.0.4 (Mac) but could not. The period scaled from 25pt to 50pt as expected:

I did have to change your script so that whenScaling was APPLY_TO_CONTENT for the page transform and ADJUST_SCALING_PERCENTAGE for the page item transform:

var myDocument = app.open(new File("~/Desktop/grep_scaling_test1.indd"));

var myPages = myDocument.pages;

var myRectangle = myDocument.pages.item(0).pageItems;

var ssize = 2;

//Scale a page around its center point.

var myScaleMatrix = app.transformationMatrices.add({horizontalScaleFactor:ssize,  verticalScaleFactor:ssize});

var idx;

for(idx = 0; idx < app.documents.item(0).pages.length; idx++)

{

    myTransform(myPages.item(idx), myDocument.pages.item(idx).pageItems, myScaleMatrix);

}

// if you want to export a pdf, uncomment

//myPDFExport ();

function myTransform(myPage, myRectangle, myScaleMatrix)

{

    var everything;

    var origin;

    if ( ssize > 1.0 )

    {

       //origin = myPage.resolve(AnchorPoint.CENTER_ANCHOR,CoordinateSpaces.PASTEBOARD_COORDINATES)[0];

       origin = myPage.resolve(AnchorPoint.CENTER_ANCHOR,CoordinateSpaces.PASTEBOARD_COORDINATES);

        app.transformPreferences.whenScaling = WhenScalingOptions.APPLY_TO_CONTENT;

        myPage.transform(CoordinateSpaces.PASTEBOARD_COORDINATES,origin,myScaleMatrix);

        everything = myRectangle.everyItem();

        //origin = myPage.resolve(AnchorPoint.CENTER_ANCHOR,CoordinateSpaces.PASTEBOARD_COORDINATES)[0];

         app.transformPreferences.whenScaling = WhenScalingOptions.ADJUST_SCALING_PERCENTAGE;

        everything.transform(CoordinateSpaces.PASTEBOARD_COORDINATES,origin,myScaleMatrix);

     }

    else

    {

        everything = myRectangle.everyItem();

        origin = myPage.resolve(AnchorPoint.CENTER_ANCHOR,CoordinateSpaces.PASTEBOARD_COORDINATES)[0];

         app.transformPreferences.whenScaling = WhenScalingOptions.ADJUST_SCALING_PERCENTAGE;

        everything.transform(CoordinateSpaces.PASTEBOARD_COORDINATES,origin,myScaleMatrix);

        app.transformPreferences.whenScaling = WhenScalingOptions.APPLY_TO_CONTENT;       

        myPage.transform(CoordinateSpaces.PASTEBOARD_COORDINATES,origin,myScaleMatrix);

    }

}

myDocument.exportFile(ExportFormat.PDF_TYPE, new File("~/Desktop/grep_scaling_test1 new.pdf"));

myDocument = myDocument.save(new File("~/Desktop/grep_scaling_test1 new.indd"));

myDocument.close();

Sorry. I did notice from the missing plug-in warning that maybe you are using XMPie, and perhaps this script is run in some larger context? Maybe you should talk to XMPie.

Known Participant
March 30, 2012

Thanks! I wish there was more documentation that you can set those transformPreferences.whenScaling multiple times as you did, I would have assumed it was an either or as the UI only gives you radio buttons.. It's true we are using XMPie and I will test this on Monday but it so far it seemed to do the job. Thank you very much!

Bob

Known Participant
March 29, 2012

if anyone wants a test file I can email them, unless there is someway to upload here that I am missing. . .

Inspiring
March 29, 2012

You can send it to the address in my profile if you'd like, though it'll likely be a day or two until I can test it.

(You could also get a free Dropbox or similar account and provide a link from there.)

Known Participant
March 30, 2012
Known Participant
March 22, 2012

60 views and no response? Is this that ugly? Perhaps this is a bug?

Inspiring
March 22, 2012

Grep styles seem to be applied as kind of a gloss or something over the underlying text properties and don't work the same way as other styles do—multiple styles can be applied to the same character, for instance, and they don't start new textStyleRanges—so it doesn't really surprise me that they don't work as you would like with WhenScalingOptions.APPLY_TO_CONTENT (though I think they should).

The grep-styled period not scaling with WhenScalingOptions.ADJUST_SCALING_PERCENTAGE in InDesign Server is interesting and doesn't make sense. I'd be willing to test it for you on my CS5 Server if you could provide a complete script free of extraneous stuff—one where I had only to change paths to run it here—that demonstrates the problem, and doesn't do anything else. (It may be that the process of reducing your script to this test case leads you to the answer, as I suspect there's something going on elsewhere in your script that's causing this.) If you do post such a reduced, complete script, please click "Use advanced editor" and then format your code with "Syntax Highlighting=>Java".

To really allow others to try to replicate the problem, you should also provide a link to download the document you're acting on. Otherwise you're asking us to guess at the regular expressions and character styles you're using in your grep styles, which is a pain and might allow the source of your very specific problem to slip by.

Jeff

Known Participant
March 22, 2012

var myDocument = app.documents.item(0);

var myPages = myDocument.pages;

var myRectangle = myDocument.pages.item(0).pageItems;

var ssize = 2;

//Scale a page around its center point.

var myScaleMatrix = app.transformationMatrices.add({horizontalScaleFactor:ssize,  verticalScaleFactor:ssize});

var idx;

for(idx = 0; idx < app.documents.item(0).pages.length; idx++)

{

    myTransform(myPages.item(idx), myDocument.pages.item(idx).pageItems, myScaleMatrix);

}

// if you want to export a pdf, uncomment

//myPDFExport ();

function myTransform(myPage, myRectangle, myScaleMatrix)

{

     app.transformPreferences.whenScaling = WhenScalingOptions.APPLY_TO_CONTENT;

   

    var everything;

    var origin;

   

    if ( ssize > 1.0 )

    {

       //origin = myPage.resolve(AnchorPoint.CENTER_ANCHOR,CoordinateSpaces.PASTEBOARD_COORDINATES)[0];

       origin = myPage.resolve(AnchorPoint.CENTER_ANCHOR,CoordinateSpaces.PASTEBOARD_COORDINATES);

        myPage.transform(CoordinateSpaces.PASTEBOARD_COORDINATES,origin,myScaleMatrix);

        everything = myRectangle.everyItem();

        //origin = myPage.resolve(AnchorPoint.CENTER_ANCHOR,CoordinateSpaces.PASTEBOARD_COORDINATES)[0];

        everything.transform(CoordinateSpaces.PASTEBOARD_COORDINATES,origin,myScaleMatrix);

     }

    else

    {

        everything = myRectangle.everyItem();

        origin = myPage.resolve(AnchorPoint.CENTER_ANCHOR,CoordinateSpaces.PASTEBOARD_COORDINATES)[0];

        everything.transform(CoordinateSpaces.PASTEBOARD_COORDINATES,origin,myScaleMatrix);

        myPage.transform(CoordinateSpaces.PASTEBOARD_COORDINATES,origin,myScaleMatrix);

    }

}

function myPDFExport()

{

        //Basic PDF output options.

        pageRange = PageRange.allPages;

        acrobatCompatibility = AcrobatCompatibility.acrobat8;

        exportGuidesAndGrids = false;

        exportLayers = false;

        exportNonPrintingObjects = false;

        exportReaderSpreads = false;

        generateThumbnails = false;

       

        try

        {

            ignoreSpreadOverrides = false;

        }

        catch(e) {}

       

        includeBookmarks = false;

        includeHyperlinks = false;

        includeICCProfiles = true;

        includeSlugWithPDF = true;

        includeStructure = false;

        interactiveElementsOption = InteractiveElementsOptions.doNotInclude;

       

        //Setting subsetFontsBelow to zero disallows font subsetting;

        //set subsetFontsBelow to some other value to use font subsetting.

        subsetFontsBelow = 0;

        //Bitmap compression/sampling/quality options.

        colorBitmapCompression = BitmapCompression.none;

        //colorBitmapQuality = CompressionQuality.eightBit;

        colorBitmapSampling = Sampling.none;

        //thresholdToCompressColor is not needed in this example.

        //colorBitmapSamplingDPI is not needed when colorBitmapSampling

        //is set to none.

        grayscaleBitmapCompression = BitmapCompression.none;

        //grayscaleBitmapQuality = CompressionQuality.eightBit;

        grayscaleBitmapSampling = Sampling.none;

        //thresholdToCompressGray is not needed in this example.

        //grayscaleBitmapSamplingDPI is not needed when grayscaleBitmapSampling

        //is set to none.

        monochromeBitmapCompression = BitmapCompression.none;

        monochromeBitmapSampling = Sampling.none;

        //thresholdToCompressMonochrome is not needed in this example.

        //monochromeBitmapSamplingDPI is not needed when

        //monochromeBitmapSampling is set to none.

        //

        //Other compression options.

        compressionType = PDFCompressionType.compressNone;

        compressTextAndLineArt = true;

        cropImagesToFrames = true;

        optimizePDF = true;

       

        //Printers marks and prepress options.

        //Get the bleed amounts from the document's bleed.

//~         bleedBottom = myDocument.documentPreferences.documentBleedBottomOffset;

//~         bleedTop = myDocument.documentPreferences.documentBleedTopOffset;

//~         bleedInside = myDocument.documentPreferences.documentBleedInsideOrLeftOffset;

//~         bleedOutside = myDocument.documentPreferences.documentBleedOutsideOrRightOffset;

//~         //If any bleed area is greater than zero, then export the bleed marks.

//~         if(bleedBottom == 0 && bleedTop == 0 && bleedInside == 0 && bleedOutside == 0)

//~         {

//~             bleedMarks = true;

//~         }

//~         else

//~        {

//~             bleedMarks = false;

//~        }

//~        colorBars = false;

        colorTileSize = 128;

        grayTileSize = 128;

        cropMarks = false;

        omitBitmaps = false;

        omitEPS = false;

        omitPDF = false;

        pageInformationMarks = false;

        pdfColorSpace = PDFColorSpace.unchangedColorSpace;

        //Default mark type.

        pdfMarkType = 1147563124;

        printerMarkWeight = PDFMarkWeight.p125pt;

        registrationMarks = false;

        try

        {

            simulateOverprint = false;

        }

        catch(e) {}

       

        useDocumentBleedWithPDF = false;

       

        viewPDF = false;

    //Now export the document.

    var thisDocument = app.documents.item(app.documents.length-1);

    var fullname = app.scriptArgs.getValue("OutputFileName");

    var idx = fullname.indexOf("_");

    var shortname = fullname.substring(0, idx);

    //thisDocument.exportFile(ExportFormat.pdfType, app.scriptArgs.getValue("OutputFolder") + shortname + ".pdf");

    thisDocument.exportFile(ExportFormat.pdfType, "c:\boosttest.pdf");

}