You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "John Hewson (JIRA)" <ji...@apache.org> on 2014/10/24 08:45:34 UTC

[jira] [Commented] (PDFBOX-2450) RenderingHints of PageDrawer should be customizable

    [ https://issues.apache.org/jira/browse/PDFBOX-2450?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14182500#comment-14182500 ] 

John Hewson commented on PDFBOX-2450:
-------------------------------------

It's not clear where the problem is, are you saying that setting the anti-alias hint to on causes issues with the dot matrix printer driver? If the driver doesn't support anti-aliasing then it should ignore the hint.

Could you attach a sample PDF? (More > Attach Files). If I can examine how the barcodes are embedded then it might be more clear what the best solution is.

> RenderingHints of PageDrawer should be customizable
> ---------------------------------------------------
>
>                 Key: PDFBOX-2450
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-2450
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: Rendering
>    Affects Versions: 2.0.0
>            Reporter: Pei-Tang Huang
>            Priority: Minor
>              Labels: PageDrawer, RenderingHints,
>
> RenderingHints defaults are hard-coded in [PageDrawer|https://github.com/apache/pdfbox/blob/54037862e4c55ab45eb8aecc44b79afbfbcd8dd9/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java#L143-L151] 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:
> {code:java}
> @Override
> public void renderPageToGraphics(int pageIndex, Graphics2D graphics, float scale)
>         throws IOException {
>     Graphics2D hintsAppliedGraphics = new HintsAppliedGraphics2D(graphics, hints);
>     super.renderPageToGraphics(pageIndex, hintsAppliedGraphics, scale);
> }
> {code}
> Where the HintsPredefinedGraphics2D is a proxy to the original Graphics2D, applying the given {{RenderingHints}} immediately and will suppress all subsequent {{setRenderingHints}} / {{setRenderingHint}} request from {{PageDrawer}}.
> I will be appreciated if there is a more elegant way to specify {{RenderHint}} s.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)