Images not being rendered properly
[Logo]
ICEsoft.org Forums: ICEfaces, ICEmobile, ICEpdf
[Search] Search   [Recent Topics] Recent Topics   [Groups] Home Page | www.icefaces.org  [Register] Register  [Login] Login 
Images not being rendered properly  XML
Forum Index -> ICEpdf General
Author Message
dstampf

Joined: 28/10/2009 00:00:00
Messages: 1
Offline


First - thanks to the good people there who made this package available! I hate to complain - hopefully it will prove to be an error on my part.

I have a number of pdf's that I need to display. I've used the examples almost verbatim to generate a png of each page (I've also created jpg's with similar results) and I've used the pdfview application as well with the same results. I'll attach the pdf and the third page. The text renders fine, but the images are either incomplete or missing.

For my application, this is not a bad thing, but some of my team-mates are a bit concerned that at some point the text would be missing which would be bad.

I'm running this on a Mac OSX 10.5.8

Thanks for any help.

Dave
[Thumb - 3MAd-Enablingtechnologysemiconductormanufacturing.pdf2.png]
 Filename 3MAd-Enablingtechnologysemiconductormanufacturing.pdf2.png [Disk] Download
 Description
 Filesize 202 Kbytes
 Downloaded:  101 time(s)

 Filename 3MAd-Enablingtechnologysemiconductormanufacturing.pdf [Disk] Download
 Description
 Filesize 520 Kbytes
 Downloaded:  229 time(s)

patrick.corless

Joined: 26/10/2004 00:00:00
Messages: 1097
Offline


I just took a quick look at your document. The good news is that you don't have to worry about missing text. The bad news is that the Images in question are compressed using the JPEG200 standard which we don't currently support.

This image format was added fairly recently to the PDF specification and to date we haven't seen a lot of uses of it in the wild, usually just a couple a year. You can vote for this enhancement request here, http://jira.icefaces.org/browse/PDF-43 .
[Email]
erimkaki

Joined: 25/11/2009 00:00:00
Messages: 3
Offline


Hi,

First of all I will thanks to the team of ICEPdf, Because now I am able to render PDF version 1.6.
Now I am facing another problem, While I am rendering the pages as images, It is not capturing the transparent images of that pdf page.
At the position of transparent images it is showing white back ground.

I am using the following code:
import org.icepdf.core.exceptions.PDFException;
import org.icepdf.core.exceptions.PDFSecurityException;
import org.icepdf.core.pobjects.Document;
import org.icepdf.core.pobjects.Page;
import org.icepdf.core.util.GraphicsRenderingHints;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

public class PDFPageCapture {
public static void main(String[] args) {
// Get a file from the command line to open
// String filePath = args[0];
// open the file
Document document = new Document();
try {
document.setFile("D:/Ebook/JpegToPDF/pdf/alberta-justice-success-story.pdf");
} catch (PDFException ex) {
System.out.println("Error parsing PDF document " + ex);
} catch (PDFSecurityException ex) {
System.out.println("Error encryption not supported " + ex);
} catch (FileNotFoundException ex) {
System.out.println("Error file not found " + ex);
} catch (IOException ex) {
System.out.println("Error IOException " + ex);
}
// save page captures to file.
float scale = 1.0f;
float rotation = 0f;
// Paint each pages content to an image and
// write the image to file
for (int i = 0; i < document.getNumberOfPages(); i++) {
BufferedImage image = (BufferedImage) document.getPageImage(i,
GraphicsRenderingHints.PRINT, Page.BOUNDARY_CROPBOX,
rotation, scale);
RenderedImage rendImage = image;
try {
System.out.println(" capturing page " + i);
File file = new File("D:/Ebook/JpegToPDF/images/imageCapture1_" + i + ".gif");
ImageIO.write(rendImage, "gif", file);
} catch (IOException e) {
e.printStackTrace();
}
image.flush();
}
// clean up resources
document.dispose();
}
}
So, Please if any one have any solution, then please suggest me.
patrick.corless

Joined: 26/10/2004 00:00:00
Messages: 1097
Offline


Double check that the viewer reference implementation is correstly renderign the PDF in question. If it is rendering ok then you can try the following getPageImage modifcation

Code:
public Image getPageImage(int pageNumber,
                               final int renderHintType, final int pageBoundary,
                               float userRotation, float userZoom) {
         Page page = catalog.getPageTree().getPage(pageNumber, this);
         PDimension sz = page.getSize(pageBoundary, userRotation, userZoom);
 
         int pageWidth = (int) sz.getWidth();
         int pageHeight = (int) sz.getHeight();
 
         BufferedImage image = new BufferedImage(pageWidth,
                 pageHeight,
                 BufferedImage.[b]TYPE_INT_ARGB[/b]);
         Graphics g = image.createGraphics();
 
         page.paint(g, renderHintType,
                 pageBoundary, userRotation, userZoom);
         g.dispose();
         catalog.getPageTree().releasePage(page, this);
 
         return image;
     }
 

[Email]
erimkaki

Joined: 25/11/2009 00:00:00
Messages: 3
Offline


Thanks Patrick for the reply...
But the issue is remain, either I change BufferedImage.OPAQUE,
BufferedImage.BITMASK, or BufferedImage.TYPE_INT_ARGB,
Now I am sending the pdf, please run this code with that pdf,
you can understand my issue more clearly.
So please if u have any suggestion then please suggest me.

Best Regards,
Er.IMKAKI

patrick.corless wrote:
Double check that the viewer reference implementation is correstly renderign the PDF in question. If it is rendering ok then you can try the following getPageImage modifcation

Code:
public Image getPageImage(int pageNumber,
                               final int renderHintType, final int pageBoundary,
                               float userRotation, float userZoom) {
         Page page = catalog.getPageTree().getPage(pageNumber, this);
         PDimension sz = page.getSize(pageBoundary, userRotation, userZoom);
 
         int pageWidth = (int) sz.getWidth();
         int pageHeight = (int) sz.getHeight();
 
         BufferedImage image = new BufferedImage(pageWidth,
                 pageHeight,
                 BufferedImage.[b]TYPE_INT_ARGB[/b]);
         Graphics g = image.createGraphics();
 
         page.paint(g, renderHintType,
                 pageBoundary, userRotation, userZoom);
         g.dispose();
         catalog.getPageTree().releasePage(page, this);
 
         return image;
     }
 

 
[Thumb - imageCapture1_0.gif]
 Filename imageCapture1_0.gif [Disk] Download
 Description
 Filesize 59 Kbytes
 Downloaded:  92 time(s)

 Filename my.pdf [Disk] Download
 Description
 Filesize 322 Kbytes
 Downloaded:  69 time(s)

patrick.corless

Joined: 26/10/2004 00:00:00
Messages: 1097
Offline


The issue is happing at the parser level of ICEpdf. For some reason we're not correctly applying an alpha value in the graphics state to the image in question and you see a white box instead of translucent white box.

Unfortunately you can't get around this issue by changes the image colour model.

I've create the following bug http://jira.icefaces.org/browse/PDF-90 for this issue. You can vote for it if you wish.
[Email]
erimkaki

Joined: 25/11/2009 00:00:00
Messages: 3
Offline


Hi Patrick,
After a long time, this issue exist,
Please fix it asap, I am waiting for
this issue removal.

Best Regards,
~Iqubal Mustafa Kaki
 
Forum Index -> ICEpdf General
Go to:   
Powered by JForum 2.1.7ice © JForum Team