UFFA, READING TWICE OR THREE TIMES I REALIZED I NEED AN COURSE OF "LEARN IN
2 DAYS HOW TO MAKE QUESTIONS EASY TO UNDERSTAND" ...

My PDF has always a table with 10 rows (it could be that it's filled in the
first 2 rows, and the rest are empty). So, for instance, if my PDF consists
of 1 page and tha table only has 4 rows with data, the total rows printed it
would be 4; if it consists of 2 pages, that's means that in the first page
the table has all the 10 rows with data, and in the second page the table
could have just data in one row, the first one, so altogether I have 11 rows
and in each page i have to print "Total number of rows:11" (Don't ask me why
I have to do such a strange thing). So ...

1. The first possible solution  'fitsPage'
> If your data is in a table, working with fitsPage could be
> a way to go. See example 13 in Chapter 5 of the tutorial.
I guess it doesn't "fit" my problem as I will always have page with a fixed
nmber of rows

2. I thought in using the way is explained how to add the total number of
pages with the GenericTagEvent
So
     i.-  I increase this counter in onGenericTag(...) method
    ii.-  as i have to show in each page the total of rows (similar to total
number of pages) for the whole PDF I'll have to use the onCloseDocument()
method, no?

Following the examples you give I'll have sth like

  // we override the onEndPage method
  public void onEndPage(PdfWriter writer, Document document)
  {
          int pageN = writer.getPageNumber();
          String text = "Page Number":  " + pageN + "/ ";
          float len = bf.getWidthPoint(text, 7);

          // Rectangle for Total number of lines
          cb.rectangle(...);
          cb.setColorFill(...); // I set to White
          cb.closePathFillStroke();
          cb.setColorFill(); // I set it to Black

         // Rectangle for Number of Pages
         cb.rectangle(...); // Different position of course ;-)
          cb.setColorFill(..); // Again to White
          cb.closePathFillStroke();
          cb.setColorFill(...); // Again to Black

          cb.beginText();
          cb.setFontAndSize(bf, 7);
          cb.setTextMatrix(...); // In Position A
          cb.showText(text);
          cb.endText();

          cb.addTemplate(...);

          cb.beginText();
          cb.setFontAndSize(bf, 7);
          cb.setTextMatrix(...);  // In Position B
          cb.endText();
  }

and  I thought in a onCloseDocument like ...

  public void onCloseDocument(PdfWriter writer, Document document)
  {
         // Total of pages
         template.beginText();
          template.setFontAndSize(bf, 7);
          template.showText(String.valueOf(writer.getPageNumber() - 1));
          template.endText();

          // Total of rows
          template.beginText();
          template.setFontAndSize(bf, 7);
          template.showText(String.valueOf(totalLines)); // The counter
          template.endText();
  }

it would work, but due to the the setMatrix at the end of onEndPage each
showText i use in onCloseDocument will be related to the position indicated
in the lastMatrix, won't it? I mean, i'll have in the same position the
total number of pages and the total number of rows with data. I tried with a

          cb.beginText();
          cb.setFontAndSize(bf, 7);
          cb.setTextMatrix(...);  // In Position C
          cb.endText();

in the onCloseDocument() between the block for total of pages and total of
rows but no success. So, is there a way to write two texts in
onCloseDocument in two different positions?

Uff, I hope this time managed to make a more clear question ;-)

Regards

Sergio

P.S: Hope u enjoyed Barcelona ;-)

-----------------------------------------------------------------------
Este mensaje y los documentos, que en su caso, lleve anexos, pueden
contener informacion confidencial y ata�e exclusivamente a las personas
a las que va dirigido. Cualquier opinion en el contenida, es exclusiva de
su autor y no representa necesariamente la opinion de AZERTIA.
Si usted no es el destinatario de este mensaje, considerese advertido de
que lo ha recibido por error y que cualquier uso, difusion o copia estan
prohibidos legalmente. Si ha recibido este mensaje por error, le rogamos
que nos lo comunique por la misma via o al telefono 93 207 55 11 y proceda
a destruirlo inmediatamente.  

This email is confidential and intended solely for the use of the individual
to whom it is addressed. Any views or opinions presented are solely those
of the author and do not necessarily represent those of AZERTIA.
If you are not the intended recipient, be advised that you have received
this email in error and that any use, dissemination, forwarding, printing,
or copying of this email is strictly prohibited.
If you have received this email in error please notify it to AZERTIA
by telephone on number +34 93 207 55 11.
-----------------------------------------------------------------------

_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to