itextsharp

What are the extra characters in the font name of my PDF?

大兔子大兔子 提交于 2019-11-27 15:22:40
while extracting font name from pdf i will get some junk characters followed by plus sign and then the font name with font style. i want to remove the junk characters.only for few pdf i get that junk characters. example:MMLPEO+RemingtonNoiseless string curFont = renderInfo.GetFont().PostscriptFontName; The "junk" characters indicate that the font isn't embedded completely. You'll find names such as ABC123+RemingtonNoiseless, XYZ456+RemingtonNoiseless, etc... meaning that there may be different subsets of the same font inside the PDF. For an explanation have a look at section 9.6.4 Font Subsets

iTextSharp international text

若如初见. 提交于 2019-11-27 14:44:37
I have a table in asp.net page,and trying to export it as a PDF file,I have couple of international characters that are not shown in generated PDF file,any suggestions, Thanks in advance The key for proper display of alternate characters sets (Russian, Chinese, Japanese, etc.) is to use IDENTITY_H encoding when creating the BaseFont. Dim bfR As iTextSharp.text.pdf.BaseFont bfR = iTextSharp.text.pdf.BaseFont.CreateFont("MyFavoriteFont.ttf", iTextSharp.text.pdf.BaseFont.IDENTITY_H, iTextSharp.text.pdf.BaseFont.EMBEDDED) IDENTITY_H provides unicode support for your chosen font, so you should be

PDF Reading highlighed text (highlight annotations) using C#

被刻印的时光 ゝ 提交于 2019-11-27 14:32:22
I have written an extraction tool using iTextSharp that extracts annotation information from PDF documents. For the highlight annotation, I only get a rectangle for the area on the page which is highlighted. I am aiming for extracting the text that has been highlighted. For that I use `PdfTextExtractor'. Rectangle rect = new Rectangle( pdfArray.GetAsNumber(0).FloatValue, pdfArray.GetAsNumber(1).FloatValue, pdfArray.GetAsNumber(2).FloatValue, pdfArray.GetAsNumber(3).FloatValue); RenderFilter[] filter = { new RegionTextRenderFilter(rect) }; ITextExtractionStrategy strategy = new

iTextSharp in version 4.1.6 (with previous licence conditions)

戏子无情 提交于 2019-11-27 14:29:09
问题 I have an old project that is using iTextSharp library for PDF generation. iTextSharp DLL is added as reference to the project. iTextSharp was originally available under the LGPL licence. Some time ago the licence has changed to be AGPL (in release 5.0.0) that is copy left so you'd have to GPL all your code if you used it. My problem is that I don't know when I downloaded the DLL file that is linked in my project. I don't know if the DLL is still under LGPL or it is already under AGPL. And

Changing text line spacing

↘锁芯ラ 提交于 2019-11-27 14:03:10
I'm creating a PDF document consisting of text only, where all the text is the same point size and font family but each character could potentially be a different color. Everything seems to work fine using the code snippet below, but the default space between the lines is slightly greater than I consider ideal. Is there a way to control this? (FYI, type "ColoredText" in the code below merely contains a string and its color. Also, the reason I am treating the newline character separately is that for some reason it doesn't cause a newline if it's in a Chunk.) Thanks, Ray List<byte[]>

Removing Watermark from a PDF using iTextSharp

早过忘川 提交于 2019-11-27 13:49:38
I added a watermark on pdf using Pdfstamper. Here is the code: for (int pageIndex = 1; pageIndex <= pageCount; pageIndex++) { iTextSharp.text.Rectangle pageRectangle = reader.GetPageSizeWithRotation(pageIndex); PdfContentByte pdfData = stamper.GetUnderContent(pageIndex); pdfData.SetFontAndSize(BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED), watermarkFontSize); PdfGState graphicsState = new PdfGState(); graphicsState.FillOpacity = watermarkFontOpacity; pdfData.SetGState(graphicsState); pdfData.SetColorFill(iTextSharp.text.BaseColor.BLACK); pdfData.BeginText();

Extracting image from PDF with /CCITTFaxDecode filter

笑着哭i 提交于 2019-11-27 13:15:06
I have a pdf that was generated from scanning software. The pdf has 1 TIFF image per page. I want to extract the TIFF image from each page. I am using iTextSharp and I have successfully found the images and can get back the raw bytes from the PdfReader.GetStreamBytesRaw method. The problem is, as many before me have discovered, iTextSharp does not contain a PdfReader.CCITTFaxDecode method. What else do I know? Even without iTextSharp I can open the pdf in notepad and find the streams with /Filter /CCITTFaxDecode and I know from the /DecodeParams that it is using CCITTFaxDecode group 4. Does

Adding an image to a PDF using iTextSharp and scale it properly

一个人想着一个人 提交于 2019-11-27 13:09:06
here's my code. It correctly adds the pictures I want and everything works except that the images are using their native resolution, so if the image is big it's being cropped to fit the page. Is there some way to have the picture use like a Zoom feature to stretch to fit, but also maintain the aspect ratio? There has to be something I'm missing there. :P Here's a picture to illustrate the problem: using System; using System.IO; using iTextSharp.text; using iTextSharp.text.pdf; using System.Drawing; using System.Collections.Generic; namespace WinformsPlayground { public class PDFWrapper {

Embedding DLL's into .exe in in Visual C# 2010

风格不统一 提交于 2019-11-27 13:06:06
问题 I'm working on a C# program that uses iTextSharp.dll and WebCam_Capture.dll. When I build the program, it creates executable in the debug folder and it also copies these two dll's to the debug folder as expected. I want to merge them into a single executable, however I failed. These two libraries are visible in the references normally in the solution explorer. I also add them as resources. Executable size got bigger which equals the sum of three files, nevertheless the executable still

How to convert pdf Byte[] Array to downloadable file using iTextSharp

柔情痞子 提交于 2019-11-27 12:59:37
问题 Hei guys I have this byte array i want to convert to pdf and make it available for download. Anybody has any idea how this is done? here is my Action Controller public ActionResult DownloadLabTestResult(string labTestResultID) { PdfReader pdfReader = new PdfReader("Xue_Tang.pdf"); MemoryStream stream = new MemoryStream(); PdfStamper stamper = new PdfStamper(pdfReader, stream); pdfReader.Close(); stamper.Close(); stream.Flush(); stream.Close(); byte[] pdfByte = stream.ToArray(); // So i got