Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-2450

RenderingHints of PageDrawer should be customizable

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Not A Problem
    • Affects Version/s: 2.0.0
    • Fix Version/s: None
    • Component/s: Rendering

      Description

      RenderingHints defaults are hard-coded in PageDrawer now.

      However, the defaults are not always valid for every situation. For example, I have a PDF file containing barcodes, which will be printed out using a low resolution dot matrix printer. The RenderingHints.VALUE_ANTIALIAS_ON default confuses all of our barcode reader!

      A dirty workaround I had is to extend PDFPrinter, use reflection to set the protected but final super.renderer field with following extension:

      @Override
      public void renderPageToGraphics(int pageIndex, Graphics2D graphics, float scale) throws IOException {
          // proxy graphics, applying hints immediately, suppress all subsequent setRenderingHint request
          Graphics2D hintsAppliedGraphics = new HintsAppliedGraphics2D(graphics, hints);
      
          super.renderPageToGraphics(pageIndex, hintsAppliedGraphics, scale);
      }
      

      It will be nice if there exist a more elegant way to specify RenderHint s.

        Attachments

        1. dot_matrix_output.jpg
          642 kB
          Pei-Tang Huang
        2. 300dpi_aa_8x.png
          16 kB
          Pei-Tang Huang
        3. 300dpi_noaa_8x.png
          9 kB
          Pei-Tang Huang
        4. test.pdf
          63 kB
          Pei-Tang Huang

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                tan9 Pei-Tang Huang
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: