This is an archived forum post. The information may be outdated. Contact us if you have any questions.

Formatting of setFooterHtml / Pagination

hlslaughter wrote on 2012-06-13:
Is there a way to add CSS or other formatting to the content in setFooterHtml?

For example, using the API we are submitting requests with setFooterHtml set to:

<div class=?page_numbers?>Page %p of %n</div>

We provide corresponding CSS to format that content.

But the content is not following the CSS rules when it gets converted to PDF. This is probably because setFooterHtml is rendered *after* the HTML/CSS has been rendered, and is not considered part of the original document. Just guessing.

We'd really like to tweak the size and positioning of that text. Is there any way to do this?

Also, I tried this and it also didn't work:

<div style="clear:both; text-align:right; font-family:Arial, Helvetica, sans-serif; font-size:10px;color:#000000;">%p of %n</div>
support wrote on 2012-06-14:
Hello,

Style sheets defined in the main document are not applied on the footer content. You can use inline CSS to style the footer.

I'm not sure why it does not work for you but I tried your HTML code and it came out in PDF as expected. Can you post your API integration code so we can look into it?
hlslaughter wrote on 2012-06-15:
Here are the settings being passed to the pdfcrowd object:

[?PdfCrowd?fields] => Array
        (
            [username] => *****
            [key] => *****
            [pdf_scaling_factor] => 1
            [html_zoom] => 200
            [footer_html] => <div style="clear:both; text-align:right; font-family:Arial, Helvetica, sans-serif; font-size:10px;color:red;">%p of %n</div>
            [width] => 8.5in
            [height] => 11in
            [hmargin] => .5in
            [vmargin] => .5in
            [initial_pdf_zoom_type] => 4
            [initial_pdf_zoom] => 100
        )

    [?PdfCrowd?scheme] => http
    [?PdfCrowd?port] => 80
    [?PdfCrowd?api_prefix] => http://pdfcrowd.com/api
    [hostname] => pdfcrowd.com


Everything works but the footer styling.

I've tried some simpler variations, and none of them have an effect either:

<div style="text-align:right;color:red;">%p of %n</div>
<div style="font-size:16px;">%p of %n</div>
<span style="font-size:16px;">%p of %n</span>
<span style="font-style:italic;">%p of %n</span>
support wrote on 2012-06-16:
One possible reason why it does not work is that the footer_html field value may require quoting/encoding/escaping. I'm not familiar with the syntax of your code. What language/framework is it?
hlslaughter wrote on 2012-06-16:
It's PHP.

Am I supposed to include quotes inside the literal value of footer_html
support wrote on 2012-06-17:
Can you try the following code? I tested this and it produces a red 10px "page of pages" footer:
$client = new Pdfcrowd("****", "****");
$client->setFooterHtml('<div style="text-align:right; font-family:Arial, Helvetica, sans-serif; font-size:10px;color:red">%p of %n</div>');
    
$fp = fopen("test.pdf", "wb");
$pdf = $client->convertHtml("Test", $fp);
fclose($fp);
hlslaughter wrote on 2012-06-18:
You are right. It does work. Perhaps it was the 'clear: both'?

Thank You