You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Andreas Lehmkühler (JIRA)" <ji...@apache.org> on 2016/11/11 11:31:58 UTC

[jira] [Updated] (PDFBOX-3565) PDF Compress using PDStream is not working.

     [ https://issues.apache.org/jira/browse/PDFBOX-3565?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andreas Lehmkühler updated PDFBOX-3565:
---------------------------------------
    Description: 
We are trying compress PDF using PDFBox 2.0.2 version.
As mentioned in PDFBox 2.0.2 migration guide we are using PDSream object with COSName.FLATE_DECODE which should compress the pdf. 

1) 
{code}
   File toCompress = new File("toCompress.pdf");
   File compressedOutputFile = new File("compressedFile.pdf");
    try {
        PDDocument doc = new PDDocument();
        InputStream in = new FileInputStream(toCompress);
        OutputStream out = new FileOutputStream(compressedOutputFile);

        PDPage page = new PDPage();
        doc.addPage(page);

        PDStream stream = new PDStream(doc, in,    COSName.FLATE_DECODE);

        doc.save(out);
        doc.close();

    } catch (Exception e) {

    }
{code}

above code snippet gives us blank compressed file with size 0. 

2) We try to load pdf stream data on document and then compress it . 

{code}
   File toCompress = new File("toCompress.pdf");
   File compressedOutputFile = new File("compressedFile.pdf");

    try {
        PDDocument doc = new PDDocument();
         doc.load(toCompress)
        InputStream in = new FileInputStream(toCompress);
        OutputStream out = new FileOutputStream(compressedOutputFile);

        PDPage page = new PDPage();
        doc.addPage(page);

        PDStream stream = new PDStream(doc, in,    COSName.FLATE_DECODE);

        doc.save(out);
        doc.close();

    } catch (Exception e) {

    }
{code}

here we get new compressed file which is having bigger size than original one.

So in short for compression  using PdfBox 2.0.,2 version is not working. 
Please guide us how to do compress PdfBox 2.0.,2 version.

  was:
We are trying compress PDF using PDFBox 2.0.2 version.
As mentioned in PDFBox 2.0.2 migration guide we are using PDSream object with COSName.FLATE_DECODE which should compress the pdf. 

1) 
File toCompress = new File("toCompress.pdf");
   File compressedOutputFile = new File("compressedFile.pdf");

    try {
        PDDocument doc = new PDDocument();
        InputStream in = new FileInputStream(toCompress);
        OutputStream out = new FileOutputStream(compressedOutputFile);

        PDPage page = new PDPage();
        doc.addPage(page);

        PDStream stream = new PDStream(doc, in,    COSName.FLATE_DECODE);

        doc.save(out);
        doc.close();

    } catch (Exception e) {

    }

above code snippet gives us blank compressed file with size 0. 

2) We try to load pdf stream data on document and then compress it . 

File toCompress = new File("toCompress.pdf");
   File compressedOutputFile = new File("compressedFile.pdf");

    try {
        PDDocument doc = new PDDocument();
         doc.load(toCompress)
        InputStream in = new FileInputStream(toCompress);
        OutputStream out = new FileOutputStream(compressedOutputFile);

        PDPage page = new PDPage();
        doc.addPage(page);

        PDStream stream = new PDStream(doc, in,    COSName.FLATE_DECODE);

        doc.save(out);
        doc.close();

    } catch (Exception e) {

    }

here we get new compressed file which is having bigger size than original one.

So in short for compression  using PdfBox 2.0.,2 version is not working. 
Please guide us how to do compress PdfBox 2.0.,2 version.


> PDF Compress using PDStream is not working. 
> --------------------------------------------
>
>                 Key: PDFBOX-3565
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3565
>             Project: PDFBox
>          Issue Type: Bug
>         Environment: PDFBox 2.0.2 version 
>            Reporter: Shubhangi Gojir Nipane
>            Priority: Blocker
>
> We are trying compress PDF using PDFBox 2.0.2 version.
> As mentioned in PDFBox 2.0.2 migration guide we are using PDSream object with COSName.FLATE_DECODE which should compress the pdf. 
> 1) 
> {code}
>    File toCompress = new File("toCompress.pdf");
>    File compressedOutputFile = new File("compressedFile.pdf");
>     try {
>         PDDocument doc = new PDDocument();
>         InputStream in = new FileInputStream(toCompress);
>         OutputStream out = new FileOutputStream(compressedOutputFile);
>         PDPage page = new PDPage();
>         doc.addPage(page);
>         PDStream stream = new PDStream(doc, in,    COSName.FLATE_DECODE);
>         doc.save(out);
>         doc.close();
>     } catch (Exception e) {
>     }
> {code}
> above code snippet gives us blank compressed file with size 0. 
> 2) We try to load pdf stream data on document and then compress it . 
> {code}
>    File toCompress = new File("toCompress.pdf");
>    File compressedOutputFile = new File("compressedFile.pdf");
>     try {
>         PDDocument doc = new PDDocument();
>          doc.load(toCompress)
>         InputStream in = new FileInputStream(toCompress);
>         OutputStream out = new FileOutputStream(compressedOutputFile);
>         PDPage page = new PDPage();
>         doc.addPage(page);
>         PDStream stream = new PDStream(doc, in,    COSName.FLATE_DECODE);
>         doc.save(out);
>         doc.close();
>     } catch (Exception e) {
>     }
> {code}
> here we get new compressed file which is having bigger size than original one.
> So in short for compression  using PdfBox 2.0.,2 version is not working. 
> Please guide us how to do compress PdfBox 2.0.,2 version.



--
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