Footer Margin for the merged pdf...?

Hi,
I have a prolem regards to the footer text that is added in my merged pdf which is generated using the aspose.pdf.kit. Now I am able to position my text to right, middle etc. but its apearing higher almost touching to my page content. Is there any support by aspose using which I can set the margins for the footer.

Hi,

Can you please provide us with the code you are using and the pdf file so that we can better understand your requirement and guide you better.

Thanks.

Let me clarify my requirements once again

1. I have a .pdf already created

2. I am able to successfully insert a footer text for each page in existing document

3. What I want is to set the vertical margin for the footer text. In other words is there any way I can prgram the distance of the footer text from bottom edge of the page.

The sample pdf which I have used is attached.

Here is the code sample that I have used-

PdfFileEditor pdfEditor = new PdfFileEditor();

// InputFileName is stream of input files, OutputFileName is Concatenated File pdfEditor.Concatenate(InputFileName, OutputFileName);

//Call the AddPageNumbers method to add footer in concatenated pdf
//The finalFileName is final Pdf file with added footer.
AddPageNumbers(OutputFileName, finalFileName);

//here is the defination for the AddPageNumbers
private void AddPageNumbers(string OutputFileName, string finalFileName)
{
//file to store the temporary pdf between process
string tempFile = "E:\\Test\\temp.pdf";

PdfFileInfo pdfFileInfo = new PdfFileInfo(OutputFileName);

//Covers preassigned number using a blank image

//Instantiate PdfFileStamp and FormattedText objects
PdfFileStamp fileStamp;

fileStamp = new PdfFileStamp(OutputFileName, finalFileName);

Stamp s = new Stamp();
s.BindImage("E:\\Test\\Image\\footer.jpg"); //footer.jpg is a blank image
s.SetImageSize(pdfFileInfo.GetPageWidth(1), 35);
s.SetOrigin(0, 0);
fileStamp.AddStamp(s);
fileStamp.Close();

//Add footer Text also I need text this to flush left but not supported by aspose so I have set it in middle right now
PdfFileStamp fileStampForText;
fileStampForText = new PdfFileStamp(finalFileName, tempFile);
FormattedText ft1 = new FormattedText("My Footer Text", System.Drawing.Color.Black, "Verdana", EncodingType.Winansi, false, 10);
fileStampForText.AddPageNumber(ft1);
fileStampForText.Close();

// assign new page numbers in pdf
PdfFileStamp fileStampForNumbering;
fileStampForNumbering = new PdfFileStamp(tempFile, finalFileName);
FormattedText ft2 = new FormattedText("Page #", System.Drawing.Color.Black , "Verdana", EncodingType.Winansi , false, 10);
fileStampForNumbering.AddPageNumber(ft2,1);
fileStampForNumbering.Close();
File.Delete(tempFile);
}


Hi,

Thanks for the code and the sample pdf. I've added this post as a comment of PdfKitNet-4620 and set the issue higher PRI.

Hi,

It has been resolved, please refer to <A href="https://forum.aspose.com/t/128228</A></P> <P>Thanks,</P>

"Well this is good. Now I am able to place the footer text to the left with top margin.
But still the one thing which I am not getting is the footer height. I already send you the code. Using that code when I am pasting image I have used height of the image to 35 (s.SetImageSize(pdfFileInfo.GetPageWidth(1), 35))
but In some cases(see attached pdf) the height is not enough to cover pre-assigned page numbers. What to do in that cases...???"

Hi,

It is very difficulity to set a proper size of the image for different files, and I have no idea with it either.

In fact, there is not such define for header/footer in PDF format, so it is hardly to support the feature of getting size of them.

Thanks,

My objective is not setting size of image. All I want is this:

1. Can I change the current footer margin of an existing .pdf page through Aspose

2. Can I change the distance of the footer text from bottom edge of the page through Aspose.

Thanks and regards.

Hi,

1. It is not supported.

2. It is supported when adding footer text.(using the method PdfFileStamp.AddFooter(Formatted text, float bottomMargin, float leftMargin, float rightMargin), which is added in the Beta version. )

Thanks,