Hi,
I’m having trouble trying to dynamically generate a line at the bottom of the page with my footer. I’ve called ProcessParagraphs() used an ImageStamp, TextStamp, and PageNumberStamp for most of the footer content, but I’ve been unable to find a good way to position a page rule above this. This line will be about 40 points from the bottom margin and the page’s bottom margin is about 47 points. The only way I’ve gotten something to draw properly is using the header, but it looks like the line disappears when page.PageInfo.isLandscape = true.
foreach (Page page in PdfDoc.Pages)
{
page.AddStamp(imageStamp);
page.AddStamp(textStamp);
page.AddStamp(pageNumberStamp);
page.Header = new HeaderFooter { Margin = new MarginInfo(27f, 0, 0, 0) };
var graph = new Aspose.Pdf.Drawing.Graph((float)page.MediaBox.Width, (float)page.MediaBox.Height);
var ruleLength = page.MedianBox.Width - 54;
var posArray = new[]
{
0f,
40f,
ruleLength,
4
};
var line = new Aspose.Pdf.Drawing.Line(posArray)
{
GraphInfo = { LineWidth = 0.75f }
};
graph.Shapes.Add(line);
page.Header.Paragraphs.Add(graph);
}
Is there a better way for me to position this line that won’t affect the content that’s already rendered in the page’s paragraphs?
Hi Ryan,
string inputFile = @“c:\test.pdf”; // Any file<o:p></o:p>
string outputFile = @“c:\out.pdf”;<o:p></o:p>
// instantiate PdfContentEditor object<o:p></o:p>
using (PdfContentEditor editor = new PdfContentEditor())<o:p></o:p>
{<o:p></o:p>
// bind the source PDf file<o:p></o:p>
editor.BindPdf(inputFile);<o:p></o:p>
// create lineinfo object<o:p></o:p>
LineInfo lineInfo = new LineInfo();<o:p></o:p>
// specify the dimensions for line object<o:p></o:p>
lineInfo.VerticeCoordinate = new float[] { 0, 70, 600, 70 };<o:p></o:p>
// specify the visibility of line to true<o:p></o:p>
lineInfo.Visibility = true;<o:p></o:p>
// create a polyline<o:p></o:p>
editor.CreatePolyLine(lineInfo, 1, new System.Drawing.Rectangle(1, 1, 1, 1), “Welcome to Aspose”);<o:p></o:p>
// save the update PDF with horizontal line<o:p></o:p>
editor.Save(outputFile);<o:p></o:p>
}
Hi,
Hi Ryan,
Document doc = new
Document(inputFile);<o:p></o:p>
// instantiate PdfContentEditor object
PdfContentEditor editor = new PdfContentEditor();
// bind the source PDf file
editor.BindPdf(doc);
// 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), "");
// save the update PDF with horizontal line
doc.Flatten();
doc.Save(outputFile);
Please feel free to contact us for any further assistance.
Best Regards,