How to create header text along with image and how to add page borders

Could you please provide code sample to add header text along with image, borders to the page.

while using imagestamp and Textstamp(to add header text) to add both image and headertext, the image is replacing headrtext

please suggest

@SAIKUMAR271

Would you please provide the sample code snippet that you are using along with an expected output PDF? We will test the scenario in our environment and address it accordingly.

Please find the below code snippet. my requirement is to in the top left side need to have Image along with Header text above the border. In the Main area of doc(Inside border) need to have data table and and multiline text.(text001 = multiline text and this text should be below the table). There should be break between table and text(While i am doing it is coming very next to table need line break between table and text)

Document document = new Document();

Aspose.Pdf.Page page = document.pages.Add();

DataTable dt = new DataTable(“Sample”);

// Adding columns to the DataTable
dt.Columns.Add("Beginning of lease", typeof(Int32));
dt.Columns.Add("End of lease", typeof(Int32));
dt.Columns.Add("Landlord's end-of-lease assessment", typeof(string));
dt.Columns.Add("Comments", typeof(string));

// Adding rows to the DataTable
DataRow dr = dt.NewRow();
dr[0] = 12;
dr[1] = 11;
dr[2] = "$32.38";
dr[3] = "M";
dt.Rows.Add(dr);

dr = dt.NewRow();
dr[0] = 22;
dr[1] = 22;
dr[2] = "$148.45";
dr[3] = "G";
dt.Rows.Add(dr);

dr = dt.NewRow();
dr[0] = 41;
dr[1] = 41;
dr[2] = "$11.42";
dr[3] = "S,R";
dt.Rows.Add(dr);

dr = dt.NewRow();
dr[0] = 47;
dr[1] = 40;
dr[2] = "$48.52";
dr[3] = "D";
dt.Rows.Add(dr);

dr = dt.NewRow();
dr[0] = 28;
dr[1] = 20;
dr[2] = "$78.43";
dr[3] = "R";
dt.Rows.Add(dr);

Aspose.Pdf.Document doc = new Aspose.Pdf.Document();
Aspose.Pdf.Page page = doc.Pages.Add();

Aspose.PDF.Table tab1 = new Aspose.Pdf.Table();

tab1.columnwidths = “100 100 100 100”;

tab1.Importdatatable(dt,true, 0, 0,3,5);

String text001 = “Using txtfrangment add mutiple line of text”;

TextFragment txtfragment = new Textfragment();
txtfragment .Text = text001;

Aspose.Pdf.Drawing.Graph graph = new Aspose.Pdf.Drawing.Graph((float)page.PageInfo.Width, (float)page.PageInfo.Height);
page.PageInfo.Margin = new MarginInfo(0, 0, 0, 0);
page.Paragraphs.Add(graph);
Aspose.Pdf.Drawing.Line bottomline = new Aspose.Pdf.Drawing.Line(new float[] { 10, 10, (float)page.PageInfo.Width - 10, 10 });
Aspose.Pdf.Drawing.Line topline = new Aspose.Pdf.Drawing.Line(new float[] { 10, (float)page.PageInfo.Height - 10, (float)page.PageInfo.Width - 10, (float)page.PageInfo.Height - 10 });
Aspose.Pdf.Drawing.Line rightline = new Aspose.Pdf.Drawing.Line(new float[] { (float)page.PageInfo.Width - 10, 10, (float)page.PageInfo.Width - 10, (float)page.PageInfo.Height - 10 });
Aspose.Pdf.Drawing.Line leftline = new Aspose.Pdf.Drawing.Line(new float[] { 10, 10, 10, (float)page.PageInfo.Height - 10 });
graph.Shapes.Add(topline);
graph.Shapes.Add(bottomline);
graph.Shapes.Add(rightline);
graph.Shapes.Add(leftline);
graph.ZIndex = 0;

/ Create Image
ImageStamp imageStamp = new ImageStamp(dataDir+ “aspose-logo.jpg”);
// Set properties of the stamp
imageStamp.TopMargin = 10;
imageStamp.HorizontalAlignment = HorizontalAlignment.Left;
imageStamp.VerticalAlignment = VerticalAlignment.Top;

// Create header
TextStamp textStamp = new TextStamp(“Header Text”);
// Set properties of the stamp
textStamp.TopMargin = 50;
textStamp.HorizontalAlignment = HorizontalAlignment.Left;
textStamp.VerticalAlignment = VerticalAlignment.Top;

page.Addstamp(imageStamp);
page.Addstamp(textStamp );
page.Paragraphs.Add(tab1);
page.Paragraphs.Add(txtfragment);

document.Save(datadir);

@SAIKUMAR271

We were able to notice that the border of the page was shifting its position according to the content which was being added to the page. We will further investigate the issue however, could you please share a sample PDF document which is your expected output you want to generate using the API. We will try to generate similar output using code snippet and share our feedback with you.