Am 12.04.2016 um 14:56 schrieb BREMAUD, CYRIL:
Hi,
You can find many example with PDFBox 2.0.0 at this link : 
https://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/

Indeed, the examples from the source code downloads are the best way to start.

That site is not really helpful. I've put a comment there three days ago and it is still in moderation.
http://radixcode.com/pdfbox-example-code-how-to-extract-text-from-pdf-file-with-java/

The only good side of this is that this increases my score on stackoverflow :-)

Tilman



BR
Cyril.

-----Original Message-----
From: Macamba [mailto:maca...@hermod.nl]
Sent: Tuesday, April 12, 2016 2:15 PM
To: users@pdfbox.apache.org
Subject: Starting question about PDFBox

Hi,

My apologies for this basic question, but I'm just starting with PDFBox and 
can't make heads nor tale from it (at the moment). I found a website
(http://radixcode.com/category/pdfbox/) which had example code I wanted to 
start out with. But when I copied the first code into Eclipse my Eclipse 
complained about some of the imports. I have included the example code below my 
text.

As I start with PDFBox I need some documentation to help me start. As I use 
PDFBox 2.0.0 I cannot find any examples. Does anyone know of websites with some 
explanation? Or would it be smarter to use PDFBox 1.8.11 (which also has no 
example of a working example as far as I could see)?

Thanks,

Macamba

Example code from http://radixcode.com/category/pdfbox/

import java.io.FileInputStream;

import org.apache.pdfbox.pdmodel.PDDocument;

import org.apache.pdfbox.pdmodel.PDPage;

import org.apache.pdfbox.pdmodel.edit.PDPageContentStream;

// The following import org.apache.pdfbox.pdmodel.graphics.xobject cannot be 
resolved

import org.apache.pdfbox.pdmodel.graphics.xobject.PDJpeg;

// The following import org.apache.pdfbox.pdmodel.graphics.xobject cannot be 
resolved

import org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectImage;

/**

*

* @author azeem

*/

public class Main {

     public static void main(String[] args) {

         String fileName = "pdfWithImage.pdf";

         String imageName = "Logo.jpg";

         try {

             PDDocument doc = new PDDocument();

             PDPage page = new PDPage();

             doc.addPage(page);

             PDXObjectImage image = new PDJpeg(doc, new 
FileInputStream(imageName));

             PDPageContentStream content = new PDPageContentStream(doc, page);

             content.drawImage(image, 180, 700);

             content.close();

             doc.save(fileName);

             doc.close();

         } catch (Exception e) {

             System.err.println(e.getMessage());

         }

     }

}


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org

Reply via email to