We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Add Horizontal Line to Footer of PDF document

Hi

I wanted to add Horizontal Line ( footer) to the Existing PDF document

I am trying the following code below to get that..but the Line is not coming properly. Please suggest me how to add a line to the existing PDF document.

Dim textStamp1 As New Aspose.Pdf.TextStamp("___________________________________________________________________________________")

'set properties of the stamp

textStamp1.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Left

textStamp1.VerticalAlignment = Aspose.Pdf.VerticalAlignment.Bottom

textStamp1.TextState.FontStyle = Aspose.Pdf.Text.FontStyles.Bold

textStamp1.BottomMargin = 30

Dim textStamp2 As New Aspose.Pdf.TextStamp(" Classification: Test")

'set properties of the stamp

textStamp2.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Left

textStamp2.VerticalAlignment = Aspose.Pdf.VerticalAlignment.Bottom

textStamp2.TextState.FontStyle = Aspose.Pdf.Text.FontStyles.Bold

textStamp2.TextState.FontSize = 10

textStamp2.TextState.Font = Aspose.Pdf.Text.FontRepository.FindFont("Times New Roman")

textStamp2.BottomMargin = 15

'create page number stamp

Dim pageNumberStamp As New Aspose.Pdf.PageNumberStamp()

'whether the stamp is background

pageNumberStamp.Background = False

pageNumberStamp.TextState.FontSize = 15

pageNumberStamp.TextState.FontStyle = Aspose.Pdf.Text.FontStyles.Bold

pageNumberStamp.Format = "Page - # "

pageNumberStamp.BottomMargin = 15

pageNumberStamp.HorizontalAlignment = HorizontalAlignment.Center

pageNumberStamp.StartingNumber = 1

for Each pg As Aspose.Pdf.Page In finalPDF.Pages

pg.AddStamp(pageNumberStamp)

pg.AddStamp(textStamp1)

pg.AddStamp(textStamp2)

Next

Hi Sreenivasulu,


Thanks for using our products.

In order to accomplish your requirement, you may consider using CreatePolyLine(…) method of PdfContentEditor class. Please try using the following code snippet to add Horizontal line in footer region.

[C#]

// instantiate PdfContentEditor object<o:p></o:p>

PdfContentEditor editor = new PdfContentEditor();

// bind the source PDf file

editor.BindPdf("d:/pdftest/input.pdf");

// create lineinfo object

LineInfo lineInfo = new LineInfo();

// specify the dimensions for line object

lineInfo.VerticeCoordinate = new float[] { 0, 70, 600, 70};

// specify the visibility of line to true

lineInfo.Visibility = true;

// create a polyline

editor.CreatePolyLine(lineInfo, 1, new System.Drawing.Rectangle(0, 0, 0, 0), "Welcome to Aspose");

// save the update PDF with horizontal line

editor.Save("d:/pdftest/Pdf_with_Horizontal_Line.pdf");

Hi

Thanks for your email and code. I am able to display Horizontal Line on PDF document, But When i print this PDF document, I did not see Horizontal Line. Could you please suggest me. I need to horizontal line after printing also.

Thanks,

Sree

Hi Sree,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for the feedback.

I am able to reproduce your mentioned issue after an initial test. Your issue has been registered in our issue tracking system as PDFNEWNET-34442. We will notify you via this forum thread regarding any update against your issue.

Sorry for the inconvenience,

Hi Sree,


Thanks for your patience. We have further looked into the issue (PDFNEWNET-34442) and would suggest to add line as following, It will print successfully.

string inputFile = @“c:\test.pdf”;
// Any file<o:p></o:p>

string outputFile = @"c:\out.pdf";

// instantiate PdfContentEditor object

using (PdfContentEditor editor = new PdfContentEditor())

{

// bind the source PDf file

editor.BindPdf(inputFile);

// create lineinfo object

LineInfo lineInfo = new LineInfo();

// specify the dimensions for line object

lineInfo.VerticeCoordinate = new float[] { 0, 70, 600, 70 };

// specify the visibility of line to true

lineInfo.Visibility = true;

// create a polyline

editor.CreatePolyLine(lineInfo, 1, new System.Drawing.Rectangle(1, 1, 1, 1), "Welcome to Aspose");

// save the update PDF with horizontal line

editor.Save(outputFile);

}

Please feel free to contact us for any further assistance.


Best Regards,