iText does not have this functionality.
 
Bill Ensley
Bear Printing


From: Segev, Eli [mailto:[EMAIL PROTECTED]
Sent: Friday, March 31, 2006 1:44 PM
To: Bill Ensley
Subject: RE: [iText-questions] JPedal undocumented goody

Bill,

 

Do you know how to get a thumbnail from a PDF document with iText?

------------
Eli Segev
781-370-6096

 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bill Ensley
Sent:
Friday, March 31, 2006 2:12 PM
To: 'Aaron J Weber'; iText Mail Group
Subject: RE: [iText-questions] JPedal undocumented goody

 

JPedal Image Thumbnail Sample Code:

 

import java.awt.image.BufferedImage;
import java.io.FileOutputStream;
import java.io.IOException;
import org.jpedal.PdfDecoder;

 

import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGEncodeParam;
import com.sun.image.codec.jpeg.JPEGImageEncoder;

 


public class PdfToImage {

 

 public PdfToImage() {
 }

 

 /**
  * @param args 
  */
 public static void main(String[] args) {
  try{
   PdfDecoder decode_pdf = new PdfDecoder(true);
   // your font dir here
   String yourFontDirectory = "c:/webdocx/lib/fonts";
   decode_pdf.setTTFontDirs(new String[]{yourFontDirectory});
   decode_pdf.useHiResScreenDisplay(true);
   
   String pdfToDecode = "c:/maureen bonfiglio 3-1-06.pdf";
   decode_pdf.openPdfFile(pdfToDecode);
   
   int imageHeight = 1056;
   int pageFromPDF = 1;
   BufferedImage image_to_save = decode_pdf.getPageAsThumbnail(pageFromPDF, imageHeight);
   
   System.out.println(image_to_save);
   
   saveImage(image_to_save, .9f, "c:/test2.jpg");
   

 

  }
  catch(Exception e){
   e.printStackTrace();
  }
  new PdfToImage();

 

 }
 public static void saveImage(BufferedImage image, float quality, String fileName){
  try{
  FileOutputStream fos = null;
   
        fos = new FileOutputStream(fileName);

 

       
          JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(fos);
          JPEGEncodeParam param = JPEGCodec.getDefaultJPEGEncodeParam(image);

 

          param.setQuality(quality, true);
          encoder.encode(image, param);
       
        fos.flush();
        fos.close();
  }
    catch(IOException ioe){
     ioe.printStackTrace();
    }
 }
 
 

 

}

 

Any Problems, let me know

 

-Bill Ensley

Bear Printing

 


From: Aaron J Weber [mailto:[EMAIL PROTECTED]
Sent:
Thursday, March 30, 2006 2:50 PM
To: Bill Ensley
Subject: Re: [iText-questions] JPedal undocumented goody

I should've mentioned...I have to create them as JPEG's...do you see any issue with getting the "good quality" images you got with PNG....even "close"?

 

Thanks again,

Aaron

----- Original Message -----

Sent: Thursday, March 30, 2006 5:45 PM

Subject: Re: [iText-questions] JPedal undocumented goody

 

Hey Bill, I realize this is a month later (sorry!)...

 

Quick questions for you:

1) Were you using the OS version of JPedal or which version?

2) Can you share some snippet of code/class/methods that I can try to create some (fairly big) thumbnails of some PDFs?  (I think this was either a topic of this thread, or very related...)  I need to create like a 400x500 thumbnail (call it a GIANT Thumbnail!) of the first page of each of my PDFs.

 

Any ideas, thoughts, code you can share???

Thanks in advance!

 

-Aaron

 

----- Original Message -----

From: Bill Ensley

Sent: Thursday, February 16, 2006 4:17 PM

Subject: [iText-questions] JPedal undocumented goody

 

Hello All!

Yesterday I helped someone figure out how to get images from a PDF using JPedal and not turn out grainy.

 

After doing that I stuck around in JPedal and did some playing and found a neat trick that I wanted to pass on To this Mail Group.

 

As you know, JPedal can create a fairly passable preview image of a PDF, but with a little fiddling with the PdfDecoder class

 

I was able to add a method that will take any Graphics2D object and paint to it.  I passed in a iText PdfGraphics2D Object and

 

was pleasantly surprised how well the final PDF turned out. 

 

Using Batik, I was also able to pass an SVGGraphics2D Object and convert a PDF into and SVG file. 

 

 

I realize this has almost no relevance to iText, but I thought it was neat and wanted to share it.

 

If anyone want's the modified PdfDecoder for JPedal, I will happily send it along.


Bill Ensley
Phone: 503.244.4738
Fax: 503.244.5235


P.S. If you aren't able to open the photo proof,
you may not have Adobe Acrobat Reader. You can download it for free from:
http://www.adobe.com/products/acrobat/readstep2.html

Reply via email to