itext

PDF text replace not working

心已入冬 提交于 2019-12-25 04:59:10
问题 I'm trying to replace text in PDF using iTextSharp dll but its not working in all cases. PDF document doesn't have acro fields. If the text which I need to replace is bigger than original text its not printing all characters. Finding some special characters is also not working. I have tried this code using (PdfReader reader = new PdfReader(sourceFileName)) { for (int i = 1; i <= reader.NumberOfPages; i++) { byte[] contentBytes = reader.GetPageContent(i); string contentString = PdfEncodings

Save JavaFX ScrollPane content to PDF file

这一生的挚爱 提交于 2019-12-25 04:53:24
问题 I'm using the below code to save the content of a ScrollPane in my JavaFx Application to a PDF file. button.setOnMouseClicked(new EventHandler<MouseEvent>() { public void handle(MouseEvent event) { File pdfFile = fileChooser.showSaveDialog(primaryStage); try { BufferedImage bufImage = SwingFXUtils.fromFXImage(scrollPane.snapshot(new SnapshotParameters(), null), null); FileOutputStream out = new FileOutputStream(new File("../temp.jpg")); javax.imageio.ImageIO.write(bufImage, "jpg", out); out

How to return an iText PDF document to the client side

余生颓废 提交于 2019-12-25 04:50:23
问题 I am trying to return an iText generated PDF from the server side to the client side to enable the user to store it. I am following How to convert iTextPDF Document to Byte Array (AceFunk) private static ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); public static byte[] main(java.util.List<Transcript> listymAwards, String scoutName, String groupName) { Document document = new Document(PageSize.A4, 0f, 0f, 0f, 0f); try { //PdfWriter.getInstance(document, new

Extract font height and rotation from PDF files with iText/iTextSharp

旧街凉风 提交于 2019-12-25 04:30:16
问题 I created some code to extract text and font height from a PDF file using iTextSharp, but does not handle text rotation. How can that information be extracted/computed? Here is the code: // Create PDF reader var reader = new PdfReader("myfile.pdf"); for (var k = 1; k <= reader.NumberOfPages; ++k) { // Get page resources var page = reader.GetPageN(k); var pdfResources = page.GetAsDict(PdfName.RESOURCES); // Create custom render listener, processor, and process page! var listener = new

iTextSharp object reference error on PdfStamper for certificate-protected file

烂漫一生 提交于 2019-12-25 04:19:24
问题 When using the PdfStamper (in append mode) to fill in a form in a certificate-protected pdf file, I get an object reference error with the following stack trace: System.NullReferenceException was unhandled HResult=-2147467261 Message=Object reference not set to an instance of an object. Source=itextsharp StackTrace: at iTextSharp.text.pdf.PdfEncryption.CreateInfoId(Byte[] id, Boolean modified) at iTextSharp.text.pdf.PdfEncryption.GetFileID(Boolean modified) at iTextSharp.text.pdf

iText doesn't set checkbox field

别说谁变了你拦得住时间么 提交于 2019-12-25 04:08:25
问题 I'm using iText library to generate pdf file based on template. But when I try to set checkbox field it won't filled. Class is here: public class MainClass { public static void main(String[] args) { try { PdfReader reader = new PdfReader("pdf/fw9_template.pdf"); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("test.pdf")); AcroFields form = stamper.getAcroFields(); String states[] = form.getAppearanceStates("topmostSubform[0].Page1[0].FederalClassification[0].c1_1"); System

Certifying Pdf document with iText

試著忘記壹切 提交于 2019-12-25 03:45:31
问题 I can sign my pdf and verify it by adding my smith.crt to be trusted in adobe reader (i get the green check mark) , my problem is certifying my pdf, i can not get the blue ribbon in the top left corner of my pdf, is it because i use the self-signed certificate? I get the message: The validity of the document certification is UNKNOWN. The author could not be verified. Can you please help me out, how can I get that blue ribbon? import java.io.FileInputStream; import java.io.FileOutputStream;

Unicode symbols in iTextSharp relative link

◇◆丶佛笑我妖孽 提交于 2019-12-25 03:29:32
问题 I'm trying to create a relative link in pdf file created with iTextSharp everything works good with ASCII letters, but if I add other unicode symbols in path they are just skipped This works fine: Chunk chunk = new Chunk(text, font); chunk.SetAnchor("./Attachments/1.jpg"); This creates incorrect link (link is created like this: //1.jpg, Вложения - part is missing): Chunk chunk = new Chunk(text, font); chunk.SetAnchor("./Вложения/1.jpg"); Is there any way to create correct link with unicode

java generate pdf file from string with arabic character and html Content

馋奶兔 提交于 2019-12-25 03:29:15
问题 I want to generate pdf file from string with arabic character and html Content . I used itextpdf-5.5.6.jar and xmlworker-5.5.6.jar . I try with this code : import java.io.ByteArrayInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import com.itextpdf.text.Document; import com.itextpdf.text.DocumentException; import com.itextpdf.text.pdf.PdfWriter; import com.itextpdf

Add image to iText dynamically on PDF file

Deadly 提交于 2019-12-25 03:24:44
问题 Can some one please help me what is missing in my code, I am trying to add image in to PDF generation fillFieldValue(stamper.getAcroFields(),agntCertBean); Image image1 = Image.getInstance(bb); image1.scaleAbsolute(25f, 25f); PdfContentByte overContent = stamper.getOverContent(1); AcroFields form = stamper.getAcroFields(); AcroFields.FieldPosition fldPos = (AcroFields.FieldPosition) form.getFieldPositions("ProfilePciture"); overContent.addImage(image1); stamper.close(); reader.close(); 回答1: