pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Wilson <williamstonconsult...@gmail.com>
Subject Re: PDFBox Problem
Date Tue, 19 Jan 2016 17:18:47 GMT
Rendering to a file very much works.  We do it to PNGs frequently and have
done so to JPG's.

Please see some code from the project for a really solid example of using
the object model.
http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java?revision=1697177&view=markup#l192

Note that the model has change from the 1.8.x branch to the 2.0.x branch.
Tilman's question on version is key to getting the code right.

On Tue, Jan 19, 2016 at 12:04 PM, Brown Paul T <BrownPaulT@johndeere.com>
wrote:

> Program is trivial  ( see below ) -
>
>   I have tried several .PDF files - all with same result, so I think any
> .pdf will have the problem
>
> public static void main(String[] args) {
>                 try {
>                         File inpFile = new
> File("C://Temp/MPDReversionJAN2016/MPDToWP01ReversionNotes.pdf");
>                         File outFile = new
> File("C://Temp/MPDReversionJAN2016/MPDToWP01ReversionNotes.jpg");
>                         FileInputStream inpStream = new
> FileInputStream(inpFile);
>                         PDFParser parser = new PDFParser(inpStream);
>                         parser.parse();
>                         PDDocument pdfDoc = parser.getPDDocument();
>                         PDStream pdStream = new PDStream(pdfDoc);
>                         PDJpeg jpeg = new PDJpeg(pdStream);
>                         System.out.println("Attempt To Write JPEG To ->" +
> outFile.getAbsolutePath());
>                         jpeg.write2file(outFile);
>                         System.out.println("Normal exit");
>                 } catch(Throwable tr) {
>                         System.err.println(tr.toString());
>                         tr.printStackTrace();
>                 }
>                 System.exit(0);
>         }
>
> -----Original Message-----
> From: Tilman Hausherr [mailto:THausherr@t-online.de]
> Sent: Tuesday, January 19, 2016 10:59 AM
> To: users@pdfbox.apache.org
> Subject: Re: PDFBox Problem
>
> None of the attachments went through, please upload them somewhere. What
> version are you using?
> Tilman
>
> Am 19.01.2016 um 17:39 schrieb Brown Paul T:
> >
> > Originally sent to 'ben@benlitchfield.com' - which was found at top of
> > source code
> >
> > I'm trying to save a .PDF as a .JPG - and getting null pointer.   See
> > attached Java Program and .PDF file
> >
> > Console Output at bottom
> >
> > Has anyone used this feature before ?
> >
> > Thanks -  Paul
> >
> > Attempt To Write JPEG To
> > ->C:\Temp\MPDReversionJAN2016\FernandoPDF\328693422.jpg
> >
> > _java.lang.NullPointerException_
> >
> >       at
> > org.apache.pdfbox.pdmodel.graphics.xobject.PDJpeg.write2OutputStream(_
> > PDJpeg.java:295_)
> >
> >       at
> > org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectImage.write2file(_
> > PDXObjectImage.java:284_)
> >
> > at com.pdfbox.PDFBoxDemoMain.main(_PDFBoxDemoMain.java:27_)
> >
> > *Paul T Brown*
> >
> > *Manufacturing Planning  Systems*
> >
> > *A & T Division - Deere & Company*
> >
> > *BrownPaulT@JohnDeere.com <mailto:BrownPaulT@JohnDeere.com>***
> >
> > *309-748-1387*
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> > For additional commands, e-mail: users-help@pdfbox.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message