You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Hitesh Patel (JIRA)" <ji...@apache.org> on 2015/09/21 14:27:04 UTC

[jira] [Created] (PDFBOX-2979) TexturePaint related bug in convertToImage method when trying to create a thumbnai image from PDF

Hitesh Patel created PDFBOX-2979:
------------------------------------

             Summary: TexturePaint related bug in convertToImage method when trying to create a thumbnai image from PDF
                 Key: PDFBOX-2979
                 URL: https://issues.apache.org/jira/browse/PDFBOX-2979
             Project: PDFBox
          Issue Type: Bug
          Components: PDModel
    Affects Versions: 1.8.10
         Environment: Ubuntu Linux - headless - Java 1.8.0_60
            Reporter: Hitesh Patel


I am trying to create a JPG image from a PDF page using convertToImage method of org.apache.pdfbox.pdmodel.PDPage class. 

If a PDF page contains a layer/element that was created using TexturePaint, convertToImage renders that element with a white background instead of original texture.

See below for the code I used to generate a thumbnail image:

import java.awt.image.BufferedImage;
import java.io.File;
import java.lang.Exception;
import javax.imageio.ImageIO;
import org.apache.pdfbox.pdmodel.PDDocument ;
import org.apache.pdfbox.pdmodel.PDDocumentCatalog;
import org.apache.pdfbox.pdmodel.PDPage;

public class PdfToJpg
{
	public static void main(String[] args)
  {
		try
		{		
		  File sourceFile = new File("input.pdf");

	    PDDocument pddocument = PDDocument.load(sourceFile);

      PDDocumentCatalog pdDocumentCatalog = pddocument.getDocumentCatalog(); 

			PDPage pdPage=pdDocumentCatalog.getAllPages().get(0);

			BufferedImage image=pdPage.convertToImage(BufferedImage.TYPE_INT_RGB,72);

			File flThumb=new File("output.jpg");

			ImageIO.write(image, "jpg", flThumb);

	    pddocument.close();
		}
		catch (Exception ex) 
		{
	    ex.printStackTrace();
		}
  }
}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org