We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Footer issues, margins

Hello,

Im having some troubles with footers in a PDFDocument.

My document wide bottom margin is set to 60f.

Here is the method I am calling to create the footer:

[code]
private void AddFooter(PdfDocument doc, string footerText)
{
RectangleF rect = new RectangleF(0, 0, doc.Pages[0].GetClientSize().Width, 40);

//Create a page template
PdfPageTemplateElement footer = new PdfPageTemplateElement(rect);

//Set the font
Font f = new Font("Helvetica", 12);
PdfTrueTypeFont font = new PdfTrueTypeFont(f, true);

PdfSolidBrush brush = new PdfSolidBrush(Color.Black);
PdfStringFormat format = new PdfStringFormat();
format.Alignment = PdfTextAlignment.Center;
format.LineAlignment = PdfVerticalAlignment.Bottom;
format.LineLimit = false;

footer.Graphics.DrawString(footerText, font, brush, new RectangleF(0, 25, footer.Width, 40), format);


//Add the footer template at the bottom
doc.Template.Bottom = footer;
[/code]

The problem is, I cannot see the footer. If i highlight the area on the PDF where the footer should be, copy, then paste the text from the footer is pasted. So the correct text is in the PDF document, its just not visible. Its asif something else (the margin maybe?) Is ontop of the footer.

If I change:

[code]
footer.Graphics.DrawString(footerText, font, brush, new RectangleF(0, 25, footer.Width, 40), format);
[/code]

To

[code]
footer.Graphics.DrawString(footerText, font, brush, new RectangleF(0, 4, footer.Width, 40), format);
[/code]

Moving the Y pos of the string to 4, this is where the bottom of the footer text is starting to be cut off.

What am i doing wrong? Is there a property of the margin, or the footer, to display all its contents? As I say, using Y pos of 25 I can highlight the footer, copy the text and this is fine so the text is in the document; its just not visible.

Thanks, any help is very much appreciated.

Best Regards,


4 Replies

JJ Jisha Joy Syncfusion Team December 14, 2007 12:07 PM UTC

Hi,

I was able to see the issue of footer is not visible in PDF document . Please create a Direct-Trac incident (mention the forum link in the subject line) so that we will fix this issue and we update you with the fix.

Please let me know if you need further assistance any questions.

Thanks for using Syncfusion product.

Regards,
Jisha




JJ Jisha Joy Syncfusion Team December 18, 2007 09:08 AM UTC

Hi,

Thank you for using Syncfusion Products.

On further analysis we found that this is not the issue of Pdf. If Line alignment of String Format is set, then the text will not be visible in the graphics space. This is the default behavior of .Net.

Please refer the sample in the link:
http://websamples.syncfusion.com/samples/PDF.Windows/70484/main.htm

In this sample I have commented out the statement format.LineAlignment, the footer will be displayed correctly and it will be visible to the users.

Kindly try this and let me know if you need further assistance.
Regards,
Jisha



UM umlprog December 20, 2021 04:20 PM UTC

Can't access solution provided. Could you provide new link to a sample?

We are having same issue.



GK Gowthamraj Kumar Syncfusion Team December 22, 2021 12:02 PM UTC

Hi umlprog, 
 
Essential PDF supports to draw the header and footer in PDF document using PdfPageTemplateElement class. We can add text to the header and footer in the PDF document using PDF library. We have attached the sample and output document for your reference, please try the sample on your end and let us know the result. 
 
 

Please let us know if you need any further assistance with this. 

Regards, 
Gowthamraj K 


Loader.
Live Chat Icon For mobile
Up arrow icon