13 Replies Latest reply: Apr 2, 2012 8:21 AM by Laubender RSS

    Strange behaviour when scaling GREP styled text.

    bobhopfner Community Member

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

          }

      }

        • 1. Re: Strange behaviour when scaling GREP styled text.
          bobhopfner Community Member

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

          • 2. Re: Strange behaviour when scaling GREP styled text.
            absqua Community Member

            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

            • 3. Re: Strange behaviour when scaling GREP styled text.
              bobhopfner Community Member
              
              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");
               }
              
              • 4. Re: Strange behaviour when scaling GREP styled text.
                bobhopfner Community Member

                I hope this isn't too messy, I just left the pdf code in case we needed some output. I am trying to secure some space for the file upload.

                 

                thanks,

                Bob

                • 5. Re: Strange behaviour when scaling GREP styled text.
                  bobhopfner Community Member

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

                  • 6. Re: Strange behaviour when scaling GREP styled text.
                    absqua Community Member

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

                    • 8. Re: Strange behaviour when scaling GREP styled text.
                      bobhopfner Community Member

                      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.

                      • 9. Re: Strange behaviour when scaling GREP styled text.
                        absqua Community Member

                        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.

                        • 10. Re: Strange behaviour when scaling GREP styled text.
                          bobhopfner Community Member

                          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

                          • 11. Re: Strange behaviour when scaling GREP styled text.
                            Laubender CommunityMVP

                            @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

                            • 12. Re: Strange behaviour when scaling GREP styled text.
                              bobhopfner Community Member

                              I agree, I think more control is warranted and things like adjusted paragraph styles should be redefined. At this point the scaling process ends in a PDF that is downloaded by the user - end of the line. This is not a script that was designed to make a designer's life easy, just a means to an end, an output method. I would love to hear your thoughts (and anyone else who wishes to chime in) toward a better approach as my next project is to define dynamic rescaling including non-proportional scaling i.e. Portrait to Landscape. This will definitely have to take every page item in to account at much greater detail. I am also having a problem defining the bleed and trim boxes too. This is definitely a work in progress. I wish there was some real in depth class you can take, I'd like to major in the IDS DOM.

                               

                              I can't thank everyone enough for their help and support.

                               

                              cheers,

                              Bob

                              • 13. Re: Strange behaviour when scaling GREP styled text.
                                Laubender CommunityMVP

                                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-importing-both-pdf-and-i ndd-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…