FAQ Database Discussion Community


Signing PDF with PDFBox and BouncyCastle

java,pdf,pdfbox
I'm trying to sign a PDF using PDFBox, and it does sign but when I open the document in adobe reader I get the following message "Document has been altered or corrupted since it was signed" can someone please help me find the problem. The keystore was created with "keytool...

Hierarchical Bookmark Generation in PDF using PDFBox library [closed]

java,pdf,pdf-generation,pdfbox
How can I create a hierarchical bookmark for a PDF like this: Root ---Node-1 -------Node-11 -------Node-12 .... ---Node-2 -------Node-21 .... I have a bidimensional array (I accept any kind of list/set for the example) with node names like this: 1 11, 12, ... 2 21, 22, 23, ... ... This...

How do I rotate the contents of a PDF page to an arbitrary angle?

pdf,pdfbox
I need to rotate the contents of a PDF page by an arbitrary angle and the PDPage.setRotation(int) command is restricted to multiples of 90 degrees. The contents of the page are vector and text and I need to be able to zoom in on the contents later, which means that...

PDFBox: Draws images in different locations and sizes depending on input PDF

java,image,pdf,pdfbox
I've added images to a document using code as supplied by Nick Russler in answer to another question here http://stackoverflow.com/a/20618152/4652269 /** * Draw an image to the specified coordinates onto a single page. <br> * Also scaled the image with the specified factor. * * @author Nick Russler * @param...

Setting character spacing with PDFBox

java,pdf,pdf-generation,pdfbox
I'm currently using Java and the PDFBox library to create some PDFs on the fly. I need to be able to set the character spacing/tracking of some text but can't seem to figure it out. It looks as there is a method to do so : http://ci.apache.org/projects/pdfbox/javadoc/index.html?org/apache/pdfbox/util/operator/SetCharSpacing.html But I'm not...

PDFBox text extraction - empty output

java,pdf,pdfbox
I'm trying to extract some infos from a set of PDFs. This works so far, but one PDF gives me grievances. I'm using PDFBox 1.8.8, with Java 7. PDDocument document = PDDocument.load(pdfFile); PDFTextStripper stripper = new PDFTextStripper(); System.out.println("File: "+pdfFile.getAbsolutePath()+" readable: "+pdfFile.canRead()+" size: "+pdfFile.length()); System.out.println(stripper.getText(document)); It just prints File: /foo/bar/mypdf.pdf readable:...

Extracting an embedded object from a pdf

java,pdf,itext,pdfbox
I had embedded a byte array into a pdf file (Java). Now I am trying to extract that same array. The array was embedded as a "MOVIE" file. I couldn't find any clue on how to do that... Any ideas? Thanks! EDIT I used this code to embed the byte...

pdfbox and itext not able to extract image

java,itext,pdfbox
I am trying to extract images from a pdf . pdfbox is able to extract images from most of the pdfs but their are some pdfs whose images are not getting extracted by pdfbox. For extracting the image I am using following code : Not able to extract images from...

Add page as layer from separate pdf(different page size) using pdfbox

java,pdf,pdfbox
How can I add a page from external pdf doc to destination pdf if pages have different sizes? Here is what I'd like to accomplish: I tried to use LayerUtility (like in this example PDFBox LayerUtility - Importing layers into existing PDF), but once I import page from external pdf...

pdfbox and itext extracting image with incorrect dpi

java,itext,pdfbox
When I extract image using pdfbox I am getting incorrect dpi of the image for some PDFs. when I extract image using photoshp or acrobat reader pro I can see that the dpi of the image is 200 using windows photo viewer but when I extract the image using pdfbox...

PdfBox issue while changing page

java,pdf,pdf-generation,rendering,pdfbox
I'm not a big fan of asking this kind of questions but well, it's been 3 whole days now trying to solve this bug on my code. I know it's a logic problem and I know how to solve it in my mind, but when it comes to translate my...

Unable to extract text and images from specific PDF

ruby,pdf,command-line,ubuntu-14.04,pdfbox
Can anyone please let me know how I can extract all the text and images from a PDF. I am able to extract images in scenario like, which I created a PDF with few lines of text and 2 png images using Google Docs. But, I am unable to extract...

.NoClassDefFoundError when trying to use pdfBox

java,exception,pdfbox
when I try to use one of the PDFBox examples for extracting images, in the run time,it gives me the following exception: Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory at org.apache.pdfbox.pdfparser.BaseParser.<clinit>(BaseParser.java:68) at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1218) at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1186) at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1111) at...

how to add image as page in PDFBox Android

android,pdfbox
I have add PdfBox Android port in my android project. I have wrote the following code try { PDDocument document = new PDDocument(); PDPage page = new PDPage(); // page.set document.addPage(page); // Create a new font object selecting one of the PDF base fonts PDFont font = PDType1Font.HELVETICA_BOLD; File mediaStorageDir...

Attachment damages signature part 2

pdfbox
I created code that adds an image to an existing pdf document and then signs it, all using PDFBox (see code below). The code nicely adds the image and the signature. However, in some documents, Acrobat Reader complains that "The signature byte range is invalid." The problem seems to be...

Splitting at a specific point in PDFBox

pdf,split,pdfbox
I would like to split to generate a new pdf by concatenating certain individual pages, but the last page has to be split at a certain point (i.e. all content above a limit to be included and everything below to be excluded - I only care about the ones having...

How to Check PDF is Reader enabled or not using C#?

c#,pdf,itextsharp,pdfbox
My only requirement is to find a selected pdf in a folder is Reader enabled or not, more specifically if usage rights are defined in a way that allows people to add annotations (e.g. comments). I am doing this in windows application. If I click a button, an event is...

PDFbox not extracting regions on android

java,android,pdfbox
I am trying to extract only the highlighted text on a PDF document. It works on PC but when I use it on Android it fails. PDFBox doesnt directly work on android so I am using Birdbrain2/PdfBox-Android for Android. Here is the PC code that works import java.awt.geom.Rectangle2D; import java.io.File;...

Java PDFBox setting custom font for a few fields in PDF Form

java,pdf,fonts,pdfbox,pdf-form
I am using Apache PDFBox to read a fillable PDF form and fill the fields based on some data. I am using the below code (as per suggestions from other SO answers) to get the default Appearance String and changing it (as you can see below, I am changing the...

Embedding PDFont after adjusting character widths

java,pdf,fonts,pdfbox
I want to create a PDF file conforming to the PDF/A standard by using Apache PDFBox. To conform to PDF/A, all used fonts have to be embedded. I can use either the standard fonts or load one from a file, but I need to adjust the character width of several...

PDFBox: extracting images from pdf to inputstream

java,inputstream,pdfbox
I am using PDFBox to extract the images from my pdf (which contains only jpg's). Since I will save those images inside my database, I would like to directly convert each image to an inputstream object first without placing the file temporary on my file sysem. I am facing difficulties...

Temp File Creation Error on GAE With PDFBox

java,google-app-engine,jersey,pdfbox
On GAE I am trying to update a PDF with a FDF file using PDFBox (and Jersey). I have read on how you can't use PDFBox on GAE because certain classes aren't whitelisted. I was hoping that just populating the PDF from the FDF wouldn't cause an issue if none...

How to draw dotted line in pdfBox

java,pdf,pdfbox
I'm using Pdfbox to draw some line on my document. Code: contentStream.drawLine(startX, startY, startX, endY); The result is an straight line. I wonder Does the PdfBox can draw dotted line?...

How to draw text containing characters like € in PDF using PDFBox

java,android,pdf,pdfbox
I have a text to draw on pdf, something like 500 €/hour. I am using PdfBox-Android library. I was trying to write above string as follows, pageContentStream.drawString("500 " + Html.fromHtml(getString(R.string.euro)).toString() + "/hour"); where euro is defined in strings.xml as <string name="euro">(&#8364;)</string> <string name="pound">(&#163;)</string> With above code PdfBox-Androidis writing some gibberish...

PDDocument can't add list of PDPage with addPage()

java,pdfbox
Using 1.8.9 I want to cut a PDF page to a multi-page PDF using crop tools. But when I add more than one page to my PDDocument it doesn't add it at all. Code example (the original PDPage is a parameter of my function) : private static void splitPage(int nbOfCrops,...