我正在尝试创建一个看起来像这样的PDF文档。它使用大量选项卡来指示列表级别和其他文档,例如它可以使用自定义枚举。
http://mgaleg.maryland.gov/2018RS/Statute_Web/gab/1-101.pdf 我似乎无法使用\ t为段落添加选项卡。
我尝试使用列表,但我需要自定义枚举。我也只需要第一行来缩进。
例如,如果没有标签,我就无法创建以下内容。
§1-101。 (a)在本文中,在本文中,以下词语具有所指的含义。
(b) (1) Some other language that wraps but is aligned to the left margin if we go to another line.
(2) Some other text.
利用列表的iTextSharp代码不会像我需要的那样换行到下一行的左边距,我需要准确控制枚举器的内容。它们可能是(A-1)或作者想要创建文档的任何其他方式。
编辑:
我升级到.Net中的iText 7。 我使用以下代码让我更接近我正在寻找的东西。
String dest = "c:\\temp\\abc.pdf";
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(dest));
Document doc = new Document(pdfDoc);
var font = PdfFontFactory.CreateFont(StandardFonts.TIMES_ROMAN);
Paragraph p = new Paragraph();
p.Add("Article - Alcoholic Beverages");
p.SetFont(font);
p.SetTextAlignment(TextAlignment.CENTER);
doc.Add(p);
p = new Paragraph();
p.Add("§1-101.");
p.SetFont(font);
doc.Add(p).SetFont(font);
p = new Paragraph();
p.SetFirstLineIndent(25);
p.AddTabStops(new TabStop(1f, TabAlignment.LEFT));
p.Add("(a)");
p.Add(new Tab()); p.Add("In this article the following words have the meanings indicated.");
doc.Add(p).SetFont(font);
p = new Paragraph();
p.SetFirstLineIndent(25);
p.AddTabStops(new TabStop(1f, TabAlignment.LEFT));
p.Add("(b)");
p.Add(new Tab()); p.Add("(1)");
p.Add(new Tab()); p.Add("“Alcoholic beverage” means a spirituous, vinous, malt, or fermented liquor, liquid, or compound that: ");
doc.Add(p).SetFont(font);
p = new Paragraph();
p.SetFirstLineIndent(25);
p.AddTabStops(new TabStop(1f, TabAlignment.LEFT));
p.Add(new Tab()); p.Add(new Tab()); p.Add("(i)");
p.Add(new Tab()); p.Add("contains at least one–half of 1% of alcohol by volume; and");
doc.Add(p).SetFont(font);
p = new Paragraph();
p.SetFirstLineIndent(25);
p.AddTabStops(new TabStop(1f, TabAlignment.LEFT));
p.Add(new Tab()); p.Add(new Tab()); p.Add("(ii)");
p.Add(new Tab()); p.Add("is suitable for beverage purposes.");
doc.Add(p).SetFont(font);
p = new Paragraph();
p.SetFirstLineIndent(25);
p.AddTabStops(new TabStop(1f, TabAlignment.LEFT));
p.Add(new Tab()); p.Add("(2)");
p.Add(new Tab()); p.Add("“Alcoholic beverage” includes alcohol, brandy, whiskey, rum, gin, cordial, beer, and wine.");
doc.Add(p).SetFont(font);
p = new Paragraph();
p.SetFirstLineIndent(25);
p.AddTabStops(new TabStop(1f, TabAlignment.LEFT));
p.Add(new Tab()); p.Add("(3)");
p.Add(new Tab()); p.Add("“Alcoholic beverage” does not include a confectionery food product that contains up to 5 % of alcohol by volume and is regulated by the Maryland Department of Health under § 21–209 of the Health – General Article.");
doc.Add(p).SetFont(font);
doc.Close();