Menu

Calculate number of pages

Help
2005-10-09
2013-04-25
  • Alfredo J. Cole

    Alfredo J. Cole - 2005-10-09

    I need to print a report that will show pending customer invoices, with a total and a blank line after each invoice. The total number of lines printed will not be known until after the report is finished. Is there a way to find out how many lines will be printed so I can calculate number of pages and use that in the page footer? Something like "Page XXX of YYY".

    Thank you.

     
    • Seltsamuel

      Seltsamuel - 2005-10-09

      hi, sounds like i had a familar problem :-) its not a problem of libharu, but a logical one.

      when your program acts as a lineprinter for example it cannot ever know how many pages are comming. so if u want to know do like i do. first spool the input in a tempfile. while u do so, u can count the
      cr/lf or cr (depends on aplication) and the form feeds.
      now when u start to print in your pdf u know all u need.

      seltsamuel

       
    • Alfredo J. Cole

      Alfredo J. Cole - 2005-10-10

      That's what I have done in the past. I was hoping there would be a function in libharu so that I could use less time. Sort of the way RLIB has variables for that.

      Thank you.

       
    • Seltsamuel

      Seltsamuel - 2005-10-10

      hm, i not tested it myself, but it should be possible to first print the payload into the PDF and count the pages. after the last line is printed (EOF) of the input u can do a loop 0 - lastpage where u select the page, go to the position of the status line and print it.
      if there is no select page function i could imagine in putting the canvas id into an array for each page and use this id later to select the pages. because the document is build in memory this should work. only some thoughts :-).

      seltsamuel

       
    • Seltsamuel

      Seltsamuel - 2005-10-16

      hi,
      i looked a little bit around and found some reference to a so called
      PAGE MARKER OBJECT thats exactly what u want.
      Its placed on a Page and Displays the actual page and the Number of pages (Style is configurable). I searched in the sources but not found it so i think its an unimplemented pdf feature. maybe a good feature to implement into the lib.

      seltsamuel

       

Log in to post a comment.

MongoDB Logo MongoDB