I am trying to print a text header with an image control.  I scale the 
image to fit the page, but the text gets scaled also.  Is there a way 
to scale the image without the text scaling as well.  I am printing as 
a bitmap.  Here is the code:





<?xml version="1.0" encoding="utf-8"?>

<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml";
   backgroundColor="#FFFFFF"
   paddingBottom="10" paddingLeft="10" paddingRight="10" 
paddingTop="10"
   initialize="initRes()"
   visible="false">

   <mx:Script>
      <![CDATA[
        import mx.graphics.ImageSnapshot;
        import mx.formatters.DateFormatter;
         import mx.printing.FlexPrintJob;
         import mx.printing.FlexPrintJobScaleType;
         import 
org.familysearch.recordsearch.web.view.common.GraphicAssets;
         import 
org.familysearch.recordsearch.web.util.ResourceLocator2;

         private const FONTSIZE:int = 16;
         public var printSelection:Boolean = true;
         public var printRectangle:Rectangle;
         
         [Bindable] private var resources:ResourceLocator2;
         private function initRes() : void
         {
           resources = ResourceLocator2.getResource("Images", 
resourcesLoaded);
         }
         
          private function resourcesLoaded(event:* = null) : void
          {
          }

         private function printImage(event:* =null) : void
         {
            var printJob:FlexPrintJob = new FlexPrintJob();
            var currentDate:Date = new Date();
            var formatter:DateFormatter = new DateFormatter();
            formatter.formatString="MMMM D, YYYY";
            date.text = resources.strings.imagesPrinted 
+formatter.format(currentDate);
            if (printJob.start())
            {
               var citationScaleFactor:Number = 1.0;
               var w:Number = img.contentWidth;
               var h:Number = img.contentHeight;
               var pjw:Number = printJob.pageWidth;
               var pjh:Number = printJob.pageHeight;
               var ws:Number = w/pjw;   //width scale factor
               var hs:Number = h/pjh;   //height scale factor

               if ( (w >= pjw && h >= pjh) ||
                    (w < pjw && h < pjw) )
               {
                  // both dimensions need to be scaled,
                  // choose the smallest scaling factor
                  citationScaleFactor = ((ws<hs)?ws:hs);
               }
               else
               {
                  citationScaleFactor = ((w>pjw)?ws:hs);
               }

               var fntSize:int = FONTSIZE*citationScaleFactor;
               var citationText:String = 
resources.strings.imagesCollection +citation.text;
               citation.text = citationText;
               citation.setStyle("fontSize",fntSize);
               date.setStyle("fontSize",(fntSize-20));
               printJob.addObject(this, 
FlexPrintJobScaleType.SHOW_ALL);
               printJob.send();
            }
         }

      ]]>
   </mx:Script>
   
  
   
    <mx:Grid width="100%">
        <mx:GridRow width="100%" height="100%">
            <mx:GridItem width="100%" height="100%">
               <mx:Image  id="familysearch" 
source="{GraphicAssets.LOGO_PRINT}"/> 
            </mx:GridItem>
        </mx:GridRow>
        <mx:GridRow width="100%" height="100%">
          <mx:GridItem width="100%" height="100%">
            <mx:Label  id="citation"  width="100%" fontWeight="bold"/> 
          </mx:GridItem>
        </mx:GridRow>
        <mx:GridRow width="100%" height="100%">
          <mx:GridItem width="100%" height="100%">
            <mx:Label  id="date"   width="100%" 
styleName="collectionSearchText" /> 
          </mx:GridItem>
        </mx:GridRow>
    </mx:Grid>
   <mx:Image id="img" complete="printImage()"/>
   <mx:Image id="selectedImg" includeInLayout="false" 
visible="false"/>
    
</mx:VBox>




Reply via email to