0 Replies Latest reply on May 21, 2010 11:06 AM by Tabgyn

    Custom Print

    Tabgyn

      I am trying to print a form with the following measures, height: 404, width: 639.

      The problem is that when printing, I need to choose the size of A4 paper, but in doing so I lose the positioning settings I had configured in the template of the form.


      Here my code:

       

      Template.mxml:

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

      <mx:Canvas

      xmlns:mx="http://www.adobe.com/2006/mxml"

            horizontalScrollPolicy="off" verticalScrollPolicy="off"

            width="639" height="404">

       

      <mx:Label x="391" y="346" text="X" width="12" height="12" fontSize="8" id="label_1" fontWeight="bold" textAlign="center"/>

      </mx:Canvas>

      Win.as:

             import com.Window;

             import mx.controls.Alert;

             import mx.events.CloseEvent;

             import mx.printing.FlexPrintJob;

       

             [Bindable]

             public class win extends com.Window

             {            

                   public function win()

                   {

                          super();

                   }

                  

                   public function begin():void

                   {

                          Alert.yesLabel = "Yes";

                          Alert.noLabel = "No";

                          Alert.show("Print?", Alert.YES | Alert.NO, null, printTemplate);

                   }

                  

                   private function printTemplate(event:CloseEvent = null):void

                   {

                          if(event == null || event.detail == mx.controls.Alert.YES)

                          {

                                 var model:Template = new Template;

                                 model.visible = false;

                                 addChild(model);

                                

                                 var printJob:FlexPrintJob = new FlexPrintJob();

                                

                                 if(printJob.start())

                                 {

                                        printJob.addObject(model);

                                        printJob.send();

                                        removeChild(model);

                                 }

                          }

                   }

             }

      }

      Anyone know how to help me?

       

      Sorry for bad english xD