pdfbox

Unable to verify digital signature using Apache PDFBOX

杀马特。学长 韩版系。学妹 提交于 2019-12-21 05:07:42
问题 I am a newbie in using Digital Signatures. In one of the projects we are using Apache PdfBox for processing digitally signed pdf files. While we could test all features, verification of signed pdf files is something we are unable to crack. We are using BouncyCastle as the provider. Below is the code: //Get Digital Signature and Signed Content from pdf file byte[] signatureAsBytes = pdsignature.getContents(new FileInputStream(this.INPUT_FILE)); byte[] signedContentAsBytes = pdsignature

Protecting PDF using PDFBox

自作多情 提交于 2019-12-21 04:58:10
问题 Im really struggling with the documentation for PDFBox. For such a popular library info seems to be a little thin on the ground (for me!). Anyway the problem Im having relates to protecting the PDF. At the moment all I want is to control the access permissions of the users. specifically I want to prevent the user from being able to modify the PDF. If I omit the access permission code everything works perfectly. I am reading in a PDF from an external resource. I am then reading and populating

How to find whether PDF has landscape orientation or portrait

心不动则不痛 提交于 2019-12-21 02:45:31
问题 Are there tools to determine whether a PDF has landscape orientation or portrait? I have currently looked upon pdfbox and Itext for this but seem that I could not find it. Please tell if they support this. Extracting the PDF pages information using Origami is providing a information the pdf pages have rotation of some degree. Here is what Origami reports: {:Parent=>#<PDF::Reader::Reference:0x872349c @id=8, @gen=0>, :Type=>:Page, :Contents=>#<PDF::Reader::Reference:0x8722f24 @id=4, @gen=0>,

Create pdf and merge with pdfbox

非 Y 不嫁゛ 提交于 2019-12-21 02:44:21
问题 This is what I want to do: Make 2 different pdf files using pdfbox Merge these two files together using pdfmerger I know how to do this if I'm saving #1 to the server side local hard drive and load the files for the #2. But what I want to do is using "directly from the memory". I've searched all the methods from this pdfboxes but still couldn't find it. This is my code getting from the local file Thank you. import java.io.BufferedOutputStream; import java.io.FileOutputStream; import java.io

Getting PDF TextObjects with PDFBox

♀尐吖头ヾ 提交于 2019-12-20 20:17:55
问题 I have a PDF from which I extracted a page using PDFBox: (...) File input = new File("C:\\temp\\sample.pdf"); document = PDDocument.load(input); List allPages = document.getDocumentCatalog().getAllPages(); PDPage page = (PDPage) allPages.get(2); PDStream contents = page.getContents(); if (contents != null) { System.out.println(contents.getInputStreamAsString()); (...) This gives the following result, which looks like something you'd expect, based on the PDF spec. q /GS0 gs /Fm0 Do Q /Span <<

Performance iText vs.PdfBox

杀马特。学长 韩版系。学妹 提交于 2019-12-20 14:41:13
问题 I'm trying to convert a pdf (my favorite book Effective Java, if its matter)to text, i checked both iText and Apache PdfBox. I see a really big difference in performance: With iText it took 2:521, and with PdfBox: 6:117. This if my code for PdfBOx PDFTextStripper stripper = new PDFTextStripper(); BUFFER.append(stripper.getText(PDDocument.load(pdf))); And this is for iText PdfReader reader = new PdfReader(pdf); for (int i = 1; i <= reader.getNumberOfPages(); i++) { BUFFER.append

Generate chart with JFreeChart and Apache PDFBOX

China☆狼群 提交于 2019-12-20 10:58:14
问题 I need to generate charts using JFreeChart and then export them to PDF using Apache PDFBOX. I don't want to use iText as it cannot be used in proprietary software. I searched all over Google, but no luck! Has anyone done it? 回答1: Copy the OutputStream from your chosen writeChartAs*() method in ChartUtilities to the InputStream used to create a PDXObjectImage in AddImageToPDF. A typical copyStream() implementation is shown here. Addendum: Alternatively, use piped streams to copy from output to

Why doesn'n create pdf-documents in java servlet? [duplicate]

若如初见. 提交于 2019-12-20 08:09:38
问题 This question already has answers here : How can I serve a PDF to a browser without storing a file on the server side? (4 answers) Closed 3 years ago . I use iText/Pdfbox to create a PDF document. Everything works when I create the PDF using a standalone Java class like this: public static void main(String[] args){ ... ... ... } The document is created correctly. But I need create a PDF document from a Servlet. I paste the code into the get or post method, run that servlet on the server, but

Text extraction is empty and unknown for text has type3 font using PDFBox,iText (difficult topic!)

北城余情 提交于 2019-12-20 07:09:33
问题 I have PDF file in Arabic that has text with font Type3 when I extract text using PDFBox some characters are empty and their font equals null? I want to know what is the problem? code: protected void processTextPosition(TextPosition text) { String character=text.getCharacter(); // is empty String font=text.getFont().getBaseFont(); // equal null } stream produced with iText: ( dJ� v{d W�cG�)Tj I speak about these question marks, why do I get the characters in this format? These question marks

Java printing PDF with options (staple, duplex, etc)

守給你的承諾、 提交于 2019-12-20 06:20:05
问题 I have a java program that prints PDFs. It uses Apache PDFBox to create a PDDocument object (from a pdf document or from a stream in some cases) and then sends it to the printer using the javax.print API: private boolean print(File pdf, String printer) { boolean success = false; try (PDDocument document = PDDocument.load(pdf)) { PrintService[] printServices = PrinterJob.lookupPrintServices(); PrintService printService = PrintServiceLookup.lookupDefaultPrintService(); PrinterJob job =