itextsharp

iTextSharp exception: PDF header signature not found

匿名 (未验证) 提交于 2019-12-03 01:31:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using iTextSharp to read the contents of PDF documents: PdfReader reader = new PdfReader(pdfPath); using (StringWriter output = new StringWriter()) { for (int i = 1; i 99% of the time it works just fine. However, there is this one PDF file that will sometimes throw this exception: PDF header signature not found. StackTrace: at iTextSharp.text.pdf.PRTokeniser.CheckPdfHeader() at iTextSharp.text.pdf.PdfReader.ReadPdf() at iTextSharp.text.pdf.PdfReader..ctor(String filename, Byte[] ownerPassword) at Reader.PDF.DownloadPdf(String url) in C:

ITextSharp HTML to PDF?

匿名 (未验证) 提交于 2019-12-03 01:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'd like to know if ITextSharp has the capability of converting HTML to PDF. Everything I will convert will just be plain text but unfortunately there is very little to no documentation on ITextSharp so I can't determine if that will be a viable solution for me. If it can't do it, can someone point me to some good, free .net libraries that can take a simple plain text HTML document and convert it to a pdf? tia. 回答1: I came across the same question a few weeks ago and this is the result from what I found. This method does a quick dump of HTML

Reading PDF content with itextsharp dll in VB.NET or C#

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How can I read PDF content with the itextsharp with the Pdfreader class. My PDF may include Plain text or Images of the text. 回答1: using iTextSharp.text.pdf; using iTextSharp.text.pdf.parser; using System.IO; public string ReadPdfFile(string fileName) { StringBuilder text = new StringBuilder(); if (File.Exists(fileName)) { PdfReader pdfReader = new PdfReader(fileName); for (int page = 1; page 回答2: You can't read and parse the contents of a PDF using iTextSharp like you'd like to. From iTextSharp's SourceForge tutorial : You can't 'parse' an

dataGridView to pdf with itextsharp

匿名 (未验证) 提交于 2019-12-03 01:18:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a problem while trying to get values of specific columns in dataGridView and add them to the PdtPtable. But the values added in the table is repeated, for example row one is added twice.I tried to go through each row and in every row through each column. PdfPTable pdfTable= new PdfPTable(5); foreach(DataGridViewRow row in dataGridView1.Rows) { foreach (DataGridViewCell celli in row.Cells) { try { pdfTable.AddCell(celli.Value.ToString()); } catch { } } doc.Add(pdfTable); } 回答1: I have fixed the indentation in your code snippet. You can

iTextSharp “The document has no pages.”

匿名 (未验证) 提交于 2019-12-03 00:52:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using iTextSharp to update A PDF's file properties: FileStream fs = File.Open(@"C:\Developer\C#Projects\BylawSearch\0001.pdf", FileMode.Open); Document document = new Document(); PdfWriter writer = PdfWriter.GetInstance(document, fs); document.Open(); document.AddSubject("Blah"); document.AddTitle("Blah blah"); document.AddKeywords("Blah blah blah"); document.Close(); I'm getting a "The document has no pages." error from iTextSharp. Any help appreciated. 回答1: You haven't added any information to put on a page ... !! document.Add(new

用Itextsharp 组件导出PDF 的文档的方法

匿名 (未验证) 提交于 2019-12-03 00:43:02
首先,从 点击下载 Itextsharp.dll */ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using iTextSharp.text; using iTextSharp.text.pdf; using System.IO; namespace PdfDemo { /// <summary> /// MainWindow.xaml 的交互逻辑 /// </summary> public partial class MainWindow : Window { public MainWindow() {

Using itextsharp (or any c# pdf library), how to open a PDF, replace some text, and save it again?

非 Y 不嫁゛ 提交于 2019-12-03 00:28:40
Using itextsharp (or any c# pdf library), i need to open a PDF, replace some placeholder text with actual values, and return it as a byte[]. Can someone suggest how to do this? I've had a look at the itext docs and can't figure out where to get started. So far i'm stuck on how to get the source pdf from a PDFReader to a Document object, i presume i'm probably approaching this the wrong way. Thanks a lot In the end, i used PDFescape to open my existing PDF file, and place some form fields in where i need to put my fields, then save it again to create my PDF file. http://www.pdfescape.com Then i

'setIndentationLeft' is not a member of 'iTextsharp.text.Paragraph'

徘徊边缘 提交于 2019-12-02 22:39:19
问题 I am adding paragraph where I am getting error p.setindentationLeft is not a member of itextsharp.text.paragraph. Dim bf As BaseFont = BaseFont.CreateFont() Dim p As New Paragraph(Label + CONTENT, New Font(bf, 12)) Dim indentation As Single = bf.GetWidthPoint(Label, 12) p.setIndentationLeft(indentation) p.setFirstLineIndent(-indentation) Document.Add(p) Document.Add(Chunk.NEWLINE) 回答1: You are using iText code in an iTextSharp application. You need to convert the iText code to iTextSharp code

iTextSharp: Why when adding a image to a pdf page the text font is different?

一个人想着一个人 提交于 2019-12-02 22:09:55
问题 I use Helvetica font and 14 px size for text. The problem is that if a page does not have any image on it the text is very clear, but in a page with at least 1 image the text is getting a little bold. You can see what I mean in images below: * Without image on page * With image on page The correct font is the one that appear in picture #1. How to make all pages have the same font even if the page contains an image or not? Thanks. Sample code: Document document = new Document(PageSize.LETTER);

Using iTextSharp with knockout JavaScript or other MVC / MVVM framework?

巧了我就是萌 提交于 2019-12-02 22:00:08
问题 Ok, since I did find out that I can use iTextSharp to generate a PDF, I went that route. I've got it to where it will save HTML with basic formatting to a PDF. That's not the problem. What I'm needing to do now is take markup with knockout in it, and use the resultant HTML (i.e. the DOM) as my string to pass into the method that creates the PDF. So, for instance, I have a table that's generated with knockout. I need to pass the DOM that was generated by knockout, as a string, into my C#