简体   繁体   English

使用itextsharp向新的pdf文档添加新页面和标签

[英]adding new pages and labels to new pdf document using itextsharp

I am working pdf creation using itextsharp in c#. 我正在使用C#中的itextsharp进行pdf创建。 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. 像“ writer.SetPageEmpty”或“ this.AddPageWithBasicFormatting(Doc)”之类的属性显示错误。 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?) 错误1'iTextSharp.text.pdf.PdfWriter'不包含'SetPageEmpty'的定义,并且找不到扩展方法'SetPageEmpty'接受类型为'iTextSharp.text.pdf.PdfWriter'的第一个参数(您是否缺少使用指令还是程序集引用?)

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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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