How to add Header & Footer in Existing PDF Document.

Technical support for Spire.PDF

Moderator: iceblue support

Re: How to add Header & Footer in Existing PDF Document.

Postby tatvasoft » Tue Apr 08, 2014 10:35 am

Hello,

Please find attached sample Pdf file which I create for your reference. And in same file I have added comments what we want.

Thanks,

Jignesh Chauhan
You do not have the required permissions to view the files attached to this post.
tatvasoft
 
Posts: 9
Joined: Tue Mar 25, 2014 9:56 am

Re: How to add Header & Footer in Existing PDF Document.

Postby Gary.zhang » Wed Apr 09, 2014 8:08 am

Hello,

Thanks for the document for testing.

So sorry that at present our Pdf product doesn't support the feature.

Sincerely,
Gary
E-iceblue support team
User avatar
Gary.zhang
 
Posts: 1390
Joined: Thu Apr 04, 2013 1:30 am

Re: How to add Header & Footer in Existing PDF Document.

Postby ppratapwar » Thu Jun 15, 2017 10:11 am

Hello,
I am trying to add a footer to my PDF document at all pages using Spire.Pdf.dll. I am able to create a footer for each page but, some how the footer is overlapping my contents on the page. Any help is appreciated.

Thanks.
ppratapwar
 
Posts: 2
Joined: Tue Jun 13, 2017 3:25 pm

Re: How to add Header & Footer in Existing PDF Document.

Postby Betsy.jiang » Fri Jun 16, 2017 2:17 am

Dear ppratapwar,

Thanks for your inqiury.
After testing, sorry that I didn't find the issue you mentioned, could you please provide us with the input file and the code you were using for investigation ? Then we will provide corresponding code for you.
In addition, here is my testing code for checking.
Code: Select all
            //Create a pdf document.
            PdfDocument doc = new PdfDocument();
            doc.PageSettings.Margins.All = 0;
            AddFooter(doc, PdfPageSize.A4, 50);//you could change the value accroding to the height of footer content
            PdfDocument original = new PdfDocument();
            original.LoadFromFile(@"F:\testing\pdf form testing\original document\10851Sample.pdf");
            PdfPageBase page = null;
            foreach (PdfPageBase origianlPage in original.Pages)
            {
                page = doc.Pages.Add(new SizeF(origianlPage.Size.Width, origianlPage.Size.Height + 50));//add the footerSpace height
                origianlPage.CreateTemplate().Draw(page, 0, 0);
            }
            doc.SaveToFile("10851output.pdf");
            System.Diagnostics.Process.Start("10851output.pdf");
        }
        static void AddFooter(PdfDocument doc, SizeF pageSize, float height)
        {
            //Create a PdfPageTemplateElement object that will be used as footer space
            PdfPageTemplateElement footerSpace = new PdfPageTemplateElement(pageSize.Width, height);
            footerSpace.Foreground = true;
            doc.Template.Bottom = footerSpace;         
            PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial", 9f, FontStyle.Bold), true);
            PdfStringFormat format = new PdfStringFormat(PdfTextAlignment.Center);
            String footerText = "Copyright © 2017 e-iceblue. All Rights Reserved.";
            //Draw text at the center of the page width
            float x = pageSize.Width / 2;
            //you could adjust this value accroding to your specific requirement.
            float y = 0f;
            //draw the footer
            footerSpace.Graphics.DrawString(footerText, font, PdfBrushes.Black, x, y, format);
        }


Sincerely,
Betsy
E-iceblue support team
User avatar
Betsy.jiang
 
Posts: 1733
Joined: Tue Sep 06, 2016 8:30 am

Re: How to add Header & Footer in Existing PDF Document.

Postby Betsy.jiang » Tue Jun 20, 2017 8:33 am

Dear ppratapwar,

How is the issue now ?
Could you please give us some feedback at your convenience ?

Thanks,
Betsy
E-iceblue support team
User avatar
Betsy.jiang
 
Posts: 1733
Joined: Tue Sep 06, 2016 8:30 am

Previous

Return to Spire.PDF

Who is online

Users browsing this forum: No registered users and 0 guests