You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Manoj Patel (JIRA)" <ji...@apache.org> on 2012/05/12 07:33:56 UTC

[jira] [Created] (PDFBOX-1306) Transparent PNG file display with black border

Manoj Patel created PDFBOX-1306:
-----------------------------------

             Summary: Transparent PNG file display with black border 
                 Key: PDFBOX-1306
                 URL: https://issues.apache.org/jira/browse/PDFBOX-1306
             Project: PDFBox
          Issue Type: Bug
            Reporter: Manoj Patel


Hi,

I have added Transparent PNG file in PDF with PDFBox and it's display black border around image. I have added same PNG file with IText and it's display good in PDF.

I have used below function to add PNG file. I am using latest PDFBox SVN code to add PNG file.


public void createPDFFromImage( String inputFile, String image, String outputFile ) 
        throws IOException, COSVisitorException
    {
        // the document
        PDDocument doc = null;
        try
        {
            doc = PDDocument.load( inputFile );
            //we will add the image to the first page.
            PDPage page = (PDPage)doc.getDocumentCatalog().getAllPages().get( 0 );

            PDXObjectImage ximage = null;        
            
            
            /*if( image.toLowerCase().endsWith( ".jpg" ) )
            {
                ximage = new PDJpeg(doc, new FileInputStream( image ) );
            }
            else if (image.toLowerCase().endsWith(".tif") || image.toLowerCase().endsWith(".tiff"))
            {
                ximage = new PDCcitt(doc, new RandomAccessFile(new File(image),"r"));
            }
            else
            {
                BufferedImage awtImage = ImageIO.read( new File( image ) );
                FileInputStream inputStream = new FileInputStream(image);
                PDStream stream = new PDStream(doc, inputStream);
                ximage = new PDPixelMap(stream);
                //throw new IOException( "Image type not supported:" + image );
            }*/
            
            System.out.println("Testing");
            BufferedImage stampImage = null;
            try{
            	stampImage = ImageIO.read(new File(image));
            	
            }catch(Exception e){
            	e.printStackTrace();
            }
            
            ximage = new PDJpeg(doc, stampImage );
            //ximage = new PDPixelMap(doc, stampImage);
            COSStream stream = ximage.getCOSStream();
            PDStream pdStream = new PDStream(stream);
            ximage = new PDPixelMap(pdStream);
            //BoxImage imageData = BoxImage.getInstance(image);
            
            //System.out.println(""+imageData.getImageType());
            PDPageContentStream contentStream = new PDPageContentStream(doc, page, true, true, true);
            AffineTransform transform = new AffineTransform(stampImage.getWidth(), 0, 0, stampImage.getHeight(), 20, 200);
            //contentStream.drawImage( ximage, 20, 20 );
            contentStream.drawXObject(ximage, transform);
            contentStream.close();
            doc.save( outputFile );
        }
        finally
        {
            if( doc != null )
            {
                doc.close();
            }
        }
    }






--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Issue Comment Edited] (PDFBOX-1306) Transparent PNG file display with black border

Posted by "Manoj Patel (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-1306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13274462#comment-13274462 ] 

Manoj Patel edited comment on PDFBOX-1306 at 5/14/12 9:24 AM:
--------------------------------------------------------------

I have tried the same and it's working fine for African_Elephant_Transparent.png. 

Now have tried with NEW.png and it's gives gray border around fonts.I am using below mentioned code to scale png image in PDFBox.

int width= (int)(stampImage.getWidth()*100/300);
int height= (int)(stampImage.getHeight()*100/300);
AffineTransform transform = new AffineTransform(width, 0, 0, height, 20, 200);    

I have attached NEW.png, iText_NEW.pdf and PDFBox_NEW.pdf files. You can compare result of generated PDF files.

                
      was (Author: patelmanoj):
    I have tried the same and it's working fine for African_Elephant_Transparent.png. 

Now have tried with NEW.png and it's gives gray border around fonts.I am using below mentioned code to scale png image in PDFBox.

int width= (int)(stampImage.getWidth()*100/300);
int height= (int)(stampImage.getHeight()*100/300);
AffineTransform transform = new AffineTransform(width, 0, 0, height, 20, 200);    

I have attached NEW.png, iText_NEW.pdf and PDFBox_NEW.pdf files. You can compare result of both PDF files.

                  
> Transparent PNG file display with black border 
> -----------------------------------------------
>
>                 Key: PDFBOX-1306
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1306
>             Project: PDFBox
>          Issue Type: Bug
>            Reporter: Manoj Patel
>            Assignee: Andreas Lehmkühler
>             Fix For: 1.7.0
>
>         Attachments: African_Elephant_Transparent.png, GeneratedFileIText.pdf, GeneratedFilePDFBox.pdf, NEW.png, PDFBox_NEW.pdf, iText_NEW.pdf
>
>
> Hi,
> I have added Transparent PNG file in PDF with PDFBox and it's display black border around image. I have added same PNG file with IText and it's display good in PDF.
> I have used below function to add PNG file. I am using latest PDFBox SVN code to add PNG file.
> public void createPDFFromImage( String inputFile, String image, String outputFile ) 
>         throws IOException, COSVisitorException
>     {
>         // the document
>         PDDocument doc = null;
>         try
>         {
>             doc = PDDocument.load( inputFile );
>             //we will add the image to the first page.
>             PDPage page = (PDPage)doc.getDocumentCatalog().getAllPages().get( 0 );
>             PDXObjectImage ximage = null;        
>             
>             
>             /*if( image.toLowerCase().endsWith( ".jpg" ) )
>             {
>                 ximage = new PDJpeg(doc, new FileInputStream( image ) );
>             }
>             else if (image.toLowerCase().endsWith(".tif") || image.toLowerCase().endsWith(".tiff"))
>             {
>                 ximage = new PDCcitt(doc, new RandomAccessFile(new File(image),"r"));
>             }
>             else
>             {
>                 BufferedImage awtImage = ImageIO.read( new File( image ) );
>                 FileInputStream inputStream = new FileInputStream(image);
>                 PDStream stream = new PDStream(doc, inputStream);
>                 ximage = new PDPixelMap(stream);
>                 //throw new IOException( "Image type not supported:" + image );
>             }*/
>             
>             System.out.println("Testing");
>             BufferedImage stampImage = null;
>             try{
>             	stampImage = ImageIO.read(new File(image));
>             	
>             }catch(Exception e){
>             	e.printStackTrace();
>             }
>             
>             ximage = new PDJpeg(doc, stampImage );
>             //ximage = new PDPixelMap(doc, stampImage);
>             COSStream stream = ximage.getCOSStream();
>             PDStream pdStream = new PDStream(stream);
>             ximage = new PDPixelMap(pdStream);
>             //BoxImage imageData = BoxImage.getInstance(image);
>             
>             //System.out.println(""+imageData.getImageType());
>             PDPageContentStream contentStream = new PDPageContentStream(doc, page, true, true, true);
>             AffineTransform transform = new AffineTransform(stampImage.getWidth(), 0, 0, stampImage.getHeight(), 20, 200);
>             //contentStream.drawImage( ximage, 20, 20 );
>             contentStream.drawXObject(ximage, transform);
>             contentStream.close();
>             doc.save( outputFile );
>         }
>         finally
>         {
>             if( doc != null )
>             {
>                 doc.close();
>             }
>         }
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Updated] (PDFBOX-1306) Transparent PNG file display with black border

Posted by "Manoj Patel (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PDFBOX-1306?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Manoj Patel updated PDFBOX-1306:
--------------------------------

    Attachment: NEW.png
                iText_NEW.pdf
                PDFBox_NEW.pdf

I have used NEW.png file and it's gives gray border around image it's working fine with iText. I have attached  PDFBox_New.pdf and iText_NEW.pdf files
                
> Transparent PNG file display with black border 
> -----------------------------------------------
>
>                 Key: PDFBOX-1306
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1306
>             Project: PDFBox
>          Issue Type: Bug
>            Reporter: Manoj Patel
>            Assignee: Andreas Lehmkühler
>             Fix For: 1.7.0
>
>         Attachments: African_Elephant_Transparent.png, GeneratedFileIText.pdf, GeneratedFilePDFBox.pdf, NEW.png, PDFBox_NEW.pdf, iText_NEW.pdf
>
>
> Hi,
> I have added Transparent PNG file in PDF with PDFBox and it's display black border around image. I have added same PNG file with IText and it's display good in PDF.
> I have used below function to add PNG file. I am using latest PDFBox SVN code to add PNG file.
> public void createPDFFromImage( String inputFile, String image, String outputFile ) 
>         throws IOException, COSVisitorException
>     {
>         // the document
>         PDDocument doc = null;
>         try
>         {
>             doc = PDDocument.load( inputFile );
>             //we will add the image to the first page.
>             PDPage page = (PDPage)doc.getDocumentCatalog().getAllPages().get( 0 );
>             PDXObjectImage ximage = null;        
>             
>             
>             /*if( image.toLowerCase().endsWith( ".jpg" ) )
>             {
>                 ximage = new PDJpeg(doc, new FileInputStream( image ) );
>             }
>             else if (image.toLowerCase().endsWith(".tif") || image.toLowerCase().endsWith(".tiff"))
>             {
>                 ximage = new PDCcitt(doc, new RandomAccessFile(new File(image),"r"));
>             }
>             else
>             {
>                 BufferedImage awtImage = ImageIO.read( new File( image ) );
>                 FileInputStream inputStream = new FileInputStream(image);
>                 PDStream stream = new PDStream(doc, inputStream);
>                 ximage = new PDPixelMap(stream);
>                 //throw new IOException( "Image type not supported:" + image );
>             }*/
>             
>             System.out.println("Testing");
>             BufferedImage stampImage = null;
>             try{
>             	stampImage = ImageIO.read(new File(image));
>             	
>             }catch(Exception e){
>             	e.printStackTrace();
>             }
>             
>             ximage = new PDJpeg(doc, stampImage );
>             //ximage = new PDPixelMap(doc, stampImage);
>             COSStream stream = ximage.getCOSStream();
>             PDStream pdStream = new PDStream(stream);
>             ximage = new PDPixelMap(pdStream);
>             //BoxImage imageData = BoxImage.getInstance(image);
>             
>             //System.out.println(""+imageData.getImageType());
>             PDPageContentStream contentStream = new PDPageContentStream(doc, page, true, true, true);
>             AffineTransform transform = new AffineTransform(stampImage.getWidth(), 0, 0, stampImage.getHeight(), 20, 200);
>             //contentStream.drawImage( ximage, 20, 20 );
>             contentStream.drawXObject(ximage, transform);
>             contentStream.close();
>             doc.save( outputFile );
>         }
>         finally
>         {
>             if( doc != null )
>             {
>                 doc.close();
>             }
>         }
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Issue Comment Edited] (PDFBOX-1306) Transparent PNG file display with black border

Posted by "Manoj Patel (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-1306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13274462#comment-13274462 ] 

Manoj Patel edited comment on PDFBOX-1306 at 5/14/12 9:02 AM:
--------------------------------------------------------------

I have tried the same and it's working fine for African_Elephant_Transparent.png. 
Now have tried with NEW.png and it's gives gray border around fonts. I have attached NEW.png, iText_NEW.pdf and PDFBox_NEW.pdf files. You can compare result of both PDF files.

                
      was (Author: patelmanoj):
    I have tried the same but there is no change in result. I have built new PDFbox jar from latest svn code and tested it but its still giving black border around the image. 

                  
> Transparent PNG file display with black border 
> -----------------------------------------------
>
>                 Key: PDFBOX-1306
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1306
>             Project: PDFBox
>          Issue Type: Bug
>            Reporter: Manoj Patel
>            Assignee: Andreas Lehmkühler
>             Fix For: 1.7.0
>
>         Attachments: African_Elephant_Transparent.png, GeneratedFileIText.pdf, GeneratedFilePDFBox.pdf
>
>
> Hi,
> I have added Transparent PNG file in PDF with PDFBox and it's display black border around image. I have added same PNG file with IText and it's display good in PDF.
> I have used below function to add PNG file. I am using latest PDFBox SVN code to add PNG file.
> public void createPDFFromImage( String inputFile, String image, String outputFile ) 
>         throws IOException, COSVisitorException
>     {
>         // the document
>         PDDocument doc = null;
>         try
>         {
>             doc = PDDocument.load( inputFile );
>             //we will add the image to the first page.
>             PDPage page = (PDPage)doc.getDocumentCatalog().getAllPages().get( 0 );
>             PDXObjectImage ximage = null;        
>             
>             
>             /*if( image.toLowerCase().endsWith( ".jpg" ) )
>             {
>                 ximage = new PDJpeg(doc, new FileInputStream( image ) );
>             }
>             else if (image.toLowerCase().endsWith(".tif") || image.toLowerCase().endsWith(".tiff"))
>             {
>                 ximage = new PDCcitt(doc, new RandomAccessFile(new File(image),"r"));
>             }
>             else
>             {
>                 BufferedImage awtImage = ImageIO.read( new File( image ) );
>                 FileInputStream inputStream = new FileInputStream(image);
>                 PDStream stream = new PDStream(doc, inputStream);
>                 ximage = new PDPixelMap(stream);
>                 //throw new IOException( "Image type not supported:" + image );
>             }*/
>             
>             System.out.println("Testing");
>             BufferedImage stampImage = null;
>             try{
>             	stampImage = ImageIO.read(new File(image));
>             	
>             }catch(Exception e){
>             	e.printStackTrace();
>             }
>             
>             ximage = new PDJpeg(doc, stampImage );
>             //ximage = new PDPixelMap(doc, stampImage);
>             COSStream stream = ximage.getCOSStream();
>             PDStream pdStream = new PDStream(stream);
>             ximage = new PDPixelMap(pdStream);
>             //BoxImage imageData = BoxImage.getInstance(image);
>             
>             //System.out.println(""+imageData.getImageType());
>             PDPageContentStream contentStream = new PDPageContentStream(doc, page, true, true, true);
>             AffineTransform transform = new AffineTransform(stampImage.getWidth(), 0, 0, stampImage.getHeight(), 20, 200);
>             //contentStream.drawImage( ximage, 20, 20 );
>             contentStream.drawXObject(ximage, transform);
>             contentStream.close();
>             doc.save( outputFile );
>         }
>         finally
>         {
>             if( doc != null )
>             {
>                 doc.close();
>             }
>         }
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Issue Comment Edited] (PDFBOX-1306) Transparent PNG file display with black border

Posted by "Manoj Patel (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-1306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13274462#comment-13274462 ] 

Manoj Patel edited comment on PDFBOX-1306 at 5/14/12 6:32 AM:
--------------------------------------------------------------

I have tried the same but there is no change in result. I have built new PDFbox jar from latest svn code and tested it but its still giving black border around the image. 

                
      was (Author: patelmanoj):
    I have tried same but giving same result. I have built new PDFbox jar from latest svn code and tested it but its still giving black border around the image. 

                  
> Transparent PNG file display with black border 
> -----------------------------------------------
>
>                 Key: PDFBOX-1306
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1306
>             Project: PDFBox
>          Issue Type: Bug
>            Reporter: Manoj Patel
>            Assignee: Andreas Lehmkühler
>             Fix For: 1.7.0
>
>         Attachments: African_Elephant_Transparent.png, GeneratedFileIText.pdf, GeneratedFilePDFBox.pdf
>
>
> Hi,
> I have added Transparent PNG file in PDF with PDFBox and it's display black border around image. I have added same PNG file with IText and it's display good in PDF.
> I have used below function to add PNG file. I am using latest PDFBox SVN code to add PNG file.
> public void createPDFFromImage( String inputFile, String image, String outputFile ) 
>         throws IOException, COSVisitorException
>     {
>         // the document
>         PDDocument doc = null;
>         try
>         {
>             doc = PDDocument.load( inputFile );
>             //we will add the image to the first page.
>             PDPage page = (PDPage)doc.getDocumentCatalog().getAllPages().get( 0 );
>             PDXObjectImage ximage = null;        
>             
>             
>             /*if( image.toLowerCase().endsWith( ".jpg" ) )
>             {
>                 ximage = new PDJpeg(doc, new FileInputStream( image ) );
>             }
>             else if (image.toLowerCase().endsWith(".tif") || image.toLowerCase().endsWith(".tiff"))
>             {
>                 ximage = new PDCcitt(doc, new RandomAccessFile(new File(image),"r"));
>             }
>             else
>             {
>                 BufferedImage awtImage = ImageIO.read( new File( image ) );
>                 FileInputStream inputStream = new FileInputStream(image);
>                 PDStream stream = new PDStream(doc, inputStream);
>                 ximage = new PDPixelMap(stream);
>                 //throw new IOException( "Image type not supported:" + image );
>             }*/
>             
>             System.out.println("Testing");
>             BufferedImage stampImage = null;
>             try{
>             	stampImage = ImageIO.read(new File(image));
>             	
>             }catch(Exception e){
>             	e.printStackTrace();
>             }
>             
>             ximage = new PDJpeg(doc, stampImage );
>             //ximage = new PDPixelMap(doc, stampImage);
>             COSStream stream = ximage.getCOSStream();
>             PDStream pdStream = new PDStream(stream);
>             ximage = new PDPixelMap(pdStream);
>             //BoxImage imageData = BoxImage.getInstance(image);
>             
>             //System.out.println(""+imageData.getImageType());
>             PDPageContentStream contentStream = new PDPageContentStream(doc, page, true, true, true);
>             AffineTransform transform = new AffineTransform(stampImage.getWidth(), 0, 0, stampImage.getHeight(), 20, 200);
>             //contentStream.drawImage( ximage, 20, 20 );
>             contentStream.drawXObject(ximage, transform);
>             contentStream.close();
>             doc.save( outputFile );
>         }
>         finally
>         {
>             if( doc != null )
>             {
>                 doc.close();
>             }
>         }
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Issue Comment Edited] (PDFBOX-1306) Transparent PNG file display with black border

Posted by "Manoj Patel (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-1306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13274462#comment-13274462 ] 

Manoj Patel edited comment on PDFBOX-1306 at 5/14/12 9:24 AM:
--------------------------------------------------------------

I have tried the same and it's working fine for African_Elephant_Transparent.png. 

Now have tried with NEW.png and it's gives gray border around fonts.I am using below mentioned code to scale png image in PDFBox.

int width= (int)(stampImage.getWidth()*100/300);
int height= (int)(stampImage.getHeight()*100/300);
AffineTransform transform = new AffineTransform(width, 0, 0, height, 20, 200);    

I have attached NEW.png, iText_NEW.pdf and PDFBox_NEW.pdf files. You can compare result of both PDF files.

                
      was (Author: patelmanoj):
    I have tried the same and it's working fine for African_Elephant_Transparent.png. 
Now have tried with NEW.png and it's gives gray border around fonts. I have attached NEW.png, iText_NEW.pdf and PDFBox_NEW.pdf files. You can compare result of both PDF files.

                  
> Transparent PNG file display with black border 
> -----------------------------------------------
>
>                 Key: PDFBOX-1306
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1306
>             Project: PDFBox
>          Issue Type: Bug
>            Reporter: Manoj Patel
>            Assignee: Andreas Lehmkühler
>             Fix For: 1.7.0
>
>         Attachments: African_Elephant_Transparent.png, GeneratedFileIText.pdf, GeneratedFilePDFBox.pdf, NEW.png, PDFBox_NEW.pdf, iText_NEW.pdf
>
>
> Hi,
> I have added Transparent PNG file in PDF with PDFBox and it's display black border around image. I have added same PNG file with IText and it's display good in PDF.
> I have used below function to add PNG file. I am using latest PDFBox SVN code to add PNG file.
> public void createPDFFromImage( String inputFile, String image, String outputFile ) 
>         throws IOException, COSVisitorException
>     {
>         // the document
>         PDDocument doc = null;
>         try
>         {
>             doc = PDDocument.load( inputFile );
>             //we will add the image to the first page.
>             PDPage page = (PDPage)doc.getDocumentCatalog().getAllPages().get( 0 );
>             PDXObjectImage ximage = null;        
>             
>             
>             /*if( image.toLowerCase().endsWith( ".jpg" ) )
>             {
>                 ximage = new PDJpeg(doc, new FileInputStream( image ) );
>             }
>             else if (image.toLowerCase().endsWith(".tif") || image.toLowerCase().endsWith(".tiff"))
>             {
>                 ximage = new PDCcitt(doc, new RandomAccessFile(new File(image),"r"));
>             }
>             else
>             {
>                 BufferedImage awtImage = ImageIO.read( new File( image ) );
>                 FileInputStream inputStream = new FileInputStream(image);
>                 PDStream stream = new PDStream(doc, inputStream);
>                 ximage = new PDPixelMap(stream);
>                 //throw new IOException( "Image type not supported:" + image );
>             }*/
>             
>             System.out.println("Testing");
>             BufferedImage stampImage = null;
>             try{
>             	stampImage = ImageIO.read(new File(image));
>             	
>             }catch(Exception e){
>             	e.printStackTrace();
>             }
>             
>             ximage = new PDJpeg(doc, stampImage );
>             //ximage = new PDPixelMap(doc, stampImage);
>             COSStream stream = ximage.getCOSStream();
>             PDStream pdStream = new PDStream(stream);
>             ximage = new PDPixelMap(pdStream);
>             //BoxImage imageData = BoxImage.getInstance(image);
>             
>             //System.out.println(""+imageData.getImageType());
>             PDPageContentStream contentStream = new PDPageContentStream(doc, page, true, true, true);
>             AffineTransform transform = new AffineTransform(stampImage.getWidth(), 0, 0, stampImage.getHeight(), 20, 200);
>             //contentStream.drawImage( ximage, 20, 20 );
>             contentStream.drawXObject(ximage, transform);
>             contentStream.close();
>             doc.save( outputFile );
>         }
>         finally
>         {
>             if( doc != null )
>             {
>                 doc.close();
>             }
>         }
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Resolved] (PDFBOX-1306) Transparent PNG file display with black border

Posted by "Andreas Lehmkühler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PDFBOX-1306?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andreas Lehmkühler resolved PDFBOX-1306.
----------------------------------------

       Resolution: Fixed
    Fix Version/s: 1.7.0
         Assignee: Andreas Lehmkühler

I fixed the smask creation in revision 1337790.

BTW: You don't need to create an PDXObjectImage using the stream of a PDJpeg object. Just use the PDJpeg.
                
> Transparent PNG file display with black border 
> -----------------------------------------------
>
>                 Key: PDFBOX-1306
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1306
>             Project: PDFBox
>          Issue Type: Bug
>            Reporter: Manoj Patel
>            Assignee: Andreas Lehmkühler
>             Fix For: 1.7.0
>
>         Attachments: African_Elephant_Transparent.png, GeneratedFileIText.pdf, GeneratedFilePDFBox.pdf
>
>
> Hi,
> I have added Transparent PNG file in PDF with PDFBox and it's display black border around image. I have added same PNG file with IText and it's display good in PDF.
> I have used below function to add PNG file. I am using latest PDFBox SVN code to add PNG file.
> public void createPDFFromImage( String inputFile, String image, String outputFile ) 
>         throws IOException, COSVisitorException
>     {
>         // the document
>         PDDocument doc = null;
>         try
>         {
>             doc = PDDocument.load( inputFile );
>             //we will add the image to the first page.
>             PDPage page = (PDPage)doc.getDocumentCatalog().getAllPages().get( 0 );
>             PDXObjectImage ximage = null;        
>             
>             
>             /*if( image.toLowerCase().endsWith( ".jpg" ) )
>             {
>                 ximage = new PDJpeg(doc, new FileInputStream( image ) );
>             }
>             else if (image.toLowerCase().endsWith(".tif") || image.toLowerCase().endsWith(".tiff"))
>             {
>                 ximage = new PDCcitt(doc, new RandomAccessFile(new File(image),"r"));
>             }
>             else
>             {
>                 BufferedImage awtImage = ImageIO.read( new File( image ) );
>                 FileInputStream inputStream = new FileInputStream(image);
>                 PDStream stream = new PDStream(doc, inputStream);
>                 ximage = new PDPixelMap(stream);
>                 //throw new IOException( "Image type not supported:" + image );
>             }*/
>             
>             System.out.println("Testing");
>             BufferedImage stampImage = null;
>             try{
>             	stampImage = ImageIO.read(new File(image));
>             	
>             }catch(Exception e){
>             	e.printStackTrace();
>             }
>             
>             ximage = new PDJpeg(doc, stampImage );
>             //ximage = new PDPixelMap(doc, stampImage);
>             COSStream stream = ximage.getCOSStream();
>             PDStream pdStream = new PDStream(stream);
>             ximage = new PDPixelMap(pdStream);
>             //BoxImage imageData = BoxImage.getInstance(image);
>             
>             //System.out.println(""+imageData.getImageType());
>             PDPageContentStream contentStream = new PDPageContentStream(doc, page, true, true, true);
>             AffineTransform transform = new AffineTransform(stampImage.getWidth(), 0, 0, stampImage.getHeight(), 20, 200);
>             //contentStream.drawImage( ximage, 20, 20 );
>             contentStream.drawXObject(ximage, transform);
>             contentStream.close();
>             doc.save( outputFile );
>         }
>         finally
>         {
>             if( doc != null )
>             {
>                 doc.close();
>             }
>         }
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Issue Comment Edited] (PDFBOX-1306) Transparent PNG file display with black border

Posted by "Manoj Patel (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-1306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13274462#comment-13274462 ] 

Manoj Patel edited comment on PDFBOX-1306 at 5/14/12 6:06 AM:
--------------------------------------------------------------

I have tried same but giving same result. I have built new PDFbox jar from latest svn code and tested it but its still giving black border around the image. 

                
      was (Author: patelmanoj):
    I have tried same but giving same result
                  
> Transparent PNG file display with black border 
> -----------------------------------------------
>
>                 Key: PDFBOX-1306
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1306
>             Project: PDFBox
>          Issue Type: Bug
>            Reporter: Manoj Patel
>            Assignee: Andreas Lehmkühler
>             Fix For: 1.7.0
>
>         Attachments: African_Elephant_Transparent.png, GeneratedFileIText.pdf, GeneratedFilePDFBox.pdf
>
>
> Hi,
> I have added Transparent PNG file in PDF with PDFBox and it's display black border around image. I have added same PNG file with IText and it's display good in PDF.
> I have used below function to add PNG file. I am using latest PDFBox SVN code to add PNG file.
> public void createPDFFromImage( String inputFile, String image, String outputFile ) 
>         throws IOException, COSVisitorException
>     {
>         // the document
>         PDDocument doc = null;
>         try
>         {
>             doc = PDDocument.load( inputFile );
>             //we will add the image to the first page.
>             PDPage page = (PDPage)doc.getDocumentCatalog().getAllPages().get( 0 );
>             PDXObjectImage ximage = null;        
>             
>             
>             /*if( image.toLowerCase().endsWith( ".jpg" ) )
>             {
>                 ximage = new PDJpeg(doc, new FileInputStream( image ) );
>             }
>             else if (image.toLowerCase().endsWith(".tif") || image.toLowerCase().endsWith(".tiff"))
>             {
>                 ximage = new PDCcitt(doc, new RandomAccessFile(new File(image),"r"));
>             }
>             else
>             {
>                 BufferedImage awtImage = ImageIO.read( new File( image ) );
>                 FileInputStream inputStream = new FileInputStream(image);
>                 PDStream stream = new PDStream(doc, inputStream);
>                 ximage = new PDPixelMap(stream);
>                 //throw new IOException( "Image type not supported:" + image );
>             }*/
>             
>             System.out.println("Testing");
>             BufferedImage stampImage = null;
>             try{
>             	stampImage = ImageIO.read(new File(image));
>             	
>             }catch(Exception e){
>             	e.printStackTrace();
>             }
>             
>             ximage = new PDJpeg(doc, stampImage );
>             //ximage = new PDPixelMap(doc, stampImage);
>             COSStream stream = ximage.getCOSStream();
>             PDStream pdStream = new PDStream(stream);
>             ximage = new PDPixelMap(pdStream);
>             //BoxImage imageData = BoxImage.getInstance(image);
>             
>             //System.out.println(""+imageData.getImageType());
>             PDPageContentStream contentStream = new PDPageContentStream(doc, page, true, true, true);
>             AffineTransform transform = new AffineTransform(stampImage.getWidth(), 0, 0, stampImage.getHeight(), 20, 200);
>             //contentStream.drawImage( ximage, 20, 20 );
>             contentStream.drawXObject(ximage, transform);
>             contentStream.close();
>             doc.save( outputFile );
>         }
>         finally
>         {
>             if( doc != null )
>             {
>                 doc.close();
>             }
>         }
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Resolved] (PDFBOX-1306) Transparent PNG file display with black border

Posted by "Andreas Lehmkühler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PDFBOX-1306?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andreas Lehmkühler resolved PDFBOX-1306.
----------------------------------------

    Resolution: Fixed

My first patch improved the SMask creation but it wasn't perfect. I optimized it once again in revision 1338247. But I'm afraid that's the maximum of quality we can get here. 
In the end it is not a good idea to use a lossy DCTFilter to compress the data. Instead one should use the lossless FlateDecode filter. I extended the PDPixelMap class similar to the PDJpeg class in revision 1338248.
Just use a PDPixelMap instead of a PDJpeg to add an image with transparency.

Thanks for coming back and your input.
                
> Transparent PNG file display with black border 
> -----------------------------------------------
>
>                 Key: PDFBOX-1306
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1306
>             Project: PDFBox
>          Issue Type: Bug
>            Reporter: Manoj Patel
>            Assignee: Andreas Lehmkühler
>             Fix For: 1.7.0
>
>         Attachments: African_Elephant_Transparent.png, GeneratedFileIText.pdf, GeneratedFilePDFBox.pdf, NEW.png, PDFBox_NEW.pdf, iText_NEW.pdf
>
>
> Hi,
> I have added Transparent PNG file in PDF with PDFBox and it's display black border around image. I have added same PNG file with IText and it's display good in PDF.
> I have used below function to add PNG file. I am using latest PDFBox SVN code to add PNG file.
> public void createPDFFromImage( String inputFile, String image, String outputFile ) 
>         throws IOException, COSVisitorException
>     {
>         // the document
>         PDDocument doc = null;
>         try
>         {
>             doc = PDDocument.load( inputFile );
>             //we will add the image to the first page.
>             PDPage page = (PDPage)doc.getDocumentCatalog().getAllPages().get( 0 );
>             PDXObjectImage ximage = null;        
>             
>             
>             /*if( image.toLowerCase().endsWith( ".jpg" ) )
>             {
>                 ximage = new PDJpeg(doc, new FileInputStream( image ) );
>             }
>             else if (image.toLowerCase().endsWith(".tif") || image.toLowerCase().endsWith(".tiff"))
>             {
>                 ximage = new PDCcitt(doc, new RandomAccessFile(new File(image),"r"));
>             }
>             else
>             {
>                 BufferedImage awtImage = ImageIO.read( new File( image ) );
>                 FileInputStream inputStream = new FileInputStream(image);
>                 PDStream stream = new PDStream(doc, inputStream);
>                 ximage = new PDPixelMap(stream);
>                 //throw new IOException( "Image type not supported:" + image );
>             }*/
>             
>             System.out.println("Testing");
>             BufferedImage stampImage = null;
>             try{
>             	stampImage = ImageIO.read(new File(image));
>             	
>             }catch(Exception e){
>             	e.printStackTrace();
>             }
>             
>             ximage = new PDJpeg(doc, stampImage );
>             //ximage = new PDPixelMap(doc, stampImage);
>             COSStream stream = ximage.getCOSStream();
>             PDStream pdStream = new PDStream(stream);
>             ximage = new PDPixelMap(pdStream);
>             //BoxImage imageData = BoxImage.getInstance(image);
>             
>             //System.out.println(""+imageData.getImageType());
>             PDPageContentStream contentStream = new PDPageContentStream(doc, page, true, true, true);
>             AffineTransform transform = new AffineTransform(stampImage.getWidth(), 0, 0, stampImage.getHeight(), 20, 200);
>             //contentStream.drawImage( ximage, 20, 20 );
>             contentStream.drawXObject(ximage, transform);
>             contentStream.close();
>             doc.save( outputFile );
>         }
>         finally
>         {
>             if( doc != null )
>             {
>                 doc.close();
>             }
>         }
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Updated] (PDFBOX-1306) Transparent PNG file display with black border

Posted by "Manoj Patel (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PDFBOX-1306?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Manoj Patel updated PDFBOX-1306:
--------------------------------

    Comment: was deleted

(was: Attachments NEW.png, iText_NEW.pdf and PDFBox_NEW.pdf)
    
> Transparent PNG file display with black border 
> -----------------------------------------------
>
>                 Key: PDFBOX-1306
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1306
>             Project: PDFBox
>          Issue Type: Bug
>            Reporter: Manoj Patel
>            Assignee: Andreas Lehmkühler
>             Fix For: 1.7.0
>
>         Attachments: African_Elephant_Transparent.png, GeneratedFileIText.pdf, GeneratedFilePDFBox.pdf, NEW.png, PDFBox_NEW.pdf, iText_NEW.pdf
>
>
> Hi,
> I have added Transparent PNG file in PDF with PDFBox and it's display black border around image. I have added same PNG file with IText and it's display good in PDF.
> I have used below function to add PNG file. I am using latest PDFBox SVN code to add PNG file.
> public void createPDFFromImage( String inputFile, String image, String outputFile ) 
>         throws IOException, COSVisitorException
>     {
>         // the document
>         PDDocument doc = null;
>         try
>         {
>             doc = PDDocument.load( inputFile );
>             //we will add the image to the first page.
>             PDPage page = (PDPage)doc.getDocumentCatalog().getAllPages().get( 0 );
>             PDXObjectImage ximage = null;        
>             
>             
>             /*if( image.toLowerCase().endsWith( ".jpg" ) )
>             {
>                 ximage = new PDJpeg(doc, new FileInputStream( image ) );
>             }
>             else if (image.toLowerCase().endsWith(".tif") || image.toLowerCase().endsWith(".tiff"))
>             {
>                 ximage = new PDCcitt(doc, new RandomAccessFile(new File(image),"r"));
>             }
>             else
>             {
>                 BufferedImage awtImage = ImageIO.read( new File( image ) );
>                 FileInputStream inputStream = new FileInputStream(image);
>                 PDStream stream = new PDStream(doc, inputStream);
>                 ximage = new PDPixelMap(stream);
>                 //throw new IOException( "Image type not supported:" + image );
>             }*/
>             
>             System.out.println("Testing");
>             BufferedImage stampImage = null;
>             try{
>             	stampImage = ImageIO.read(new File(image));
>             	
>             }catch(Exception e){
>             	e.printStackTrace();
>             }
>             
>             ximage = new PDJpeg(doc, stampImage );
>             //ximage = new PDPixelMap(doc, stampImage);
>             COSStream stream = ximage.getCOSStream();
>             PDStream pdStream = new PDStream(stream);
>             ximage = new PDPixelMap(pdStream);
>             //BoxImage imageData = BoxImage.getInstance(image);
>             
>             //System.out.println(""+imageData.getImageType());
>             PDPageContentStream contentStream = new PDPageContentStream(doc, page, true, true, true);
>             AffineTransform transform = new AffineTransform(stampImage.getWidth(), 0, 0, stampImage.getHeight(), 20, 200);
>             //contentStream.drawImage( ximage, 20, 20 );
>             contentStream.drawXObject(ximage, transform);
>             contentStream.close();
>             doc.save( outputFile );
>         }
>         finally
>         {
>             if( doc != null )
>             {
>                 doc.close();
>             }
>         }
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Updated] (PDFBOX-1306) Transparent PNG file display with black border

Posted by "Manoj Patel (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PDFBOX-1306?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Manoj Patel updated PDFBOX-1306:
--------------------------------

    Attachment: GeneratedFilePDFBox.pdf
                GeneratedFileIText.pdf
                African_Elephant_Transparent.png

Attached are the PNG and generated PDF files with PDFBox and IText
                
> Transparent PNG file display with black border 
> -----------------------------------------------
>
>                 Key: PDFBOX-1306
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1306
>             Project: PDFBox
>          Issue Type: Bug
>            Reporter: Manoj Patel
>         Attachments: African_Elephant_Transparent.png, GeneratedFileIText.pdf, GeneratedFilePDFBox.pdf
>
>
> Hi,
> I have added Transparent PNG file in PDF with PDFBox and it's display black border around image. I have added same PNG file with IText and it's display good in PDF.
> I have used below function to add PNG file. I am using latest PDFBox SVN code to add PNG file.
> public void createPDFFromImage( String inputFile, String image, String outputFile ) 
>         throws IOException, COSVisitorException
>     {
>         // the document
>         PDDocument doc = null;
>         try
>         {
>             doc = PDDocument.load( inputFile );
>             //we will add the image to the first page.
>             PDPage page = (PDPage)doc.getDocumentCatalog().getAllPages().get( 0 );
>             PDXObjectImage ximage = null;        
>             
>             
>             /*if( image.toLowerCase().endsWith( ".jpg" ) )
>             {
>                 ximage = new PDJpeg(doc, new FileInputStream( image ) );
>             }
>             else if (image.toLowerCase().endsWith(".tif") || image.toLowerCase().endsWith(".tiff"))
>             {
>                 ximage = new PDCcitt(doc, new RandomAccessFile(new File(image),"r"));
>             }
>             else
>             {
>                 BufferedImage awtImage = ImageIO.read( new File( image ) );
>                 FileInputStream inputStream = new FileInputStream(image);
>                 PDStream stream = new PDStream(doc, inputStream);
>                 ximage = new PDPixelMap(stream);
>                 //throw new IOException( "Image type not supported:" + image );
>             }*/
>             
>             System.out.println("Testing");
>             BufferedImage stampImage = null;
>             try{
>             	stampImage = ImageIO.read(new File(image));
>             	
>             }catch(Exception e){
>             	e.printStackTrace();
>             }
>             
>             ximage = new PDJpeg(doc, stampImage );
>             //ximage = new PDPixelMap(doc, stampImage);
>             COSStream stream = ximage.getCOSStream();
>             PDStream pdStream = new PDStream(stream);
>             ximage = new PDPixelMap(pdStream);
>             //BoxImage imageData = BoxImage.getInstance(image);
>             
>             //System.out.println(""+imageData.getImageType());
>             PDPageContentStream contentStream = new PDPageContentStream(doc, page, true, true, true);
>             AffineTransform transform = new AffineTransform(stampImage.getWidth(), 0, 0, stampImage.getHeight(), 20, 200);
>             //contentStream.drawImage( ximage, 20, 20 );
>             contentStream.drawXObject(ximage, transform);
>             contentStream.close();
>             doc.save( outputFile );
>         }
>         finally
>         {
>             if( doc != null )
>             {
>                 doc.close();
>             }
>         }
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Issue Comment Edited] (PDFBOX-1306) Transparent PNG file display with black border

Posted by "Manoj Patel (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-1306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13274516#comment-13274516 ] 

Manoj Patel edited comment on PDFBOX-1306 at 5/14/12 9:06 AM:
--------------------------------------------------------------

Attachments NEW.png, iText_NEW.pdf and PDFBox_NEW.pdf
                
      was (Author: patelmanoj):
    I have used NEW.png file and it's gives gray border around image it's working fine with iText. I have attached  PDFBox_New.pdf and iText_NEW.pdf files
                  
> Transparent PNG file display with black border 
> -----------------------------------------------
>
>                 Key: PDFBOX-1306
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1306
>             Project: PDFBox
>          Issue Type: Bug
>            Reporter: Manoj Patel
>            Assignee: Andreas Lehmkühler
>             Fix For: 1.7.0
>
>         Attachments: African_Elephant_Transparent.png, GeneratedFileIText.pdf, GeneratedFilePDFBox.pdf, NEW.png, PDFBox_NEW.pdf, iText_NEW.pdf
>
>
> Hi,
> I have added Transparent PNG file in PDF with PDFBox and it's display black border around image. I have added same PNG file with IText and it's display good in PDF.
> I have used below function to add PNG file. I am using latest PDFBox SVN code to add PNG file.
> public void createPDFFromImage( String inputFile, String image, String outputFile ) 
>         throws IOException, COSVisitorException
>     {
>         // the document
>         PDDocument doc = null;
>         try
>         {
>             doc = PDDocument.load( inputFile );
>             //we will add the image to the first page.
>             PDPage page = (PDPage)doc.getDocumentCatalog().getAllPages().get( 0 );
>             PDXObjectImage ximage = null;        
>             
>             
>             /*if( image.toLowerCase().endsWith( ".jpg" ) )
>             {
>                 ximage = new PDJpeg(doc, new FileInputStream( image ) );
>             }
>             else if (image.toLowerCase().endsWith(".tif") || image.toLowerCase().endsWith(".tiff"))
>             {
>                 ximage = new PDCcitt(doc, new RandomAccessFile(new File(image),"r"));
>             }
>             else
>             {
>                 BufferedImage awtImage = ImageIO.read( new File( image ) );
>                 FileInputStream inputStream = new FileInputStream(image);
>                 PDStream stream = new PDStream(doc, inputStream);
>                 ximage = new PDPixelMap(stream);
>                 //throw new IOException( "Image type not supported:" + image );
>             }*/
>             
>             System.out.println("Testing");
>             BufferedImage stampImage = null;
>             try{
>             	stampImage = ImageIO.read(new File(image));
>             	
>             }catch(Exception e){
>             	e.printStackTrace();
>             }
>             
>             ximage = new PDJpeg(doc, stampImage );
>             //ximage = new PDPixelMap(doc, stampImage);
>             COSStream stream = ximage.getCOSStream();
>             PDStream pdStream = new PDStream(stream);
>             ximage = new PDPixelMap(pdStream);
>             //BoxImage imageData = BoxImage.getInstance(image);
>             
>             //System.out.println(""+imageData.getImageType());
>             PDPageContentStream contentStream = new PDPageContentStream(doc, page, true, true, true);
>             AffineTransform transform = new AffineTransform(stampImage.getWidth(), 0, 0, stampImage.getHeight(), 20, 200);
>             //contentStream.drawImage( ximage, 20, 20 );
>             contentStream.drawXObject(ximage, transform);
>             contentStream.close();
>             doc.save( outputFile );
>         }
>         finally
>         {
>             if( doc != null )
>             {
>                 doc.close();
>             }
>         }
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Reopened] (PDFBOX-1306) Transparent PNG file display with black border

Posted by "Manoj Patel (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PDFBOX-1306?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Manoj Patel reopened PDFBOX-1306:
---------------------------------


I have tried same but giving same result
                
> Transparent PNG file display with black border 
> -----------------------------------------------
>
>                 Key: PDFBOX-1306
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1306
>             Project: PDFBox
>          Issue Type: Bug
>            Reporter: Manoj Patel
>            Assignee: Andreas Lehmkühler
>             Fix For: 1.7.0
>
>         Attachments: African_Elephant_Transparent.png, GeneratedFileIText.pdf, GeneratedFilePDFBox.pdf
>
>
> Hi,
> I have added Transparent PNG file in PDF with PDFBox and it's display black border around image. I have added same PNG file with IText and it's display good in PDF.
> I have used below function to add PNG file. I am using latest PDFBox SVN code to add PNG file.
> public void createPDFFromImage( String inputFile, String image, String outputFile ) 
>         throws IOException, COSVisitorException
>     {
>         // the document
>         PDDocument doc = null;
>         try
>         {
>             doc = PDDocument.load( inputFile );
>             //we will add the image to the first page.
>             PDPage page = (PDPage)doc.getDocumentCatalog().getAllPages().get( 0 );
>             PDXObjectImage ximage = null;        
>             
>             
>             /*if( image.toLowerCase().endsWith( ".jpg" ) )
>             {
>                 ximage = new PDJpeg(doc, new FileInputStream( image ) );
>             }
>             else if (image.toLowerCase().endsWith(".tif") || image.toLowerCase().endsWith(".tiff"))
>             {
>                 ximage = new PDCcitt(doc, new RandomAccessFile(new File(image),"r"));
>             }
>             else
>             {
>                 BufferedImage awtImage = ImageIO.read( new File( image ) );
>                 FileInputStream inputStream = new FileInputStream(image);
>                 PDStream stream = new PDStream(doc, inputStream);
>                 ximage = new PDPixelMap(stream);
>                 //throw new IOException( "Image type not supported:" + image );
>             }*/
>             
>             System.out.println("Testing");
>             BufferedImage stampImage = null;
>             try{
>             	stampImage = ImageIO.read(new File(image));
>             	
>             }catch(Exception e){
>             	e.printStackTrace();
>             }
>             
>             ximage = new PDJpeg(doc, stampImage );
>             //ximage = new PDPixelMap(doc, stampImage);
>             COSStream stream = ximage.getCOSStream();
>             PDStream pdStream = new PDStream(stream);
>             ximage = new PDPixelMap(pdStream);
>             //BoxImage imageData = BoxImage.getInstance(image);
>             
>             //System.out.println(""+imageData.getImageType());
>             PDPageContentStream contentStream = new PDPageContentStream(doc, page, true, true, true);
>             AffineTransform transform = new AffineTransform(stampImage.getWidth(), 0, 0, stampImage.getHeight(), 20, 200);
>             //contentStream.drawImage( ximage, 20, 20 );
>             contentStream.drawXObject(ximage, transform);
>             contentStream.close();
>             doc.save( outputFile );
>         }
>         finally
>         {
>             if( doc != null )
>             {
>                 doc.close();
>             }
>         }
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira