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

Need to do strange stuff to create my own PageDrawer Parameters

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Not A Bug
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Rendering
    • Labels:
      None

      Description

      Currently using the following function to create my PageDrawer Parameters:

      {{
      private static PageDrawerParameters createPageDrawerParameters(PDPage page) {
      Class<PageDrawerParameters> clazz = PageDrawerParameters.class;
      Constructor<PageDrawerParameters> c;
      try {
      c = clazz.getDeclaredConstructor(PDFRenderer.class, PDPage.class, boolean.class,
      RenderDestination.class, RenderingHints.class);
      if( !c.isAccessible() )

      { c.setAccessible(true); }

      // TODO: Play with other rendering hints
      Map<Key,Object> hints = new HashMap<>();
      hints.put(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED);
      hints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      hints.put(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_SPEED);
      hints.put(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
      hints.put(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
      hints.put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
      hints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
      hints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
      return c.newInstance(null,page,true,RenderDestination.VIEW,new RenderingHints(hints));
      } catch (Exception e)

      { throw new RuntimeException("Could not instantiate PageDrawerParameters.",e); }

      }
      }}

      Isn't there a better way to achive this? Why isn't the constructor public at all? I need this to create my own PageDrawer because I am writing a PDF Viewer GUI in SWT that uses PDFBox for the rendering and to render I thought it would be nice to be able to use the PageDrawer.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              dmigowski Daniel Migowski
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: