pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "BREMAUD, CYRIL" <cyril.brem...@atos.net>
Subject RE: Starting question about PDFBox
Date Tue, 12 Apr 2016 12:56:57 GMT
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/

BR
Cyril.

-----Original Message-----
From: Macamba [mailto:macamba@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-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message