Hello to all...when i convert tiff2pdf i found a little problem, for some
particular tiff (wich have COMP_FAX_G3_2D compression) the result pdf have
color inverted (black to white and white to black).

Is there a way using itext to invert the colors of the image?


my code is:



ByteArrayOutputStream baos = new ByteArrayOutputStream();
        Document document = new Document();
                PdfWriter writer = PdfWriter.getInstance(document, baos);
        try {
                        int pages = 0;
                        document.open();
                        PdfContentByte cb = writer.getDirectContent();
                        RandomAccessFileOrArray ra = null;
                        int comps = 0;
                        ra = new RandomAccessFileOrArray(tiff.getStream());
                        comps = TiffImage.getNumberOfPages(ra);
                        for (int c = 0; c < comps; ++c) {

                                Image img = TiffImage.getTiffImage(ra, c + 1);
                                long h = 0;
                                long w = 0;
                                if (img != null) {
                                        Float height = new 
Float(img.getScaledHeight());
                                        h = height.longValue();
                                        Float width = new 
Float(img.getScaledWidth());
                                        w = width.longValue();
                                        float percent = 100;
                                        int pos = 0;
                                        if (w > 895)
                                                percent = ((595 + 18) * 100 / 
w);
                                        if (h > 842)
                                                pos = (int) (842 - h * percent 
/ 100);
                                        else
                                                pos = (int) (842 - h);

                                        img.scalePercent(percent);
                                        img.setAbsolutePosition(0, pos);
              
                                        document.add(new Paragraph());
                                        cb.addImage(img);
                                        document.newPage();
                                        ++pages;
                                }

                        }

                        ra.close();
                        document.close();
                        writer.close();

-- 
View this message in context: 
http://www.nabble.com/how-to-invert-color-of-tiff-using-itext-tp23667238p23667238.html
Sent from the iText - General mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to