1
Answer

How to create sections in hiqpdf

Photo of kavya m

kavya m

2y
605
1

How to create sections in hiqpdf and pageview layout (two pages view  in single page ).

Answers (1)

1
Photo of Leon D
489 2.7k 387 2y

You can use Spire.PDF library to create sections in pdf and set page view layout.

https://www.e-iceblue.com/Download/download-pdf-for-net-now.html

Code sample:

using Spire.Pdf;
using Spire.Pdf.Graphics;
using System.Drawing;

namespace CreateSections
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a PDF document
            PdfDocument pdf = new PdfDocument();

            PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial", 11f));

            //Add the first section
            PdfSection section1 = pdf.Sections.Add();
            section1.PageSettings.Size = PdfPageSize.A4;
            section1.PageSettings.Margins = new PdfMargins(30);
            //Add a page to the first section
            PdfPageBase page1 = section1.Pages.Add();
            //Draw some text on the page
            page1.Canvas.DrawString("This is Page 1", font, PdfBrushes.Black, 0, 50);

            //Add the second section
            PdfSection section2 = pdf.Sections.Add();
            section2.PageSettings.Size = PdfPageSize.A4;
            section2.PageSettings.Margins = new PdfMargins(0);
            //Add a page to the section section
            PdfPageBase page2 = section1.Pages.Add();
            //Draw some text on the page
            page2.Canvas.DrawString("This is Page 2", font, PdfBrushes.Black, 0, 50);

            //Set page layout
            pdf.ViewerPreferences.PageLayout = PdfPageLayout.TwoPageLeft;

            //Save the result document
            pdf.SaveToFile("Output.pdf");
            System.Diagnostics.Process.Start("Output.pdf");
        }
    }
}