[
https://issues.apache.org/jira/browse/PDFBOX-3100?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15002548#comment-15002548
]
John Hewson edited comment on PDFBOX-3100 at 11/12/15 6:11 PM:
---------------------------------------------------------------
This is by design. PDFRenderer is the entry point for all rendering. You can
supply a custom PageDrawer but you can't create one which is independent of a
PDFRenderer. Note that PageDrawerParameters maintains a field which references
its parent PDFRenderer, so it's not possible to create one without the other.
You could subclass PDFRenderer and PageDrawer then override PageDrawer#drawPage
to override the graphics and box, that way you could reset the graphics and use
the media box. See our CustomPageDrawer example for guidance.
One other thing to bare in mind is that content is cropped to the crop box, so
the area between the crop box and the media box will always be empty. You could
render as usual using PDFRenderer and then draw the resulting image onto a new
image which is the size of the media box.
Alternatively you could call renderPageToGraphics with a Graphics which
corresponds to a device which is already the size of the media box, then the
content will be drawn into that. (You might need a translation to account for
the crop box position).
was (Author: jahewson):
This is by design. PDFRenderer is the entry point for all rendering. You can
supply a custom PageDrawer but you can't create one which is independent of a
PDFRenderer. Note that PageDrawerParameters maintains a field which references
its parent PDFRenderer, so it's not possible to create one without the other.
You could subclass PDFRenderer and PageDrawer then override PageDrawer#drawPage
to override the graphics and box, that way you could reset the graphics and use
the media box. See our CustomPageDrawer example for guidance.
One other thing to bare in mind is that content is cropped to the crop box, so
the area between the crop box and the media box will always be empty. You could
render as usual using PDFRenderer and then draw the resulting image onto a new
image which is the size of the media box.
> Allow flexible calling of PageDrawer
> ------------------------------------
>
> Key: PDFBOX-3100
> URL: https://issues.apache.org/jira/browse/PDFBOX-3100
> Project: PDFBox
> Issue Type: Bug
> Components: Rendering
> Affects Versions: 2.0.0
> Reporter: simon steiner
> Attachments: newpdfbox.patch
>
>
> You used to be able to do:
> PageDrawer drawer = new PageDrawer(null);
> drawer.drawPage(g2d, page, mediaBox);
> Now you have to do:
> new PDFRenderer(doc).renderPageToGraphics(1, g2d);
> I don't want to use pdfbox PDFRenderer.renderPage impl, due to my custom
> renderer.
> I cant do as PageDrawerParameters has private constructor:
> PageDrawerParameters parameters = new
> PageDrawerParameters(new PDFRenderer(pdDocument), page);
> PageDrawer drawer = new PageDrawer(parameters);
> drawer.drawPage(g2d, mediaBox);
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]