[jira] [Commented] (PDFBOX-5120) Need to do strange stuff to create my own PageDrawer Parameters

2021-03-07 Thread Daniel Migowski (Jira)


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

Daniel Migowski commented on PDFBOX-5120:
-

Oh... it looks like using PDFRenderer.renderPageToGraphics would allow me 
everything I need. I will investigate this first, thanks.

> Need to do strange stuff to create my own PageDrawer Parameters
> ---
>
> Key: PDFBOX-5120
> URL: https://issues.apache.org/jira/browse/PDFBOX-5120
> Project: PDFBox
>  Issue Type: Bug
>  Components: Rendering
>Reporter: Daniel Migowski
>Priority: Major
>
> Currently using the following function to create my PageDrawer Parameters:
> {{
> private static PageDrawerParameters createPageDrawerParameters(PDPage page) {
> Class clazz = PageDrawerParameters.class;
> Constructor 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 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.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-5120) Need to do strange stuff to create my own PageDrawer Parameters

2021-03-07 Thread Daniel Migowski (Jira)


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

Daniel Migowski commented on PDFBOX-5120:
-

I need them to create the PageDrawer:

// the end-user may provide a custom PageDrawer
PageDrawerParameters parameters = createPageDrawerParameters(page);
PageDrawer drawer = new PageDrawer(parameters);
drawer.drawPage(g, page.getCropBox());

Maybe I abused this a bit, but how else am I supposed to draw just part of the 
page onto a GraphicsContext?

> Need to do strange stuff to create my own PageDrawer Parameters
> ---
>
> Key: PDFBOX-5120
> URL: https://issues.apache.org/jira/browse/PDFBOX-5120
> Project: PDFBox
>  Issue Type: Bug
>  Components: Rendering
>Reporter: Daniel Migowski
>Priority: Major
>
> Currently using the following function to create my PageDrawer Parameters:
> {{
> private static PageDrawerParameters createPageDrawerParameters(PDPage page) {
> Class clazz = PageDrawerParameters.class;
> Constructor 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 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.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-5120) Need to do strange stuff to create my own PageDrawer Parameters

2021-03-07 Thread Tilman Hausherr (Jira)


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

Tilman Hausherr commented on PDFBOX-5120:
-

Is this all about passing your own rendering hints? There is a method 
{{setRenderingHints()}}.

> Need to do strange stuff to create my own PageDrawer Parameters
> ---
>
> Key: PDFBOX-5120
> URL: https://issues.apache.org/jira/browse/PDFBOX-5120
> Project: PDFBox
>  Issue Type: Bug
>  Components: Rendering
>Reporter: Daniel Migowski
>Priority: Major
>
> Currently using the following function to create my PageDrawer Parameters:
> {{
> private static PageDrawerParameters createPageDrawerParameters(PDPage page) {
> Class clazz = PageDrawerParameters.class;
> Constructor 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 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.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org