Tag: itextsharp

在itext中使用PdfTextExtractor的问题!

首先请原谅我的英语不好! 我想在pdf文档中搜索“Hello”这样的单词。 所以我必须通过PdfTextExtractor阅读pdf中的每一页。 我做得很好。 我可以分别读取每个页面中的所有单词,并将其保存在字符串缓冲区中。 但是当我在For循环中推送此代码时(例如从第1页到第7页进行搜索),前一页的单词将保留在字符串缓冲区中。我跳了解你的问题。 Tanx全部。 这是我的代码: PdfReader reader2 = new PdfReader(openFileDialog1.FileName); int pagen = reader2.NumberOfPages; reader2.Close(); ITextExtractionStrategy its = new iTextSharp.text.pdf.parser.SimpleTextExtractionStrategy(); for (int i = 1; i < pagen; i++) { textBox1.Text = ""; PdfReader reader = new PdfReader(openFileDialog1.FileName); String s = PdfTextExtractor.GetTextFromPage(reader, i, its); //MessageBox.Show(s.Length.ToString()); //PdfTextArray h = new PdfTextArray(s); // // […]

使用Itextsharp读取本地化的PDF文件

我正在尝试使用iTextSharp阅读PDF文件。 问题是当试图读取除英语(例如印地语或阿拉伯语)之外的PDF文件时,它没有得到正确的单词。 我想知道,我应该在我的系统上安装印地语或阿拉伯语字体还是我需要对编码做些什么? ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy(); string currentText = PdfTextExtractor.GetTextFromPage(pdfReader, page, strategy); currentText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(currentText))); text.Append(currentText); 编辑: 样本PDF图像: 提取的文字: uxj ikfydk ifj“kn fuokZpd ukekoyh&2011 i`”B la [; k%1 1 1 1 &&& ftys dk uke ftys dk uke ftys dk uke ftys dk uke %%%% 0701-ò¶â€ãæ-2 2 2 2 &&&fudk fudk […]

c#/ asp.net – 如何捕获“System.Web.HttpException:Request timed out”?

在我的asp.net/c#项目中,我使用iTextsharp dll从许多pdf文档中读取文本,但有时我会收到此错误 System.Web.HttpException:请求超时。 但是这样做的代码是: public static bool does_pdf_have_keyword(string keyword, string pdf_src) { try { PdfReader pdfReader = new PdfReader(pdf_src); string currentText; int count = pdfReader.NumberOfPages; for (int page = 1; page <= count; page++) { ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy(); currentText = PdfTextExtractor.GetTextFromPage(pdfReader, page, strategy); if (currentText.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) != -1) return true; } pdfReader.Close(); return […]

如何从pdf c#获取具有特定颜色的文本

我必须将pdf文件中的数据放在某个数据库结构中。 这要求我能够从pdf文件中获取某些数据。 由于pdf没有任何标签等…我想知道是否有可能获得基于颜色的文本。 比方说,我想要所有的红色文字。 或者我想要文档中的所有斜体文本。 这可能在C#中吗? 或者是否有其他方法可以轻松过滤pdf文档中的数据?

使用iTextSharp将pdf显示到网页?

我正在使用iTextSharp生成pdf。 我想在网页上显示它,让用户从在线pdf查看器中保存它。 dynamicpdf有一个drawtoweb()方法,但它不能免费使用,我无法使用iTextSharp找到相同的function。 如何显示pdf? string newFile = “Pdf Document.pdf”; Document doc = new Document(); PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(newFile, FileMode.Create)); doc.AddCreator(“Myself”); doc.AddTitle(“Sample PDF Document”); doc.Open(); doc.Add(new Paragraph(“Hello, World!”)); doc.Close();

在iTextSharp中的旋转PdfPCell中创建本地链接

我正在尝试使用iTextSharp在我的pdf中添加指向另一个页面的链接。 旋转单元格中的链接不起作用。 其他单元格按预期工作: FileStream fs = new FileStream(“TestPDF.pdf”, FileMode.Create, FileAccess.Write, FileShare.None); Document doc = new Document(); PdfWriter writer = PdfWriter.GetInstance(doc, fs); doc.Open(); PdfPTable linkTable = new PdfPTable(2); PdfPCell linkCell = new PdfPCell(); linkCell.HorizontalAlignment = Element.ALIGN_CENTER; linkCell.Rotation = 90; linkCell.FixedHeight = 70; Anchor linkAnchor = new Anchor(“Click here”); linkAnchor.Reference = “#target”; Paragraph linkPara = new Paragraph(); […]

iTextSharp – 移动Acrofield

我有一个将内容表插入现有Acroform的过程,我能够跟踪启动该内容所需的位置。 但是,根据我插入的表的高度,我在该点之下存在需要向上或向下移动的Acrofield。 有了这个,我怎样才能改变Acrofield的位置? 下面是我可以用来“获得”位置的代码……但现在我还需要能够“设置”它。 …. // Initialize Stamper (“output” is a MemoryStream object) PdfStamper stamper = new PdfStamper(pdf_rdr, output); // Get Reference to PDF Document Fields AcroFields fields = stamper.AcroFields; //call method to get the field’s current position AcroFields.FieldPosition pos = GetFieldPosition(fields, “txt_footer”); // **需要明确地为这里的场地设置一个新的位置 //assuming a call to “RegenerateField” will be required fields.RegenerateField(txt_footer); …. […]

从pdf阅读证书

我正在使用ITextSharp从数字签名的pdf文档中读取证书信息。 ITextSharp.Text.Pdf.PdfPKCS7类公开了三个属性: Certificates (列表) SignCertificate (作为单个对象) SignCertificateChain (作为列表) 如何组合这三个属性以获得有关单个证书的所有信息? 我将能够显示所有证书路径(所有嵌套证书)。

iTextSharp 5.5.6.0错误? 复选框刻度线更改

我有一个现有的PDF,我正在以编程方式填写(C#)。 表格上有复选框。 在构建4.4.x中,它们在选中时呈现复选标记。 在构建5.5.5.0和5.5.6.0中,它们现在是十字符号。 该文件的PdfVersion为54’6’。 我试过了: SetFieldProperty(fieldname, “checkboxtype”, RadioCheckField.TYPE_CHECK, null); 但没有运气。 我也搜索了潜在的属性列表,但似乎无法找到有效字符串值的列表。 iText在行动 – >表8.3是完整列表吗?

如何使用iTextSharp为C#设置现有PDF的版权元数据

如何使用iTextSharp为C#设置现有的版权元数据(即从文件或内存流加载的pdf)pdf文件? 非常感谢