Border Issue While Multiple pages

I have big Html in a single string. I cant insert border for the whole page with adding Paragraphs option in aspose, and an issue with border it is overlapping with content my code is below

Document pdfDocument = new Document();
        var htmlStrinfg = "long_html_string";
        var fullc = new HtmlFragment(htmlStrinfg);
        string strHtml = "<table style=\"height: 18px; width: 100%; background-color: #03a9f4;\"><tbody><tr style=\"height: 18px;\"><td style=\"color: blue; height: 18px; width: 98.8166%;\" align=\"left\"><span style=\"color: #ffffff;\"> [TemplateName]12</span></td><td style=\"height: 18px; width: 0.986193%;\" align=\"right\"><span style=\"color: #ffffff;\"><img id=\"imgCompanyLogo\" style=\"width: 312px; height: 100px;\" src=\"../images/CompanyLogoPdf.png\" /></span></td></tr></tbody></table>";

        Aspose.Pdf.HtmlFragment headerHtml = new Aspose.Pdf.HtmlFragment(strHtml);
        Aspose.Pdf.HeaderFooter hf;

        foreach (Aspose.Pdf.Page page in pdfDocument.Pages)
        {
            Aspose.Pdf.Drawing.Graph graph = new Aspose.Pdf.Drawing.Graph((float)page.PageInfo.Width, (float)page.PageInfo.Height);
            page.PageInfo.Margin = new MarginInfo(0, 1, 0, 65);
            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);

            hf = new Aspose.Pdf.HeaderFooter();
            hf.Paragraphs.Add(headerHtml);
            hf.Margin.Top = 0;
            hf.Margin.Left = 0;
            hf.Margin.Right = 0;
            hf.Margin.Bottom = 10;
            page.Header = hf;
        }

        MemoryStream outStream = new MemoryStream();
        pdfDocument.Save(outStream);
        HttpContext.Current.Response.Expires = 0;
        HttpContext.Current.Response.Buffer = true;
        HttpContext.Current.Response.ClearContent();
        HttpContext.Current.Response.AddHeader("content-disposition", "inline; filename=output.pdf");
        HttpContext.Current.Response.ContentType = "application/pdf";
        HttpContext.Current.Response.BinaryWrite(outStream.ToArray());
        outStream.Close();
        HttpContext.Current.Response.End();

@mehaboob

Thank you for contacting support.

We have modified your code snippet a little and tried plugging in different values for expected results. Below is a code snippet and generated PDF document for your kind reference. Border_19.9.pdf

Document pdfDocument = new Document();
pdfDocument.Pages.Add();
var htmlStrinfg = "long_html_string";
var fullc = new HtmlFragment(htmlStrinfg);
string strHtml = "<table style=\"height: 18px; width: 100%; background-color: #03a9f4;\"><tbody><tr style=\"height: 18px;\"><td style=\"color: blue; height: 18px; width: 98.8166%;\" align=\"left\"><span style=\"color: #ffffff;\"> [TemplateName]12</span></td><td style=\"height: 18px; width: 0.986193%;\" align=\"right\"><span style=\"color: #ffffff;\"><img id=\"imgCompanyLogo\" style=\"width: 312px; height: 100px;\" src=\"../images/CompanyLogoPdf.png\" /></span></td></tr></tbody></table>";

Aspose.Pdf.HtmlFragment headerHtml = new Aspose.Pdf.HtmlFragment(strHtml);
Aspose.Pdf.HeaderFooter hf;

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

    hf = new Aspose.Pdf.HeaderFooter();
    hf.Paragraphs.Add(headerHtml);
    hf.Margin.Top = 2;
    hf.Margin.Left = 2;
    hf.Margin.Right = 2;
    hf.Margin.Bottom = 10;
    page.Header = hf;
}

MemoryStream outStream = new MemoryStream();
pdfDocument.Save(dataDir + "Border_19.9.pdf");

We hope this will be helpful. Please feel free to contact us if you need any further assistance.

Thank you for your response.

Still, we having issues that we have already mentioned. While we inserting Html As content the header is overlapping and the content is coming on outside of the border. and another question is can we add padding for border now it is coming on the edges of the page.
here is my code

Document pdfDocument = new Document();
        var fullc = new HtmlFragment("<H1>Test</H1>");
        string strHtml = "<table style=\"height: 18px; width: 100%; background-color: #03a9f4;\"><tbody><tr style=\"height: 18px;\"><td style=\"color: blue; height: 18px; width: 98.8166%;\" align=\"left\"><span style=\"color: #ffffff;\"> [TemplateName]12</span></td><td style=\"height: 18px; width: 0.986193%;\" align=\"right\"><span style=\"color: #ffffff;\"><img id=\"imgCompanyLogo\" style=\"width: 312px; height: 200px;\" src=\"../images/CompanyLogoPdf.png\" /></span></td></tr></tbody></table>";

        Aspose.Pdf.HtmlFragment headerHtml = new Aspose.Pdf.HtmlFragment(strHtml);
        Aspose.Pdf.HeaderFooter hf;
        pdfDocument.Pages.Add().Paragraphs.Add(fullc);
        foreach (Aspose.Pdf.Page page in pdfDocument.Pages)
        {
            Aspose.Pdf.Drawing.Graph graph = new Aspose.Pdf.Drawing.Graph((float)page.PageInfo.Width, (float)page.PageInfo.Height);
            page.PageInfo.Margin = new MarginInfo(0, 1, 0, 0);
            page.Paragraphs.Add(graph);
            Aspose.Pdf.Drawing.Line bottomline = new Aspose.Pdf.Drawing.Line(new float[] { 1, 1, (float)page.PageInfo.Width - 1, 1 });
            Aspose.Pdf.Drawing.Line topline = new Aspose.Pdf.Drawing.Line(new float[] { 1, (float)page.PageInfo.Height - 1, (float)page.PageInfo.Width - 1, (float)page.PageInfo.Height - 1 });
            Aspose.Pdf.Drawing.Line rightline = new Aspose.Pdf.Drawing.Line(new float[] { (float)page.PageInfo.Width - 1, 1, (float)page.PageInfo.Width - 1, (float)page.PageInfo.Height - 1 });
            Aspose.Pdf.Drawing.Line leftline = new Aspose.Pdf.Drawing.Line(new float[] { 1, 1, 1, (float)page.PageInfo.Height - 1 });
            topline.GraphInfo.Color = Color.Red;
            bottomline.GraphInfo.Color = Color.Red;
            rightline.GraphInfo.Color = Color.Red;
            leftline.GraphInfo.Color = Color.Red;

            graph.Shapes.Add(topline);
            graph.Shapes.Add(bottomline);
            graph.Shapes.Add(rightline);
            graph.Shapes.Add(leftline);

            hf = new Aspose.Pdf.HeaderFooter();
            hf.Paragraphs.Add(headerHtml);
            hf.Margin.Top = 2;
            hf.Margin.Left = 2;
            hf.Margin.Right = 2;
            hf.Margin.Bottom = 10;
            page.Header = hf;
        }

The variable fullc will have a long HTML it will be more than 11 pages. I sure aspose will automatically generate pages

@mehaboob

Would you please share your sample HTML string longer than several pages for our reference.

@Farhan.Raza

Here is the sample html, and one more issue is aspose generating only 4 pages. is that fix by purchase?
demo.zip (9.3 KB)

@mehaboob

Thank you for sharing data.

We have been able to notice the problem with multiple pages and a ticket with ID PDFNET-46992 has been logged in our issue management system for further investigations. We will let you know once any update will be available in this regard.

About four pages, you are currently facing evaluation limitation which allows to process only four items from any collection, along with evaluation watermark, as explained in Licensing . You may avoid this limitation and test the API in its full capacity by applying a free 30-days temporary license .

@Farhan.Raza Is there any update

@mehaboob

Please note that the issue has been logged under free support model and will be investigated on first come first serve basis. Therefore, it may take some months to resolve. As soon as we have some definite updates regarding ticket resolution, we will let you know.

Furthermore, we also offer paid support model where issues are resolved on urgent basis and have priority over the issues logged under free support model. You may check our Paid Support options for your reference.