4 Replies Latest reply on Mar 18, 2011 3:28 AM by solapola

    Flex PrintJob

    solapola

      Hi!

      I have a problem with the PrintJob and fitting the pages to the A4 size.

      I add to the PrintJob a list of objects and for presentation I use the PrintDataGrid, using only a column and inside a spark List component. I attach the example:

       

      private function doPrint(event:FlexEvent = null):void

      {

      var printJob:FlexPrintJob = new FlexPrintJob();

      if (printJob.start())

      {

      printJob.addObject(taskListView, FlexPrintJobScaleType.NONE);

      printJob.send();

      }

      }

       

      <mx:PrintDataGrid  id="taskListView" dataProvider="{hostComponent.taskList}" borderVisible="false" width="100%" >

      <mx:columns>

      <mx:DataGridColumn itemRenderer="com.tecfa.tseo.theme.tecfa.editor.print.PrintTaskItemRenderer" />

      </mx:columns>

      </mx:PrintDataGrid > 

       

      The PrintTaskItemRenderer is a s:ItemRenderer with spark components.

      The thing is "sizeToPage" attributte is not working, anyone had solve this problem, or I have to use only PrintDataGrid and no components inside?

       

      Thank you

        • 1. Re: Flex PrintJob
          Flex harUI Adobe Employee

          Does the renderer correctly report its measuredWidth?

          • 2. Re: Flex PrintJob
            solapola Level 1

            Yes, the width it's ok

            I think the problem is with the ItemRenderer and is not fitting the objects in the pages, the objects are appearing cutted when a page finish ..

             

            Thats my Item Renderer, and I hacve another ItemRenderer Inside, maybe too much for Flex print?

             

            Thanx

             

             

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

            <s:MXDataGridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"

            xmlns:s="library://ns.adobe.com/flex/spark"

                            xmlns:mx="library://ns.adobe.com/flex/mx"

            xmlns:component="com.tecfa.tseo.common.component.*">

             

            <fx:Metadata>

            [ResourceBundle("editor")]

            </fx:Metadata>

             

            <fx:Script>

            <![CDATA[

            import com.tecfa.tseo.theme.tecfa.graphic.icon.*;

             

            import mx.controls.listClasses.IListItemRenderer;

             

             

            ]]>

            </fx:Script>

             

            <!-- Main content -->

             

            <s:VGroup>

            <s:HGroup horizontalAlign="left">

            <s:Label width="40" text="{resourceManager.getString('editor', 'printView.id')}"/>

            <s:Label width="60" text="{resourceManager.getString('editor', 'printView.state')}"/>

            <s:Label width="40" text="{resourceManager.getString('editor', 'printView.page')}"/>

            <s:Label width="100" text="{resourceManager.getString('editor', 'printView.category')}"/>

            </s:HGroup>

                    <s:HGroup horizontalAlign="left">

            <s:Label width="40" text="{data.id}"/>

            <s:Group width="60">

            <component:IconButton iconUp="{ViewUnreadPenfingFeedback}"

              visible="{data.state=='UNREAD'}"/>

            <component:IconButton iconUp="{ViewPendingFeedback}"

              visible="{data.state=='OPEN'}"/>

            <component:IconButton iconUp="{ViewValidatedFeedback}"

              visible="{data.state=='CLOSED'}"/>

            </s:Group>

            <s:Label width="40" text="{data.page.id}"/>

            <s:Label width="100" text="{data.category.name}"/>

                    </s:HGroup>

            <s:HGroup horizontalAlign="left" paddingLeft="30">

            <s:Label width="40" text="{resourceManager.getString('editor', 'printView.id')}"/>

            <s:Label width="40" text="!!"/>

            <s:Label width="100" text="{resourceManager.getString('editor', 'printView.author')}"/>

            <s:Label width="90" text="{resourceManager.getString('editor', 'printView.date')}"/>

            </s:HGroup>

            <s:List id="commentList" itemRenderer="com.tecfa.tseo.theme.tecfa.editor.print.PrintTaskCommentItemRenderer"

            borderVisible="true" dataProvider="{data.comments}" width="600" >

            <s:layout>

            <s:VerticalLayout paddingLeft="30" />

            </s:layout>

            </s:List>

             

            </s:VGroup>

             

            </s:MXDataGridItemRenderer>

            • 3. Re: Flex PrintJob
              Flex harUI Adobe Employee

              Check the measuredHeight.  I'll bet it isn't right.  It doesn't look like

              you have enough height constraints to get it to calculate correctly.

              • 4. Re: Flex PrintJob
                solapola Level 1

                Yes! that was the problem..

                I have to use something like this :

                 

                view.width=printJob.pageWidth;
                view.height=printJob.pageHeight;

                 

                Now is not detecting when to start new pages in the validNextPage maybe because I'm using skins, but that's another problem..

                 

                Thanx a lot