pdfbox

getting null when call acroform.getFields() using pdfbox

懵懂的女人 提交于 2019-12-10 20:21:58
问题 I tried to get All the fields available in pdf form but I'm encountering a NullPointerException when calling acroform.getFields() using PDFBox. Sample: pdDoc = PDDocument.load(fileName); PDAcroForm form = pdDoc.getDocumentCatalog().getAcroForm(); if(form!=null) { List<PDField> field = form.getFields(); //here I am getting null pointer exception } 回答1: this is because your pdf if not contain any acroform 回答2: form is not null , but that doesn't mean it is not empty . Check this instead: if

merge files gives error: End-of-File, expected line

一曲冷凌霜 提交于 2019-12-10 18:56:20
问题 I'm Using PdfBox for android in order to append data to a PDF file. The data to append public byte [] prerparePdfToAppend() { final PDDocument document = new PDDocument(); final PDPage sourcePage = new PDPage(); document.addPage(sourcePage); PDPageContentStream contentStream = new PDPageContentStream(document, sourcePage); contentStream.beginText(); contentStream.setFont(PDType1Font.COURIER, 12); contentStream.showText("Name: " + firstName + " " + lastName); contentStream.newLine(); ...

PDFBox - checkbox is not displayed if set readonly

北城以北 提交于 2019-12-10 18:53:17
问题 I am generating PDF using PDFBox, where I need to add a checkbox, which needs to be preset to checked and readonly. But some how it does not work. Please find below code, which adds the checkbox on PDF: import java.io.File; import java.io.IOException; import org.apache.pdfbox.cos.COSArray; import org.apache.pdfbox.cos.COSDictionary; import org.apache.pdfbox.cos.COSFloat; import org.apache.pdfbox.cos.COSName; import org.apache.pdfbox.cos.COSString; import org.apache.pdfbox.exceptions

Possible bug with load() and parse() methods in PDFBox?

隐身守侯 提交于 2019-12-10 18:36:44
问题 I tried to use PDFBox on regular .pdf files and it worked fine. However when I encountered a corrupted .pdf , the code would "freeze" .. not throwing errors or something .. simply the load or parse function take forever to execute Here is the corrupted file (i have zipped it so that everybody could download it), it is probably not a native pdf file but it was saved as a .pdf extension and it is only 4 Kb. I am not an expert at all, but I think that this is a bug with PDFBox. According to

pdfbox: … is not available in this font's encoding

折月煮酒 提交于 2019-12-10 14:49:54
问题 I'm having problems with pdfbox 2.0.2 writing a pdf document from elements of a previously read document (https://www.dropbox.com/s/ttxiv0dq3abh5kj/Test.pdf?dl=0). Everything works fine, except when I call showText on a PDPageContentStream where I previously set the font with out.setFont(textState.getFont(), textState.getFontSize()) (see the INFORMATION log) and the font is ComicSansMS or ArialBlack. textState is (a clone from) the state from the previously read document. Writing text with

How can I get PDVisibleSigProperties to write the signature on the 3 page into the signature box

守給你的承諾、 提交于 2019-12-10 14:48:12
问题 I am working with the pdfbox example signature CreateVisableSignature and I would like the code to write the image of the signature into a signature field called "ApplicantSignature" on the third page. Can someone give a clue as to why it writes the signature in the upper left corner of the first page? Here is the code: public static void main(String[] args) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException, COSVisitorException,

pdfbox: trying to decrypt PDF

元气小坏坏 提交于 2019-12-10 12:57:00
问题 Following this answer I'm trying to decrypt a pdf-document with pdfbox: PDDocument pd = PDDocument.load(path); if(pd.isEncrypted()){ try { pd.decrypt(""); pd.setAllSecurityToBeRemoved(true); } catch (Exception e) { throw new Exception("The document is encrypted, and we can't decrypt it."); } This leads to Exception in thread "main" java.lang.NoClassDefFoundError: org/bouncycastle/jce/provider/BouncyCastleProvider at org.apache.pdfbox.pdmodel.PDDocument.openProtection(PDDocument.java:1601) at

Using Overlay in PDFBox 2.0

僤鯓⒐⒋嵵緔 提交于 2019-12-10 11:59:40
问题 What I am trying to do here is to create text and place it onto a blank page. That page would then be overlayed onto another document and that would then be saved as one document. In 1.8 I was able to create a blank PDPage in a PDF, write text to it as needed, then overlay that PDF with another and then save or view on screen using the code below - overlayDoc = new PDDocument(); page = new PDPage(); overlayDoc.addPage(page); overlayObj = new Overlay(); font = PDType1Font.COURIER_OBLIQUE; try

Can pdfbox extract vector images?

╄→尐↘猪︶ㄣ 提交于 2019-12-10 11:51:59
问题 As per my understanding, 1. .eps format images are vector images. 2. When we draw something in word (like a flowchart) that is stored as a vector image. I am almost sure about the first, not sure about the second. Please correct me if I am wrong. Assuming this two things, when a latex file (where .eps images are inserted) or a word file (that contains vector images) is converted into pdf, do the images get converted into raster images? Also, I think PDFBox / xpdf can only extract raster

QuadBounds Order for PdfAnnotation markup using itext or pdfbox

橙三吉。 提交于 2019-12-10 10:48:13
问题 0 1 2 3 * (x1,y1) *************** (x2,y2) * * * * * * * 4 5 * * 6 7 * (x3,y3) *************** (x4,y4) is this correct order for float array for PdfAnnotation or PDFAnnotation? i tried creating a pdf annotation but the annotations are concave not convex like the those generally created by using adobe reader or acrobat 回答1: What I found using iText was the following: * 4 5 6 7 * (x3, y3) ***************** (x4, y4) * * * * * * * * * * 0 1 * * 2 3 * (x1, y1) ***************** (x2, y2) Using this