itext

C# Pdf to Text with values in multiple line

余生颓废 提交于 2021-01-29 03:01:58
问题 Hi I have a pdf with content as following : - Property Address: 123 Door Form Type: Miscellaneous ABC City Pin - XXX So when I use itextSharp to get the content, it is obtained as follows - Property Address: 123 Door Form Type: Miscellaneous ABC City Pin - XXX The data is mixed since it is in next line. Please suggest a possible way to get the content as required. Thanks Property Address: 123 Door ABC City Pin - XXX Form Type: Miscellaneous 回答1: The following code using iTextSharp helped in

How to increase the accuracy of measurements in iTextSharp?

天大地大妈咪最大 提交于 2021-01-28 16:42:14
问题 I want to resize a pdf to a specific size, but when I use scaling it loses accuracy because a float rounds the value. Is there a way that I can resize a pdf with a given width and height? This is what I've tried so far: public void PDFScalingTest11(string FileIn, string FileOut) { // The following code opens a pdf and place it 20 times on a new pdf page // I want to resize the pdf before adding it int iQuantity = 20; int iCol = 3; int iRow = 0; float fTileSpacing = 0; float fPrintWidth =

zip a pdf file created using itext

删除回忆录丶 提交于 2021-01-28 15:10:29
问题 response.setHeader("Content-Disposition", "attachment; filename=r.pdf"); Document document1 = new Document(PageSize.A4); PdfWriter pdfWriter=PdfWriter.getInstance(document1, response.getOutputStream()); pdfWriter.setPageEvent(new HeaderAndFooter(name)); try{ document1.open(); XMLWorkerHelper worker1 = XMLWorkerHelper.getInstance(); long seed =123; Random rnd = new Random (seed); Collections.shuffle(arrlist1,rnd); for(int i=0;i<nb;i++){ String str =(String) arrlist1.get(i); worker1.parseXHtml

zip a pdf file created using itext

泪湿孤枕 提交于 2021-01-28 15:03:26
问题 response.setHeader("Content-Disposition", "attachment; filename=r.pdf"); Document document1 = new Document(PageSize.A4); PdfWriter pdfWriter=PdfWriter.getInstance(document1, response.getOutputStream()); pdfWriter.setPageEvent(new HeaderAndFooter(name)); try{ document1.open(); XMLWorkerHelper worker1 = XMLWorkerHelper.getInstance(); long seed =123; Random rnd = new Random (seed); Collections.shuffle(arrlist1,rnd); for(int i=0;i<nb;i++){ String str =(String) arrlist1.get(i); worker1.parseXHtml

How to avoid bcprov-jdk16-1.45.jar while running the application through POM entry

只愿长相守 提交于 2021-01-28 10:58:36
问题 I have a Java 8 application running in Weblogic 12.1.3. The application uses iText 5.5.9 and minimum version of BC required is 1.49 . The application is deploying as a WAR file in Weblogic . I could see the war file is having the proper version of BC . But during run time its taking from WebLogic maven plugin path and using BC 1.45. Is there any way we can avoid this by editing POM entry or by editing WebLogic.xml . If i remove BC 1.45 jar from my local server its running successfully. But i

iText7: How to get the real width of a Paragraph

为君一笑 提交于 2021-01-28 09:13:57
问题 I need to know the width (in point) of a Paragraph before add to the document. I searched here and found Alexey answer about Paragraph's height. So I made it with width, but it doesn't work. Always return the Rectangle's width no matter how long the Paragraph. I tried this code: private float getRealParagraphWidth(Document doc, Paragraph paragraph) { // Create renderer tree IRenderer paragraphRenderer = paragraph.createRendererSubTree(); // Do not forget setParent(). Set the dimensions of the

C# PKCS7 Smartcard Digital Signature - Document has been altered or corrupted since it was signed

我怕爱的太早我们不能终老 提交于 2021-01-27 21:17:49
问题 I try to sign a pdf file using my smartcard (USB token) but encounter "Document has been altered or corrupted since it was signed" error when I open the signed pdf file in Adobe. The error is not so descriptive and I'm not sure where to look at because the code seems good to me but apparently it's not.. The code that I use is: var signer = smartCardManager.getSigner("myTokenPassword"); var toBeSignedHash = GetHashOfPdf(File.ReadAllBytes(@"xxx\pdf.pdf"), cert.asX509Certificate2().RawData, "dsa

How to align a Chunk Left and Right Side

女生的网名这么多〃 提交于 2021-01-27 15:07:50
问题 i want to align the Chunk Left and Right side. Also the each Chunk have different format you can see in image. i try the below code: Chunk invoiceid = new Chunk("Invoice ID: ", font9BoldDARK_GRAY); Chunk invoiceidvalue = new Chunk("value from database", font10NoramlBlack); Chunk inoicdate = new Chunk("Invoice Date: ", font9BoldDARK_GRAY); Chunk inoicedatevalue = new Chunk(new SimpleDateFormat("MMMM dd yyyy").format(new Date()), font10NoramlBlack);// get From database Paragraph

iText 7 - HTML to PDF write to MemoryStream instead of file

风流意气都作罢 提交于 2021-01-24 09:26:12
问题 I'm using iText 7, specifically the HtmlConverter.ConvertToDocument method, to convert HTML to PDF. The problem is, I would really rather not create a PDF file on my server, I'd rather do everything in memory and just send it to the users browser so they can download it. Could anyone show me an example of how to use this library but instead of writing to file write to a MemoryStream so I can send it directly to the browser? I've been looking for examples and all I can seem to find are those

在linux环境下使用itext生成pdf

天大地大妈咪最大 提交于 2021-01-15 05:39:07
转载请注明出处 https://www.cnblogs.com/majianming/p/9537173.html 项目中需要对订单生成pdf文件,在不断的尝试之后,终于生成了比较满意的pdf文档。 简单介绍一下背景:项目是一个erp项目,docker容器化CentOS 7运行环境,应用打包方式jar,使用itext生成pdf 我们从后面的三个背景来分析 首先是使用itext库,需要明确的是itext是默认不支持中文显示的,这个问题很容易找到的方法是添加itext-asin库,一个解决中日韩文字问题的拓展,而在这个拓展自然也是需要另外添加中文字体支持的,所以我们为了支持中文,在itext的基础上需要itext-asin库和字体文件。 第二个背景,也就是jar打包方式,许多博客在介绍这一段时,会把字体文件添加到项目文件下,这样本地开发是没有问题的,但是一旦部署到了linux(CentOS)环境下,就会有中文字无法显示的问题(这时候如果你将应用的jar包在windows环境下跑,一般是可以正常显示的,为什么?等会看看第三个背景你就会明白了),这是因为在itext中,并不是用文件流(fileinputstream)的形式去读取字体,自然无法读取到jar包中的文件,那么我们换一个思路,把字体文件移动到项目外的一个路径下,然后指定itext去读取这个路径。 第三个背景CentOS