Sign In  Sign Up Live-Chat

How to add padding to the bottom of a PDF

Last post 06-11-2007, 9:00 AM by GeorgieYuan. 8 replies.
Sort Posts: Previous Next
  •  06-06-2007, 4:30 PM 79669

    How to add padding to the bottom of a PDF

    I use the code below to stamp the bottom of PDFs. How would I go about adding additional padding to a PDF to ensure the text that I am stamping does not overwrite existing text? Many thanks! Ryan --------------------------------------------------------------------------------

    public void copyPdfAndStamp(string soruce, string destination, FormattedText[] formattedText, bool setLandscapeToPortrait, position objPosition)

    {

     

    fatalError = false;

    fatalErrorMessage = "";

    try

    {

    /* get height and width */

    PdfFileInfo pdfFileInfo = new PdfFileInfo(soruce);

    PdfFileStamp stamper = new PdfFileStamp(soruce, destination);

    for (int i = 0; i < formattedText.Length; i++)

    {

    float pageHeight = pdfFileInfo.GetPageHeight(i + 1);

    float pageWidth = pdfFileInfo.GetPageWidth(i + 1) / 2;

    float textHeight = formattedText[i].TextHeight;

    float textWidth = formattedText[i].TextWidth;

    Stamp stamp = new Stamp();

    stamp.BindLogo(formattedText[i]);

    stamp.IsBackground = false;

    int[] pages;

    pages = new int[1];

    pages[0] = i + 1;

    stamp.Pages = pages;

    switch (objPosition)

    {

    case position.BOTTOM_LEFT:

    stamp.SetOrigin(0, 2);

    break;

    case position.BOTTOM_RIGHT:

    pageWidth = pdfFileInfo.GetPageWidth(i + 1);

    stamp.SetOrigin(pageWidth - textWidth, 2);

    break;

    default:

    //stamp.SetOrigin((pageWidth / 2) - (textWidth / 2) + 15, 2);

    stamp.SetOrigin((pageWidth / 2) - (textWidth / 2) + 135, 2);

    break;

    }

    stamper.AddStamp(stamp);

    }

    pdfFileInfo = null;

    stamper.Close();

    stamper = null;

    }

    catch (Exception e)

    {

    fatalError = true;

    fatalErrorMessage = e.Message;

    }

    }


    Ryan Schnieber

    Project Manager
    Electronic Discovery & Computer Forensics On-Site E-Discovery
    832 North Henry Street
    Alexandria, VA 22314
    Office 001-703-276-1123
    International Cellular 001-213-479-0153
     
  •  06-06-2007, 6:23 PM 79684 in reply to 79669

    Re: How to add padding to the bottom of a PDF

    Hi,

    Thank you for considering Aspose.

    I am not sure that I understand your problem. What I understand is that you want to add some space from the Bottom in the Pdf Page. I don't think that in the existing Pdf it is possible. If it didn't help, then please elaborate your requirements, so that we can better guide you to some solution.

    Thanks.

    Adeel Ahmad
    Support Developer
    Aspose Changsha Team
    http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactChangsha.html

     
  •  06-07-2007, 11:19 AM 79812 in reply to 79684

    Re: How to add padding to the bottom of a PDF

    What I want to do is add a disclaimer to the bottom of each PDF. However, I do not want to overwrite existing content on the PDF.

    I have no way of dictating if these PDF have content on the bottom since they come from different sources.

    For example, I have a PDF that has a page size of 8.5 X 11. I would like to make it 8.5X12.5. This way I can safely add the disclaimer without overwriting existing text. Does this make sense?

    Many thanks,

    Ryan


    Ryan Schnieber

    Project Manager
    Electronic Discovery & Computer Forensics On-Site E-Discovery
    832 North Henry Street
    Alexandria, VA 22314
    Office 001-703-276-1123
    International Cellular 001-213-479-0153
     
  •  06-07-2007, 12:58 PM 79825 in reply to 79812

    Re: How to add padding to the bottom of a PDF

    Hi,

    I think you can use PdfPageEditor class to change the Pdf page size of the resultant Pdf. And then you can add stamp.

    If you need more help, please do let us know.

    Thanks.

    Adeel Ahmad
    Support Developer
    Aspose Changsha Team
    http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactChangsha.html

     
  •  06-07-2007, 9:37 PM 79878 in reply to 79825

    Re: How to add padding to the bottom of a PDF

    Could you please give me an example of how to do this using PdfPageEditor? Your help with this is greatly appreciated.

    Many thanks,

    Ryan


    Ryan Schnieber

    Project Manager
    Electronic Discovery & Computer Forensics On-Site E-Discovery
    832 North Henry Street
    Alexandria, VA 22314
    Office 001-703-276-1123
    International Cellular 001-213-479-0153
     
  •  06-07-2007, 10:01 PM 79879 in reply to 79878

    Re: How to add padding to the bottom of a PDF

    Hi,

    I have checked with the following code to increase the Height of the Pdf page. It worked but the problem is that it add the spaces from the top not from the bottom. I will discuss this with the developers and we will let you know as soon as solution is find. Meanwhile you can check the following code, may be it will be of any help.

    PdfPageEditor pdf = new PdfPageEditor();

    pdf.BindPdf("D:/AsposeTest/pdfPage.pdf");

    Aspose.Pdf.Kit.PageSize psize = new Aspose.Pdf.Kit.PageSize();

    psize.Height = 1000F;

    psize.Width = 600F;

    pdf.PageSize = psize;

    pdf.Save("D:/AsposeTest/outPdfPage.pdf");


    Thanks.

    Adeel Ahmad
    Support Developer
    Aspose Changsha Team
    http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactChangsha.html

     
  •  06-07-2007, 11:18 PM 79886 in reply to 79879

    Re: How to add padding to the bottom of a PDF

    Hi,

    This feature can't be support directly now, I will add a Property for Class PdfPageEditor to support this feature. It maybe take 2~3 days.

    Thanks.


    Georgie Yuan
    Lead Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
  •  06-08-2007, 9:30 AM 79953 in reply to 79886

    Re: How to add padding to the bottom of a PDF

    That would be great.

    If you like any assistance with testing please let me know.


    Ryan Schnieber

    Project Manager
    Electronic Discovery & Computer Forensics On-Site E-Discovery
    832 North Henry Street
    Alexandria, VA 22314
    Office 001-703-276-1123
    International Cellular 001-213-479-0153
     
  •  06-11-2007, 9:00 AM 80101 in reply to 79953

    Re: How to add padding to the bottom of a PDF

    Attachment: Present (inaccessible)
    Hi,

    In Class PdfPageEditor, we have added property Alignment and VerticalAlignment to set the alignment ways between the original page and result page.

    You can write code like this:

    PdfPageEditor pdf = new PdfPageEditor();
    pdf.BindPdf(TestPath + "pdfPage.pdf");
    Aspose.Pdf.Kit.PageSize psize = new Aspose.Pdf.Kit.PageSize();
    psize.Height = 1000F;
    psize.Width = 600F;
    pdf.PageSize = psize;

    //add this two line
    pdf.Alignment = AlignmentType.Center;
    pdf.VerticalAlignment = VerticalAlignmentType.Top;

    pdf.Save(TestPath + "outPdfPage.pdf");

    Best Regards.

    Georgie Yuan
    Lead Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
View as RSS news feed in XML