This might be basic knowledge, but I can't find how do I add the Phrase inside ("in the middle") of one of my Paragraph's content from the onCloseDocument event?

Besides that would even affect the total number of pages on some border cases, wouldn't it?

El 28/12/2010 02:24 p.m., Nurettin DAG escribió:
I think you can still use the PdfPTemplate as explained in the book for the total number of pages(value you don t know until u are done with the document). Given that you define a _pageNumber variable that is a PdfPTemplate to hold the page number.

    protected Phrase getPageNumberingPhrase() {
Phrase pageNumber = new Phrase(String.format("Page %d of ", _pageNumber), Footer.FONT);
        Image totalPageNum;
        try {
            totalPageNum = Image.getInstance(_totalNumPagesTemplate);
        } catch (BadElementException e) {
            throw new ExceptionConverter(e);
        }
        pageNumber.add(new Chunk(totalPageNum, 0, 0));
        return pageNumber;
    }

If you add the phrase returned by this method to your document once you define template _pageNumber onCloseDocument it should work fine.

Please note that I have not tried it but I do not see why it would not work theoretically.

2010/12/28 Johann Pérez <[email protected] <mailto:[email protected]>>

    I have been trying some stuff with the methods you said, but can't get
    the result I want.

    Suppose I have a Paragraph inside a PDFPCell which says "TITLE -
    page #n
    out of #t - " + image on every page. how do I replace #n and #t on
    every
    page? I understand where can I get those values but what don't
    understand is how do I put them in the right place taking into account
    that the mentioned Paragraph should be part of the contents of the pdf
    document.

    Thanks four your help,
    Johann

    El 28/12/2010 11:47 a.m., 1T3XT BVBA escribió:
    > Op 28/12/2010 13:32, Johann Pérez schreef:
    >> Hello,
    >>
    >> I have already seen some examples of how to put page numbers
    and total
    >> pages using templates.
    >> What I cannot figure out is how to add page number and total pages
    >> between some other content.
    >>
    >> In our application pdf documents are built from some meta-data so
    >> headers and footers are made with a pdftable where we put
    images, user
    >> name, title etc etc and combinations of them according to the
    meta-data
    >> we receive.
    >> So, even tough it may sound strange, we may have things
    like<title>   + "
    >> " + page number + translate("out of",<userlanguage>) + total
    number of
    >> pages +<some other text>   +<an image>   and any kind of
    combination so if
    >> I wanted to use templates I should know the exact position where
    >> pagenumber or total pages should be which depends not only of the
    >> combination but also of the pdftable and cells size (height is not
    >> bounded), text font, etc etc which it seems quite difficult to
    achieve...
    >>
    >> I would appreciate any ideas.
    > The methods in page events as well as in table and cell events
    give you
    > access to a PdfWriter object. This allows you to get the current
    page
    > number. As for the total number of pages: this should be
    obtained from
    > the onCloseDocument method as is done in the "page X of Y" examples
    > you're referring to.
    > In the examples, you're referring to, the onEndPage() method is
    used. As
    > you want to add the page numbers "inside the content", you
    should choose
    > another method, such as onGenericTag() or, as you refer to
    PdfPTable: in
    > a table or cell event.
    > Given this information, what is your question?
    >
    >
    
------------------------------------------------------------------------------
    > Learn how Oracle Real Application Clusters (RAC) One Node allows
    customers
    > to consolidate database storage, standardize their database
    environment, and,
    > should the need arise, upgrade to a full multi-node Oracle RAC
    database
    > without downtime or disruption
    > http://p.sf.net/sfu/oracle-sfdevnl
    > _______________________________________________
    > iText-questions mailing list
    > [email protected]
    <mailto:[email protected]>
    > https://lists.sourceforge.net/lists/listinfo/itext-questions
    >
    > Many questions posted to this list can (and will) be answered
    with a reference to the iText book: http://www.itextpdf.com/book/
    > Please check the keywords list before you ask for examples:
    http://itextpdf.com/themes/keywords.php
    >




    
------------------------------------------------------------------------------
    Learn how Oracle Real Application Clusters (RAC) One Node allows
    customers
    to consolidate database storage, standardize their database
    environment, and,
    should the need arise, upgrade to a full multi-node Oracle RAC
    database
    without downtime or disruption
    http://p.sf.net/sfu/oracle-sfdevnl
    _______________________________________________
    iText-questions mailing list
    [email protected]
    <mailto:[email protected]>
    https://lists.sourceforge.net/lists/listinfo/itext-questions

    Many questions posted to this list can (and will) be answered with
    a reference to the iText book: http://www.itextpdf.com/book/
    Please check the keywords list before you ask for examples:
    http://itextpdf.com/themes/keywords.php




--
Nurettin DAG


------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and,
should the need arise, upgrade to a full multi-node Oracle RAC database
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl


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

Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php



------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to