Hi,

That code doesn't "saving it with the program". No saving there, only display. You wrote yesterday that the file size gets reduced somehow ("1.2mB to 532.4kB").

I'm asking because your PDF is of bad visual quality, and I'm trying to find out how the PDF became so.

Tilman


Am 21.09.2017 um 12:39 schrieb [email protected]:

Hi

Ok I will try and explain the process as clear as I can.

Thanks for looking so far.

    1) It starts of by loading the pdf and rendering the pages into Buffered Images which are added to an                     ArrayList(this.docList). The ArrayList (this.docList is sent to a method (DisplayDocs2).


 public JPanel *makeDocument*() throws IOException, FileNotFoundException{

        File target = new File(filePath);
         PDDocument pddocument = PDDocument.load(target);


             JPanel displayView = new JPanel();



        //try (PDDocument pddocument = PDDocument.load(target)) {
            PDFRenderer pdfrend = new PDFRenderer(pddocument);


            for (int i = 0; i < pddocument.getNumberOfPages(); i ++){
                BufferedImage pageImage = pdfrend.renderImageWithDPI(i,300,ImageType.RGB);
                this.docList.add(pageImage);
                }


            displayProcessing = new DisplayDocs2(this.docList);

            displayView = displayProcessing.getPanel();

          pddocument.close();

        return displayView;

    }


    2) In (DisplayDocs2) the Buffered Image in (docList) are painted onto a JPanel. This JPanel is returned via                         (Doc_processing)  to a class called (FileMenu) where it is processed for Display.

@Override
    protected void paintComponent(Graphics g){

        super.paintComponent(g);
          if (docList.get(0).getWidth() > docList.get(0).getHeight()){
              imageWidth = 900;
              imageHeight = 595;
      }

      if (this.createdImage == null){
          this.createdImage = new BufferedImage(imageWidth,imageHeight*docList.size()*zoomup,
          BufferedImage.TYPE_INT_ARGB);
      }


        Graphics g2 = this.createdImage.createGraphics();

        if (controlWhichImage == 1){

            for(BufferedImage eachImage : docList){

                //Draw image on JPanel at the same time draw image on this.createdImage                 //g.drawImage(eachImage, 0,inty,imageWidth,imageHeight,this);
g2.drawImage(eachImage,0,inty,imageWidth,imageHeight,this);
                intx += eachImage.getWidth();
                inty += eachImage.getHeight();


                }


There is no problem with pdf's that are produced on a computer the problem comes when I try to view a scanned document.

I hope I have made this clear enough.

Gerry


On 20.09.2017 18:21, Tilman Hausherr wrote:
Hi,

Maybe explain what your "program" is. Explain the whole sequence from start to finish. PDFBox doesn't reduce image quality if you just loaded and saved a PDF.

Could it be that you created an image from a PDF, then created a PDF from this image? If yes, then take care to render at a good dpi the first time.

Tilman

Am 20.09.2017 um 18:12 schrieb [email protected]:

Hi

My PDF is the result of loading it into my program and then saving it with the program. When I use document viewer it is clear, it is only when I put it through my program that the file size is reduced from 1.2mB to 532.4kB ?

Gerry



-------- Forwarded Message --------
Subject:        Re: pdf shows as very pixelated
Date:   Wed, 20 Sep 2017 17:54:06 +0200
From:   Tilman Hausherr <[email protected]>
Reply-To:       [email protected]
To:     [email protected]



Hi,

Your PDF is made from a low resolution scan, or from a hires image that was reduced poorly. It looks bad even with Adobe Reader. The size of the image within the PDF is 842 x 595. A good scan (300dpi) is 3508 x 2480 pixels.

Tilman





Am 20.09.2017 um 17:42 schrieb [email protected]:
Hi

The link to my pdf is:

http://www116.zippyshare.com/v/WdY6AYy7/file.html

Regards

Gerry


On 20.09.2017 17:27, Tilman Hausherr wrote:
Hi,

http://filedropper.com/

Tilman

PS: please keep it on list. This is a recent flaw in thunderbird, get the "reply to list" icon.

Am 20.09.2017 um 17:22 schrieb [email protected]:
Hi Tilman

Thanks for your quick reply.

Could you please give me the name of a Sharehoster you like to use and I will post a pdf on there.

Thanks

Gerry


On 19.09.2017 18:11, Tilman Hausherr wrote:
Hi,
Please try again with 2.0.7. If it doesn't work as wished, please upload the PDF to a sharehoster.
Tilman

Am 19.09.2017 um 17:44 schrieb Gerry:
Hi

I am using pdfbox-app-2.0.0 in my program.

I am using the following code:

public JPanel makeDocument() throws IOException, FileNotFoundException{

        File target = new File(filePath);

        PDDocument pddocument = PDDocument.load(target);

         JPanel displayView;

          PDFRenderer pdfrend = new PDFRenderer(pddocument);


            for (int i = 0; i < pddocument.getNumberOfPages(); i ++){

                //BufferedImage pageImage = pdfrend.renderImage(i,0.9f);                 BufferedImage pageImage = pdfrend.renderImageWithDPI(i,300);

                this.docList.add(pageImage);
            }



            displayProcessing = new DisplayDocs2(this.docList);

            displayView = displayProcessing.getPanel();

          pddocument.close();

        return displayView;

    }

when I use this code to open a computer produced pdf (with a white background) it works fine.

But when I try to open a pdf which was a scanned page it come out pixelated and pretty much unreadable like grey instead of white background has an effect.

Any help gratefully received. Sorry for my bad descriptive skills I am learning as I go.

Gerry



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]





---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]





Reply via email to