动态地创建下iTextSharp的自由许可.pdfs [英] Dynamically creating .pdfs under the ITextSharp Free Licence
问题描述
在一个ASP.NET C#网站/服务器我使用所谓iTextSharp的创建与文字和放大器.pdfs该.pdf创世库;一些图像有关的产品。
In a ASP.NET C# website/server I am using the .pdf creater library called ITextSharp to create .pdfs with text & some images about a product.
像往常一样,老板不希望购买许可证。我知道,如果我使用iTextSharp的版本4.1.6或降低我可以使用该库下的免费许可(广东话吗?)
As usual the boss doesn't want to purchase a licence. I know that if I use ITextSharp versions 4.1.6 or lower I can use the library under the free licence(cant I?)
我的问题:请问老版本(4.1.6 - )/免费版满足我的生成与顶部的图像的PDF格式的需求,在中间的文本内容(一些段落)和在底部的形象呢?我会找到不提供给自己一些API函数,因为我有旧版本?
My Question: Will the older versions(4.1.6-)/free versions meet my needs of generating a pdf with an image at the top, text content in the middle(some paragraphs) and an image at the bottom? Will I find some API functions not available to myself because I have the older versions?
你会建议我去另一个开源ASP.NET C#发电机.PDF?
Would you suggest I go to another open source ASP.NET C# .pdf generator?
推荐答案
是的,你可以做到这一点,与旧版本了。我重视使用字符串生成器与夏普的iText生成html的code。
Yes you can do it, with older versions too. I have attached the code that uses the string builder to generate html with itext Sharp.
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();
这篇关于动态地创建下iTextSharp的自由许可.pdfs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!