I am finding myself with the weirdest flex behavior since i started
using flex 8 months ago.

Let me explain:

Remember i told you that i made a sample application whose only
purpose was to scroll the bar down just to see it was scrolling
correctly? Well i made a little improvement to that screen, i removed
the scrolldown logic and i added print logic, but the normal and basic
one, printJob.start(), printJob.addObject() and printJob.send(),
NOTHING related to multipage, i didn't set the VBox width and height
to the PrintJob ones and for my surprise when it printed, IT PRINTED
IT IN MULTIPLE PAGES!!!

Next thing i did was to set the VBox to the PrintJob dimensions (width
and height) and try to print it again and it printed a SINGLE PAGE
which is incomplete (you can see the scrollbar which indicates that it
didn't fit).

Here is the sample code:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="vertical" width="595" height="842">

<mx:Label id="test" width="100%"/>
<mx:Button label="Fill" click="fill()"/>
<mx:Button label="Print" click="print()"/>
    
<mx:Script>
<![CDATA[
import mx.printing.FlexPrintJob;
import mx.controls.Button;
import mx.controls.Spacer;
import mx.controls.Text;
import mx.containers.VBox;

public var prueba : VBox = new VBox();
        
public function fill() : void
{
for (var i:Number = 0; i<16; i++) {
  var formato : VBox = new VBox();
  formato.percentWidth = 100;
  test.setStyle('textAlign', 'center');
  var etiquetaFecha : Label = new Label();
  var etiquetaRol : Label = new Label();
  var etiquetaDesc : Text = new Text();
  var espacio : Spacer = new Spacer();
  espacio.height = 10;
  etiquetaFecha.text = 'Fecha';
  etiquetaRol.text = 'Rol'
  etiquetaDesc.percentWidth = 100;
  etiquetaDesc.text = i.toString();
  formato.addChild(etiquetaFecha);
  formato.addChild(etiquetaRol);
  formato.addChild(etiquetaDesc);
  formato.addChild(espacio);
  prueba.addChild(formato);
  }
}

public function print() : void
{
  var printJob : FlexPrintJob = new FlexPrintJob();
  if (printJob.start()) {
    addChild(prueba);

   //If you use this it prints in multiple pages

    prueba.percentHeight = 100;
    prueba.percentWidth = 100;

   //If you use this it prints a single incomplete page 

    //prueba.width = printJob.pageHeight;
    //prueba.height = printJob.pageWidth; 

    invalidateSize();
    invalidateDisplayList();
    validateNow();
    printJob.addObject(prueba);
  }     
  printJob.send();
}
]]>
</mx:Script>
</mx:Application>

Any idea why this behavior?

Now back to my other application, here's the loop that adds pages:

private function imprimir() : void
{
var printJob : FlexPrintJob = new FlexPrintJob();
var printView : DetalleAuditoria = new DetalleAuditoria();
if (printJob.start()) {
  addChild(printView);
  printView.width = printJob.pageWidth;
  printView.height = printJob.pageHeight;
  printView.header = sesion;
  printView.detalles = auditorias.toArray();
  printView.showPage("single");
  if (!printView.validateNextPage()) {
    printJob.addObject(printView);
  }
  else {
    printView.showPage("first");
    printJob.addObject(printView);      
    while (true) {
      printView.nextPage();
      printView.showPage("last");
      if (!printView.validateNextPage()) {
        printJob.addObject(printView);
        break;
      }
      else {
        printView.showPage("middle");
        printJob.addObject(printView);
      }
    }
  }
//removeChild(printView);
}
printJob.send();
}

Please help!!! i know i am close to the solution but i just don't seem
to find the final piece of this puzzle.

By the way, got MSN messenger or google talk? or can i write to your
email directly? i ask this because probably you will need the whole
code or something.

--- In [email protected], "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> Just so I understand, if you leave the verticalScrollPolicy to Auto
or On, you can see the scrollbar move on the printed page but the
content doesn't?  And, when printing is finished you do see the
content of the last page?
>  
> Can I see the loop that does the addPage?
> 
> ________________________________
> 
> From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of dmiramontesval
> Sent: Monday, December 11, 2006 2:11 PM
> To: [email protected]
> Subject: [flexcomponents] Re: Printig multipage output
> 
> 
> 
> I tried that on Saturday, i made an application which scrolls down
> whenever i press a button and it does scroll down, so it could be a
> validateNow() problem as you said.
> 
> I am sure the verticalScrollBar is scrolling because if i set the
> scrollBar policy to true, when printing you can see how the scrollbar
> (the scrollbar appears in the printed page) moved from one page to
> another.
> 
> The thing is that even when i am scrolling down, it is printing always
> the first page. I changed my code according to your suggestion but
> the result is still the same, it prints multipages but they are all
> the first page.
> 
> Here is the function:
> 
> public function nextPage() : void
> {
> verticalScrollPosition += height;
> invalidateSize();
> invalidateDisplayList();
> validateNow();
> }
> 
> Of course i am adding the PrintVBox to the displayList, as a matter of
> fact i am not removing it of the displayList in order to see how the
> PrintVBox looks at the end, and it appears with it's verticalScrollBar
> an the bottom, which means it scrolled to the end of the bar,
> showing the last page that was supposed to be printed.
> 
> So it is in fact scrolling down but it is printing only the first
> page, any help????? please i am very close to finishing this.
> 
> --- In [email protected]
<mailto:flexcomponents%40yahoogroups.com> , "Alex Harui" <aharui@> wrote:
> >
> > What happens if you call valdateNow() right after
> invalidateDisplayList()?
> > 
> > One good test is to put the PrintVBox in an app, set up a Button
> that sets verticalScrollPosition, run the app, hit the button and make
> sure it does move. If it does move, then you are facing an
> invalidation timing problem and probably just need to call
> validateNow() at the right time. If it doesn't, then there is
> something about the content of the VBox that is fooling the VBox.
> > 
> > You might also want to print out the value of verticalScrollPosition
> to make sure it is changing as expected. If you never put the
> PrintVBox on the display list, it won't get layed out and won't have a
> height.
> > 
> > And, you can always create a mini-example and post it. It might
> give us more clues as to what might be going on.
> > 
> > -Alex
> > 
> > ________________________________
> > 
> > From: [email protected]
<mailto:flexcomponents%40yahoogroups.com> 
> [mailto:[email protected]
<mailto:flexcomponents%40yahoogroups.com> ] On Behalf Of dmiramontesval
> > Sent: Monday, December 11, 2006 10:08 AM
> > To: [email protected]
<mailto:flexcomponents%40yahoogroups.com> 
> > Subject: [flexcomponents] Re: Printig multipage output
> > 
> > 
> > 
> > Actually i am following the same approach, i receive an Array and i
> > iterate it adding child components to the report, every x objects in
> > the array i add a new page. 
> > 
> > It works fine except that when i send them to print, it always prints
> > the first page even though i am scrolling down the screen.
> > That's what the PrintDataGrid does, scrolls down and then sends to
> > print, i am doing the same but it always prints the first page i dunno
> > why, maybe i am missing something but i have no idea.
> > 
> > The function that does this scrolling looks like this:
> > 
> > public function nextPage() : void
> > {
> > verticalScrollPosition += height;
> > invalidateSize();
> > invalidateDisplayList();
> > }
> > 
> > Any ideas of what i am missing?
> > 
> > --- In [email protected]
<mailto:flexcomponents%40yahoogroups.com> 
> <mailto:flexcomponents%40yahoogroups.com> , "zenwarden" <cwarden@>
wrote:
> > >
> > > I've started down the same path you have. I have not finished what I
> > > am working on, but it's a custom report with charts in a VBox
that is
> > > of variable length. I'm dynamically adding components and I need to
> > > print them out as a report.
> > > 
> > > Basically I would suggest creating an array (or any collection you
> > > like) and adding the components (or references to them) that you
want
> > > to have in the printed report to that array. 
> > > 
> > > Then when you do a print job, you will need to iterate through the
> > > array and print those things out. You will probably need to
preprocess
> > > that array and figure out where the page breaks are going to be. 
> > > 
> > > That at least the approach that I am considering right now. 
> > > 
> > > You might also want to look at the src code for the data grid print
> > > for ideas.
> > > 
> > > All the best.
> > > 
> > > Chris
> > > 
> > > P.S. In anyone thinks this is a bad appraoch let me know. I would be
> > > happy to have a better solution.
> > > 
> > > 
> > > --- In [email protected]
<mailto:flexcomponents%40yahoogroups.com> 
> <mailto:flexcomponents%40yahoogroups.com> , "dmiramontesval"
> > > <dmiramontesval@> wrote:
> > > >
> > > > In my last post i made myself clear when i told Peter not to
take it
> > > > personally, who seemed to get the point since he later replied
> to give
> > > > me a piece of advice on how to do this.
> > > > 
> > > > Since my first post, i was asking for that, for any ideas on how
> to do
> > > > it manually, i NEVER asked for explanations of why Adobe didn't
> > > > include multipage support in every component and I wasn't
expecting
> > > > Adobe to magically release a solution in one day either.
> > > > 
> > > > If Peter felt offended, i apologize to him, like i said in
that post
> > > > which seemed to have caused such a big deal, i wasn't taking it on
> > > > him, sorry if anyone felt it that way.
> > > > 
> > > > Going back to the original question and how to solve it, i am
doing
> > > > what Peter suggested, print, scroll then print again, i think i am
> > > > close to accomplish it but i can't get page break to work
properly.
> > > > I'll examine PrintDataGrid.as a little more to see if i there's
> > > > anything that can help me out
> > > > 
> > > > Any ideas will be of great help
> > > > 
> > > > 
> > > > --- In [email protected]
<mailto:flexcomponents%40yahoogroups.com> 
> <mailto:flexcomponents%40yahoogroups.com> , Peter Bell <pbell@> wrote:
> > > > >
> > > > > It is the same issue I am having with a major new product I¹m
> > > > rolling out at
> > > > > SystemsForge. It isn¹t just scaffolding a la Rails or
> > Model-Glue, but
> > > > > neither can it do every possible thing automatically that an
> > > imperative
> > > > > programming language can. It allows you to generate many classes
> > > of web
> > > > > applications using re-usable metadata in minutes, but if you
want
> > > > completely
> > > > > custom elements, you either need to create your own metadata or
> > > > sometimes
> > > > > you need to go out and write your own objects to subclass the
> > > framework.
> > > > > Maybe we need to start selling a copy of Fred Brookes ³The
> > > Mythical Man
> > > > > Month² with ALL of the development tools we all create. There
> really
> > > > is no
> > > > > silver bullet!
> > > > > 
> > > > > Best Wishes,
> > > > > Peter
> > > > > 
> > > > > 
> > > > > On 12/9/06 7:57 AM, "Yakov Fain" <yfain@> wrote:
> > > > > 
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > I kinda agree with Peter, Flex is just a tool, and if it does
> > > not have
> > > > > > some features, you should not assume it should have them. Yes,
> > > the OP
> > > > > > should tell his users that it's doable, but will cost them.
> > > > > > 
> > > > > > The problem is that currently the main theme of Flex sales
> > force is
> > > > > > "you can create a fully functional application in Flex in less
> > than
> > > > > > one minute". True, if your application just needs to
populate a
> > > > > > datagrid from an XML source and this is all the user
wants. But
> > > in the
> > > > > > real world, you should deliver a message that clearly states,
> > > "Flex is
> > > > > > a tool that can substantially speed up your development, but
> > when it
> > > > > > comes to customization, it's not faster than any other
software
> > > tool".
> > > > > > 
> > > > > > Regards,
> > > > > > Yakov Fain
> > > > > > Farata Systems 
> > > > > > 
> > > > > > --- In [email protected]
<mailto:flexcomponents%40yahoogroups.com> 
> <mailto:flexcomponents%40yahoogroups.com> 
> > > > > > <mailto:flexcomponents%40yahoogroups.com> , Peter Bell
<pbell@>
> > > wrote:
> > > > > >> >
> > > > > >> > With respect, I would tell them that Flex can do
exactly what
> > > they
> > > > > > want. It
> > > > > >> > has a built in tool ­ PrintDataGrid that supports their
> > > > requirements
> > > > > > (with
> > > > > >> > any limitations there might be for your use case) and
if that
> > > > > > doesn¹t work
> > > > > >> > for them for a substantially higher fee you could code a
> custom
> > > > > > component to
> > > > > >> > meet their specific needs. I don¹t think that support for
> > > > multi-page
> > > > > > print
> > > > > >> > pagination support on all controls is the kind of
feature you
> > > would
> > > > > > expect
> > > > > >> > by default and I¹m actually glad to hear that Flex even
> > supports
> > > > > > that in the
> > > > > >> > PrintDataGrid component.
> > > > > >> > 
> > > > > >> > I don¹t see what the beef is. They bought a development
tool
> > > > that has a
> > > > > >> > built in control to solve the class of problem and that
> has the
> > > > > > capacity to
> > > > > >> > be extended using custom controls if the standard controls
> > don¹t
> > > > > > meet their
> > > > > >> > needs. Was there a label on the box saying ³all controls
> > support
> > > > > > multi-page
> > > > > >> > pagination²? Did someone from Adobe call you up and say
> > ³buy Flex
> > > > > > because
> > > > > >> > the multi-page pagination support on our Vbox is cool²?
> > > > > >> > 
> > > > > >> > What if I purchased VS.NET and found (because I hadn¹t
> > checked in
> > > > > > advance)
> > > > > >> > that one of the controls didn¹t do something I¹d just
assumed
> > > > that it
> > > > > >> > should? Maybe Microsoft should reschedule their production
> > > release
> > > > > > because
> > > > > >> > I¹m in a bind?
> > > > > >> > 
> > > > > >> > It is perfectly appropriate to ask respectfully for feature
> > > > > > enhancements and
> > > > > >> > I¹m guessing they¹ll get evaluated by the product team and
> > may be
> > > > > > added to
> > > > > >> > the production schedule based upon whatever criteria they
> > > have for
> > > > > >> > evaluating such requests. If you think a missing feature
> makes
> > > > a product
> > > > > >> > unusable, select a different alternative. Flex is amazing
> but I
> > > > can¹t
> > > > > >> > believe it solves every single problem for every single use
> > case.
> > > > > > But what
> > > > > >> > is with the attitude? It seems to me like the only mistake
> > > that was
> > > > > > made was
> > > > > >> > that a consultant assumed a feature would exist, made a
> > > > > > recommendation based
> > > > > >> > on that assumption and is now in a bind. I¹ve been
there too
> > > ­ none
> > > > > > of us
> > > > > >> > are perfect, but that wasn¹t Adobes fault.
> > > > > >> > 
> > > > > >> > FYI, I am completely unaffiliated with Adobe, and I don¹t
> > > know Alex
> > > > > > at all.
> > > > > >> > But to be honest, the tone of your post just pissed me off.
> > > > Sorry you¹re
> > > > > >> > having a bad day, but it isn¹t Alex or Adobe¹s fault.
> > > > > >> > 
> > > > > >> > Best Wishes,
> > > > > >> > Peter
> > > > > >> > 
> > > > > >> > 
> > > > > > 
> > > > > > 
> > > > > >
> > > > >
> > > >
> > >
> >
>


Reply via email to