简体   繁体   中英

adding new pages and labels to new pdf document using itextsharp

I am working pdf creation using itextsharp in c#. i am able to create a new document but when i am unable to add pages to the document. And also i am unable to get the page label or change it.

The properties like "writer.SetPageEmpty" or "this.AddPageWithBasicFormatting(Doc)" are showing error. The error shown is

Error 1 'iTextSharp.text.pdf.PdfWriter' does not contain a definition for 'SetPageEmpty' and no extension method 'SetPageEmpty' accepting a first argument of type 'iTextSharp.text.pdf.PdfWriter' could be found (are you missing a using directive or an assembly reference?)

Can anyone please suggest me how to tackle this? Please help

Thanks

Hello you can simply add new page using below code :-

 Document document = new Document();
 document.Open();
 document.NewPage();

And to add label please use below code :-

 static Font FontSubHeading = FontFactory.GetFont("gothic", 10, Font.NORMAL, new BaseColor(System.Drawing.ColorTranslator.FromHtml("#404041").ToArgb()));
   Paragraph DearName = new Paragraph("test", FontSubHeading);                           
   document.Add(DearName);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM