This topic contains 8 replies, has 0 voices, and was last updated by EnablingSolutions 8 years, 7 months ago.

  • Author
    Posts
  • #2207

    jwenzer

    I am trying to wrap my head around what I thought would be a simple task. We are moving to using the Advanced PDF Template for our invoices, and I want to print the page number, but only if there are more than 1 pages. This seems to be not easy to do, because it is a mix of both Freemarker and BFO. BFO has the pagenumber and totalpages variables, but can those be accessed using Freemarker if statement?

    This is what I am trying:

    Code:
    1)>Page of #if>
    It is giving me a Expression totalpages is undefined error when trying to save the template.
    This is a cached copy. Click here to see the original post.

  • #2208

    corey

    How about if you just check if pagenumber is not 1.


    jwenzer replied on 02/17/2015, 09:25 AM: I get the same basic error, that pagenumber is undefined.

  • #2209

    wwinters

    Hmmm..

    I wonder if something like this might work:

    <#assign totalpages="”>

    1)>Page of

    Let me know if that works.

    Best,

    Wes


    jwenzer replied on 02/17/2015, 09:26 AM: The editor keeps changing your first line of code into HTML (I can’t get it to save in this editor!):

  • #2210

    wwinters

    Drat! Sounds like it might be a defect in the XML parser.

  • #2211

    rgonzales

    try using

  • #2212

    charoldson

    Assigning the variable works fine, but the problem is in the comparison. NetSuite will not allow us to Save the template with the #if statement in it. When saving, it appears the HTML editor is validating the HTML. It sees the totalPages variable as a FreeMarker SimpleScalar type (since has not been evaluated yet) and trying to compare it to the number 1, which is a Number type.

    I haven’t found a way around it yet.

  • #2213

    dmatyas

    Hi,

    this cannot work from the nature of used technologies.

    Here is what is happening during PDF generation:

    1. Template gets merged with datasource using Freemarker – all Freemarker constructs gets evaluated in this step as well – as a result we get “processed template” which is now fully qualified XHTML (with BFO tags in it, but without any FreeMarker). At this point it is unknown how many pages will be in resulting PDF.

    2. “Processed Template” goes to XML to PDF function, where BFO engine simply translates XHTML into PDF. No scripting is available during this phase therefore there cannot be any conditional changes to what will be in resulting PDF.

    I hope my explanation is understandable.

    Thanks,

    Daniel

  • #2214

    jakubwagner

    There is also one commonly hit limitation of BFO also mentioned in their FAQ (http://bfo.com/faq.jsp) :

    How do I set headers and footers for specific pages ?

    The Report Generator userguide has a section devoted to headers and footers. In version 1.1.x of the Report Generator the options for setting headers are:

    Setting them for specific pages using the page selector in the style sheet.

    Setting them in the tag and tags, in which case the header and footer will be changed from that point forward.

    Setting them for odd and even pages using the CSS2 right and left selectors for the body tag in the style sheet (see the “examples/dynamic/bigtable.jsp” example in the download package).

    At the moment we do not have a facility for explicitly assigning a footer or header to the last page in a document when the number of pages is unknown.

    Regarding to the page problem, there might be one possibility, however I have not tested it:

    In the BFO user guide(http://bfo.com/products/report/docs/userguide.pdf) there is mentioned:

    Each page in the document is given a unique ID equal to โ€œpageโ€ followed by the current pagenumber.

    For example, hereโ€™s how to set the size and background color of the first page.

    Code:
    #page1 { size:A4-landscape; background-color:yellow; }
    So there may be some opportunity to magic as the BFO do support CSS2 (http://bfo.com/products/report/docs/tags/) and if its really true that there are reserved values like #page1 – #pageXYZ

  • #2215

    EnablingSolutions

    Hi all

    Is there any movement on this? Has anyone been able to achieve it?

    Thanks

    Pete.

You must be logged in to reply to this topic.