0 Replies Latest reply on Dec 23, 2011 9:28 AM by nnmmooppqq

    Printing problem: extra space

    nnmmooppqq Level 1

      I am using a print renderer to print out list element. On a seemingly random basis (I can't figure out the pattern), either an entire line or part of a line is indented. E.g., the list print will show:

       

      ...

      2. Text for list item 2            [radio buttons aligned correctly]

      3.      Text for list item 3       [radio buttons aligned correctly]

      4. Text for list item 4            [radio buttons aligned correctly]

         5. Text for list item 5         [radio buttons aligned correctly]

      ...

       

      In this example, item 3 text is improperly indented, and item 5 number is improperly indented. (I've never seen an example where both the number and the text are improperly indented.

       

      If I run the app again, the improper indents might be on different lines, but there is always at least 1 (usually the last of 10 items).

       

      I suspect that the print renderer needs to be re-sized after it is fully created but before being sent to the print queue, but I can't figure out how to do this.

       

      Please help! Thanks in advance.

       

      JoAnn

       

       

       

      Code that controls the print job:

      public function printContent():void {//called by contentManager based on click event from main printBtn

                  //setup print job:

                  var printJob:FlexPrintJob = new FlexPrintJob();

                  if (printJob.start()) {

                      //Create instance of printRenderer:

                      var asRenderer:asPrintRenderer = new asPrintRenderer();

                      asRenderer.width=printJob.pageWidth;

                      //Put in Title on PrintRenderer:

                      asRenderer.plTitleString=printTitle.toString();

                      //Add the printRenderer, so that it can pick up a dataprovider

                      this.addChild(asRenderer);

                      asRenderer.doCreate(printDP);

                      //make printRenderer invisible

                      asRenderer.visible=false;

                      printJob.addObject(asRenderer);

                      printJob.send();

                      this.removeChild(asRenderer);

                  }

              }  

       

      asPrintRenderer code:

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

      <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" backgroundColor="0xffffff" verticalGap="10"

          horizontalAlign="left" width="90%">

      <mx:Script>

          <![CDATA[

             

              import mx.controls.*

              import mx.collections.*

              import customComponents.asPrintItem

             

              public function doCreate(ourData:XMLList):void {

       

                      head1Text.text=parentDocument.head1;

                      head2Text.text=parentDocument.head2;

                      head3Text.text=parentDocument.head3;

                      for (var n:int=0; n<ourData.length(); n++) {                   

                          //put in text box:

                          var thisBox:asPrintItem=new asPrintItem();

                          addChild(thisBox);

                          thisBox.dorder.text=ourData[n].optionSign.toString();

                          thisBox.optionTextVal.htmlText=ourData[n].optionText;

                          if (ourData[n].isSelected==1) {thisBox.r1.selected=true};

                          if (ourData[n].isSelected==2) {thisBox.r2.selected=true};

                          if (ourData[n].isSelected==3) {thisBox.r3.selected=true};

                      }

              }

          ]]>

      </mx:Script>

          <mx:String id="plTitleString" />

          <mx:Text id="plTitle" htmlText="{plTitleString}" styleName="printHeader"/>

          <mx:HBox id="ptitles" width="100%" horizontalAlign="right"  horizontalGap="0" verticalAlign="bottom" verticalGap="0">

                      <mx:Spacer width="64%" />

                      <mx:HBox id="hrt1" horizontalAlign="center" width="12%" styleName="printSmallI" >

                          <mx:Text id="head1Text" text="first" selectable="false" width="100%" horizontalCenter="true"/>

                      </mx:HBox>

                      <mx:HBox id="hrt2" horizontalAlign="center" width="12%"  styleName="printSmallI">

                          <mx:Text id="head2Text" text="second"  width="100%" horizontalCenter="true"/>

                      </mx:HBox>

                      <mx:HBox id="hrt3" horizontalAlign="center" width="12%" styleName="printSmallI">

                          <mx:Text id="head3Text" text="third"  width="100%" horizontalCenter="true"/>

                      </mx:HBox>

          </mx:HBox>

      </mx:VBox>

       

      asPrintItem Code:

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

      <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" horizontalAlign="left" >

          <mx:Text id="dorder" text="1" width="4%" styleName="printRegular" />

          <mx:Text id="optionTextVal" htmlText="Here is item" selectable="false" width="60%" styleName="printRegular"/>

              <mx:HBox id="hr1" horizontalAlign="center" width="12%"  >

                  <mx:RadioButton id="r1" groupName="g" />

              </mx:HBox>

              <mx:HBox id="hr2" horizontalAlign="center" width="12%"  >

                  <mx:RadioButton id="r2" groupName="g" />

              </mx:HBox>

              <mx:HBox id="hr3" horizontalAlign="center" width="12%" >

                  <mx:RadioButton id="r3" groupName="g" />

              </mx:HBox>

      </mx:HBox>