I'm creating piecharts using JFreeChart, use chart.createBufferedImage(width,height) and give the buffered image to IReport as an image parameter. In IReport I have an image and its image expression points to this parameter, so I can render the image. But when exported to PDF, images are covered with a black rectangle. Something about transparency or RGB, I guess.
There's a thread here about this problem and some suggested solutions, but I couldn't apply them to my problem, will you help me? Thanks.
The thread: http://www2.jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=21922&page=2#24710
As suggested by #Pekka, this is likely a limitation of Transparency in PDF files.
I can't find a way to set RGB or trasparency values from JFreeChart.
The JFreeChart class includes a createBufferedImage() method that accepts an imageType, which is subsequently used to create the BufferedImage . You may have to select the optimal one empirically.
Related
I am using JFreeChart, and I want to export my Chart to SVG. I refer this code.
If I send Rectangle bounds parameter like
new Rectangle(100,100);
then I get the complete image(Chart). But for another dimension, I get cropped image(Chart).
What I miss?
I fond solution.
we need to give input in the Same ratio as image have.
I'm creating PDFs with iText (LGPL) which include some Text and self-drawn (Graphics2D) images.
My current solution is to draw the images on a BufferedImage and then include it in the PDF, which has several drawbacks:
If printed, the images just look ugly, a way to circumvent this is to use larger images, and with 3000*3000 it looks ok. But this leads to the next problem: time. It takes several seconds to compress one image (I haven’t found a way to disable it, and files would be huge without compression).
PdfGraphics2d from iText looks good, but has one major drawback: it’s only able to draw to the background of the PDF, and there seems to be no way to wrap it in some kind of element.
Is there a way to draw on a PDF without having to use absolute positions? I’m using Graphics2d because it’s used also to provide a preview in the UI.
You can wrap a PdfTemplate inside an Image object without losing any of the vector image's quality. In most cases, you'll use the Image object to add raster images to a PDF document as an Image XObject. However, in this case, the PdfTemplate will be added as a Form XObject using its original vector data. Another situation when this happens, is when you add a WMF file; such as file is converted into PDF syntax automatically.
I got this exception when my app is trying to read a JPG image using ImageIO.read( ) method. This exception is not thrown for all jpg file.
I found this answer useful Intersection of bands in R raster package, but still it converts my colored image to a black n white one. I guess that question has focused on the right issue, but I want it to keep my image colored(not black and white).
Download image: https://skydrive.live.com/?cid=19547371C4F3B839&id=19547371C4F3B839%21105
Simply if someone can obtain a BufferdImage from the image given that's enough (should not convert the image to gray scale one).
You are a genius if you can answer this :D.
Plz help.
That is typically the exception you get when Java cannot read the JPEG file. While they are standard compliant JPEGs Java has not implemented the full standard. I recommend converting the JPEG file with ImageMagick, Irfanview, or something like this before actually trying to open it in Java.
You may use ImageJ, which can deal with most JPEGs.
I am converting pdf to tiff images for one of my project.
Than I using iipserver to generate tiles for the tiff images on fly. But this process is killing my CPU.
so I thinking of generating tile in advance and showing them directly instead of using iipserver. I researched into iipserver and got this libTiff c++ utility which is doing tiling work for the same server.
So I wanted to know is there any java wrapper for this libTiff or are there any other method from which i could generate tiles directly from tiff image or directly from pdf pages to tiles?
ImageJ can handle Tiled Pyramidal TIFF. JAI can handle MipMaps generated from TIFF files as well.
And if you're looking for a ready-made solution, take a look at djatoka.
In the end , I got the solution. There are few points that I want to explain
1) Tiles parameter in any tiff image is just a metadata value, so
there is nothing physically marking of tiles in an image
That best way I found to generate tiles out of image is BufferedImage class method:
bufferedImage.getSubimage(x, y, w, h)
Now play with this method in a loop for image matrix as per your needs.
It worked 200% perfect for me.. cheers to all :)
I have searched over bunch of sites, and I was unable to find solution for my problem.
This is the problem:
I am making PDF's in Java using iText library.
Everything works fine except one thing.
Transparent PNG images have black/gray border around non-transparent area.
I didn't set any borders in code, and actually I have tried to remove them (with no luck).
Can someone help me how to solve this problem?
The closest answer what I have found is: Resizing an image in asp.net without losing the image quality
But I cannot (don't know) interpret this code in Java.
My code is pretty big to copy/paste, but these are steps:
create document
load image from given path
manipulate image (resize, rotate, positioning)
add image to current page
save pdf file
This is what I have tried also:
http://itext-general.2136553.n4.nabble.com/template/NamlServlet.jtp?macro=print_post&node=2157267
http://itext-general.2136553.n4.nabble.com/template/NamlServlet.jtp?macro=print_post&node=2330200
I have tried more than those 2, but I didn't bookmarked them (none of them worked)
Thanks in advance
UPDATE: I forgot to mention that my original pictures don't have border. Border is created somehow by iText. I initially thought that it was bug, but since iText 5.0.2 this problem remained so now I doubt that is bug (I am currently using 5.1.3).
UPDATE 2 I forgot to add this link: http://itext-general.2136553.n4.nabble.com/template/NamlServlet.jtp?macro=print_post&node=2157261
Here is presented VB script that works, but I cannot convert to Java code (it still draws black border), so can someone help me at least with this to convert good?
You could use the java BufferedImage method, getSubImage(x, y, w, h) which allows you to crop a sub image out of an existing image. That way you could cut out the edges.
See here: Class BufferedImage