Skip navigation
bobhopfner
Currently Being Moderated

Strange behaviour when scaling GREP styled text.

Mar 21, 2012 8:54 AM

Tags: #cs5 #scaling #script #javascript #indesign #indesign_cs5 #grep #up-scaling

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:

 

price_error_1.jpg

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

 

price_error_3.jpg

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:

 

price_error_2.jpg

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,mySca leMatrix);

        everything = myRectangle.everyItem();

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

        everything.transform(CoordinateSpaces.PASTEBOARD_COORDINATES,origin,m yScaleMatrix);

     }

    else

    {

        everything = myRectangle.everyItem();

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

        everything.transform(CoordinateSpaces.PASTEBOARD_COORDINATES,origin,m yScaleMatrix);

        myPage.transform(CoordinateSpaces.PASTEBOARD_COORDINATES,origin,mySca leMatrix);

    }

}

 
Replies
  • Currently Being Moderated
    Mar 22, 2012 7:30 AM   in reply to bobhopfner

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 29, 2012 10:27 AM   in reply to bobhopfner

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

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 30, 2012 12:57 PM   in reply to bobhopfner

    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:

     

    Screen shot 2012-03-30 at 2.56.42 PM.PNG

     

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 31, 2012 12:58 AM   in reply to bobhopfner

    @Bob – Just a bit OT:

     

    I think your approach of scaling a document is debatable, if someone wants to work on in the scaled-up document, because you leave  paragraph styles and character styles untouched.
    I mean the styles are left intact with their point size, leading and baseline shift values whereas the actual characters are scaled.

     

    Something like "32pt(64)" [scale factor 2] will show up if you set your curser in the actual text frame. And the applied paragraph style, of course, does not show a +sign. This might be dangerous for simple users…

     

    Just a thought.

     

     

    Uwe

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 2, 2012 8:21 AM   in reply to bobhopfner

    This is not a script that was designed to make a designer's life easy, just a means to an end, an output method.

     

    @Bob – for that (output = scaled page output to PDF) you could go a different route:
    Just place your 1:1 InDesign page (or a PDF exported from that), scale the placed object and export to PDF again.

     

    Also see Scott Zanelli's "MultiImporter2.5" script at:

     

    http://indesignsecrets.com/zanelli-releases-multipageimporter-for-impo rting-both-pdf-and-indd-files.php

     

    You have to edit it a bit that it will work in InDesign CS5.5. But basically that's all a designer needs for that task.

     

    Unfortunately "bleed" (documentBleedBottomOffset, etc.) and "slug" (slugBottomOffset, etc.) are  document properties in the documentPreferences, not properties for individual pages. Adobe should correct that to page properties one can manage with the Page tool in the UI.

     

    "trim" is neither a document nor a page property. It is derived from the page bounds when you export to PDF.
    Of course you can redefine all PDF box information in AcrobatPro through  preflight correction.

     

    Uwe

     

    P.S. Oh and about class taking.
    Me thinks it's more: practice, practice and practice. Did I already mention practice? ;-)
    In case you cannot sleep read out loud all DOM objects, methods and properties.

    A prayer drum wouldn't hurt…

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points