4 Replies Latest reply on Mar 11, 2011 5:52 AM by Jerry62712

    How do I get Flex to print everything?

    Jerry62712 Level 1

      I am trying to add some data to a report.  I would like to print the user name (and if that ever works more bio stuff) on the each page of a report or worse case on the first page.

       

      To do this I'm adding a Label with the appropriate text set to the user name to the FlexPrintJob.  Then I'm adding a PrintAdvanceGrid to the print job after that.

       

      The problem is the label prints VERY small.  Here is what I have so far:

                      <s:TextArea id="custName"
                               text="Name Holder"
                               fontSize="26" fontWeight="bold"
                               color="#FFFF00"
                               height="200" width="400"/>

      This has been a Label as well.  It displays on the screen in the width and height that are expected.  Only after it is added as an object to the print and then viewed does it become 5 point (or somewhere around there).  Here is how it is added:
                  private function printCaseNotesComponent():void
                  {
                      currentState = "print";
                      var printJob:FlexPrintJob = new FlexPrintJob();
                      custName.text = model.selectedCustomer.individualName.toString();
                      if (printJob.start())
                      {
                          printJob.addObject(custName);
                          printJob.addObject(myPrintAdvancedDataGrid);
                          while (myPrintAdvancedDataGrid.validNextPage)
                          {
                              myPrintAdvancedDataGrid.nextPage();
                              printJob.addObject(myPrintAdvancedDataGrid);
                          }

                          printJob.send();
                      }
                      currentState="normal";
                  }

      When I didn't have the "toString" it printed as if it were 72 point font.

       

      Any ideas?

        • 1. Re: How do I get Flex to print everything?
          dave cragg Level 2

          Does it make a difference if you change the first addObject() statement to this:

           

          printJob.addObject(custName, "none");

           

          I'm wondering if the different sizes of text you are seeing is due to the scaling that addObject() uses. (Although as your TextArea has the width set, I'm not sure how that would make a difference.)

          • 2. Re: How do I get Flex to print everything?
            Jerry62712 Level 1

            Dave,

             

            I will certainly try that.  I could see a second parameter in the "add" function, but I didn't know what it was.

             

            Jerry

            • 3. Re: How do I get Flex to print everything?
              Jerry62712 Level 1

              Update.

               

              The font size is now OK.  Of course, fix one thing and another breaks.

               

              The object should be in HTML format as now built.  It seems HTML formatting was removed in Spark so I set the control to Halo.

                          private function printCaseNotesComponent():void
                          {
                              currentState = "print";
                              var printJob:FlexPrintJob = new FlexPrintJob();
                              var bio:String = model.selectedCustomer.individualName.toString() +
                                              "<br \>" +
                                              model.selectedCustomer.individualName.toString();
                              custName.htmlText = bio;
                              if (printJob.start())
                              {
                                  printJob.addObject(custName, "none");
                                  printJob.addObject(myPrintAdvancedDataGrid);
                                  while (myPrintAdvancedDataGrid.validNextPage)
                                  {
                                      myPrintAdvancedDataGrid.nextPage();
                                      printJob.addObject(myPrintAdvancedDataGrid);
                                  }

                                  printJob.send();
                              }
                              currentState="normal";
                          }
              ...
                              <mx:TextArea id="custName"
                                       htmlText="Name Holder&lt;br/&gt;Line two"
                                       fontSize="18" fontWeight="bold"
                                       color="#FFFF00"  height="60"/>

              I expected the name to appear twice, but it only appeared once.  The grid printed off with only three items on a page.  I suspect it was limited by the size of the first object.  I did change the <> to &lt; and &gt; in the last test and it made no difference in the output.  On the screen it did become two lines when the control was resized to be big enough.

               

              So the question becomes 1) how do you make multiple lines and 2) how do you print the grid so it takes a full page.

              • 4. Re: How do I get Flex to print everything?
                Jerry62712 Level 1

                Further Update

                 

                The print would be of records 13-12-11 on one page, 9-8-7 on the next, 5-4-3 on the next and 1 on the last.  I figured the grid size must be confusing the print option so I upped the grid height to 50000 and all 13 records print.  There is still the question of more records eventually causing the print to miss other records.  Making the height 100% didn't help at all.

                 

                I also changed from HTML which wasn't working to "\n\r" to cause a line break.  This worked, but I don't see why the "<br'>" didn't work as well.  The new code looks like this:

                            <mx:TextArea id="custName"
                                         htmlText="Name Holder"
                                         borderStyle="none"
                                         fontWeight="bold"
                                         x="0" y="70"
                                         height="50%" width="50%"/>
                ...
                                <mx:PrintAdvancedDataGrid
                                    id="myPrintAdvancedDataGrid"
                                    borderStyle="none"
                                    dataProvider="{model.dpCASENOTES}"
                                    width="100%" height="50000"
                                    variableRowHeight="true" y="40">
                                    <mx:columns>
                                        <mx:AdvancedDataGridColumn
                                            headerText=""
                                            textAlign="left"
                                            dataField="shortDescription"
                                            width="135"
                                            wordWrap="true"/>

                 

                                        <mx:AdvancedDataGridColumn
                                            headerText=""
                                            textAlign="left"
                                            dataField="notes"
                                            width="200"
                                            wordWrap="true"/>

                 

                                        <mx:AdvancedDataGridColumn
                                            headerText=""
                                            textAlign="center"
                                            dataField="postTs"
                                            labelFunction="formatDate"
                                            width="120"/>

                 

                                        <mx:AdvancedDataGridColumn
                                            headerText=""
                                            textAlign="left"
                                            dataField="updatedBy"
                                            width="200"/>
                                    </mx:columns>
                                </mx:PrintAdvancedDataGrid>
                            </s:Panel>

                ...

                            private function printCaseNotesComponent():void
                            {
                                currentState = "print";
                                var holdWorker:String;
                                var holdCaseNum:String;

                 

                                if (model.selectedCustomer.caseNumber == null)
                                    holdCaseNum = "none given";
                                else
                                    holdCaseNum = model.selectedCustomer.caseNumber.toString();

                 

                                if (model.selectedCustomer.caseWorkerName == null)
                                    holdWorker = "none given";
                                else
                                    holdWorker = model.selectedCustomer.caseWorkerName;

                 

                                var printJob:FlexPrintJob = new FlexPrintJob();
                                var bio:String = "\r\n\t\tCase Notes for\r\n\tCustomer: " +
                                                model.selectedCustomer.individualName.toString() +
                                                "\t\n\rCase Number: " +
                                                holdCaseNum +
                                                "\t\r\nCase Worker: " +
                                                holdWorker;
                                custName.htmlText = bio;
                                if (printJob.start())
                                {
                                    printJob.addObject(custName, "none");
                                    printJob.addObject(myPrintAdvancedDataGrid);
                                     while (myPrintAdvancedDataGrid.validNextPage)
                                    {
                                        myPrintAdvancedDataGrid.nextPage();
                                        printJob.addObject(myPrintAdvancedDataGrid);
                                    }

                                    printJob.send();
                                }
                                currentState="normal";
                            }