PDF Generating Tool Support Forum

HOME   Login   Register    Search




  Subject: Is it possible to set header/footer scope via the API?
   PostPosted: 02 Feb 2010, 08:44 
I see that since PD4ML Pro 3.2.0b5 you support the 'scope' attribute for in <pd4ml:page.header> and <pd4ml:page.footer> tags so we would be able to set (for example) different headers for the 1st and the other pages.
Thing is that we are currently using the API to set the header template and in the API docs on the site I do not find a way to set this scope programmatically. Am I missing something?


  Subject: Re: Is it possible to set header/footer scope via the API?
   PostPosted: 14 Mar 2010, 07:45 
It is possible with overriding of template methods. For example the code below defines different footers for even and odd pages.

PD4PageMark footer = new PD4PageMark() {
	public String getHtmlTemplate(int pageNumber) {
		if ( pageNumber % 2 == 0 ) {
			return "<html>...template 1...</html>";
		} else {
			return "<html>...template 2...</html>";
		}
	}
};
footer.setAreaHeight(50);


Please take into account - even if you define return ""; for some pages there, it will allocate the defined footer space 50px anyway.

footer.setAreaHeight(-1); autocomputes the footer heigh using the template code, returned for the first page.

The following methods of PD4PageMark are overridable:
  • String getHtmlTemplate( int pageNumber )
  • Color getPageBackgroundColor( int pageNumber )
  • String getPageBackgroundImageUrl( int pageNumber )
  • String getPageNumberTemplate( int pageNumber )
  • String getTitleTemplate( int pageNumber )
  • Font getFont( int pageNumber )


  Subject: Re: Is it possible to set header/footer scope via the API?
   PostPosted: 11 May 2010, 21:50 
I have a dynamic first page footer, it may sometimes occupy more than half of the first page.
Looks like program computing footer height based on first page footer for all pages.

Is there any way that I can force to compute footer height based on individual page footer content and adjust page content accordingly?


  Subject: Re: Is it possible to set header/footer scope via the API?
   PostPosted: 25 May 2010, 17:21 
There are 3 ways to define headers or footers with PD4ML:

html-pdf-faq-f1/pdf-page-headers-footers-definition-options-t41.html

The first and the second (definition via PD4ML API) always allocate fixed amount of space.

The third option should do the trick for you.


  Subject: Re: Is it possible to set header/footer scope via the API?
   PostPosted: 23 Apr 2014, 21:03 
I am also looking to compute the header height dynamically based on header size. Does anyone know how to do this using the API?


  Subject: Re: Is it possible to set header/footer scope via the API?
   PostPosted: 24 Apr 2014, 13:00 
For HTML headers footer.setAreaHeight(-1) forces to allocate footer (or header) space, depending on an actual header height. The auto-computed height cannot change from page to page.

By inline header/footer definition (like <pd4ml:page.header>) it can auto-compute header/footer height as well as change the allocated header space if header definition changes from page to page.

If you do need an exact numeric height (in pixels) of a particular portion of HTML content, you may instantiate PD4ML, perform a dummy conversion of HTML portion to PDF and request the document height:

http://pd4ml.com/cookbook/pd4ml_conversion_status.htm



[Reply]     [ 6 posts ] 

cron
Copyright ©2004-10 zefer|org. All rights reserved. Bookmark and Share