在ITextSharp免费许可证下动态创建.pdfs
本文关键字:动态 创建 pdfs 许可证 ITextSharp 免费 | 更新日期: 2023-09-27 18:26:56
在ASP.NET C#网站/服务器中,我使用名为ITextSharp的.pdf creater库来创建带有文本&一些关于产品的图片。
和往常一样,老板不想买执照。我知道,如果我使用ITextSharp 4.1.6或更低版本,我可以在免费许可证下使用该库(不是吗?)
我的问题:旧版本(4.1.6-)/免费版本是否满足我生成顶部有图像、中间有文本内容(某些段落)、底部有图像的pdf的需求?我会发现一些API函数对我自己不可用,因为我有旧版本吗?
你会建议我使用另一个开源的ASP.NET C#.pdf生成器吗?
是的,您可以这样做,旧版本也可以。我已经附上了使用字符串生成器生成带有itext Sharp的html的代码。
Document doc = new Document(PageSize.LETTER, 10, 10, 42, 35);
iTextSharp.text.pdf.PdfWriter wri = iTextSharp.text.pdf.PdfWriter.GetInstance(doc, new FileStream("D:''PurchaseOrderDetails.pdf", FileMode.Create));
doc.Open();//
StringBuilder builder = new StringBuilder();
builder.Append("<html>");
builder.Append("<head>");
builder.Append("</head>");
builder.Append("<body>");
builder.Append("<img src='"D:''Images''logo_left.png'" align='"right'"/>");
builder.Append("<br/><br/><br/><br>");
builder.Append("");
builder.Append("<h1 style='"font-weight: bold'">Purchase Order Details</h1> ");
builder.Append("");
builder.Append("<br /><br /> ");
builder.Append("<h2 style='"font-weight: bold'">Purchase Order Information</h2> ");
builder.Append("<table> ");
builder.Append(" <tr> ");
builder.Append(" <td style='"font-weight: bold'">P.O.Number:</td> ");
builder.Append(" <td>" + txtPONumber.Text + "</td> ");
builder.Append(" </tr> ");
builder.Append(" <tr> ");
builder.Append(" <td style='"font-weight: bold'">Vendor:</td> ");
builder.Append(" <td>" + txtVendorName.Text + "</td> ");
builder.Append(" </tr> ");
builder.Append(" <tr> ");
builder.Append(" <td style='"font-weight: bold'">Entry Date:</td> ");
builder.Append(" <td>" + dtpickerEntryDate.SelectedDate + "</td> ");
builder.Append(" </tr> ");
builder.Append(" <tr> ");
builder.Append(" <td style='"font-weight: bold'">Description:</td> ");
builder.Append(" <td>" + txtDescription.Text + "</td> ");
builder.Append(" </tr> ");
builder.Append(" <tr> ");
builder.Append(" <td style='"font-weight: bold'">Ship Method:</td> ");
builder.Append(" <td>" + drpShipMethod.SelectedItem.Text + "</td> ");
builder.Append(" </tr> ");
builder.Append(" <tr> ");
builder.Append(" <td style='"font-weight: bold'">Ship Carrier:</td> ");
builder.Append(" <td>" + drpShipCarrier.SelectedItem.Text + "</td> ");
builder.Append(" </tr> ");
builder.Append(" <tr> ");
builder.Append(" <td style='"font-weight: bold'">Price:</td> ");
builder.Append(" <td>" + txtPrice.Text + "</td> ");
builder.Append(" </tr> ");
builder.Append(" <tr> ");
builder.Append(" <td style='"font-weight: bold'">Shipping Cost:</td> ");
builder.Append(" <td>" + txtShippingCost.Text + "</td> ");
builder.Append(" </tr> ");
builder.Append(" <tr> ");
builder.Append(" <td style='"font-weight: bold'">Warranty Status:</td> ");
builder.Append(" <td>" + txtWarrantyStatus.Text + "</td> ");
builder.Append(" </tr> ");
builder.Append(" <tr> ");
builder.Append(" <td style='"font-weight: bold'">Part Requirement:</td> ");
builder.Append(" <td>" + drpPartRequirement.SelectedItem.Text + "</td> ");
builder.Append(" </tr> ");
builder.Append("</table> ");
builder.Append("<br /><br /> ");
builder.Append(" ");
builder.Append("<p style='"text-align: center; font-style: italic; font-size: 10pt'"> ");
builder.Append(" Thank you for your business! If you have any questions about your order, please contact us at ");
builder.Append(" 800-555-. ");
builder.Append("</p> ");
builder.Append("</body>");
builder.Append("</html>");
var parsedHtmlElements = HTMLWorker.ParseToList(new StringReader(builder.ToString()), null);
foreach (var htmlElement in parsedHtmlElements)
doc.Add(htmlElement as IElement);
doc.Close();