You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Jeremy Young <je...@likezero.co.uk> on 2022/01/12 21:46:12 UTC

Mask is not applied.

The attached pdf is the first page referred to in this link from Gunnar Brand.

https://www.mail-archive.com/users@pdfbox.apache.org/msg11980.html

When I render this page in pdfbox 2.0.24 I get a blank page using code
similar to below, which works for documents which are not using masks.


PDDocument document = PDDocument.load(fileAsByteArray)
PDFRenderer renderer = new PDFRenderer(document);

// configuring renderer for best image
RenderingHints hints = new RenderingHints(null);
hints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
hints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
hints.put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
renderer.setRenderingHints(hints);

// render relevant the pages into memory
BufferedImage bufferedImage = renderer.renderImage(0, 5, ImageType.BINARY);


I have tried with/without the hints and with different scales and image types.

Any ideas what's going wrong here?

Thanks.

-- 


LIKEZERO Limited is a limited company registered in Scotland with 
registered number SC651418. Our registered office is at Quartermile One, 15 
Lauriston Place, Edinburgh, United Kingdom, EH3 9EP

This email is intended 
solely for the addressee and may contain confidential information. If you 
have received this message in error, please immediately and permanently 
delete it. Do not use, copy or disclose the information contained in this 
message or in any attachment.

This email is not in any way intended to 
create a binding contract.

We may monitor and record emails for security 
reasons and for monitoring compliance with internal policies.

Re: Mask is not applied.

Posted by Tilman Hausherr <TH...@t-online.de>.
I can't help on Intelli and on gradle. You need to make sure that the 
jar files are in your class path. (And update pdfbox and log4j!)
Re log4j2, here's the file I use locally:

<?xml version="1.0" encoding="UTF-8"?>
<!-- https://logging.apache.org/log4j/2.x/manual/configuration.html
      https://logging.apache.org/log4j/2.x/manual/appenders.html
-->
<Configuration>
     <Appenders>
         <Console name="STDOUT" target="SYSTEM_OUT">
             <PatternLayout pattern="%d{dd.MM.yyyy HH:mm:ss} %-5p 
%C{2}:%L - %m%n"/>
         </Console>
     </Appenders>
     <Loggers>
         <Root level="info">
             <AppenderRef ref="STDOUT"/>
         </Root>
     </Loggers>
</Configuration>


Tilman

Am 13.01.2022 um 17:55 schrieb Jeremy Young:
> Hi Tilman
>
> The jbig and j2k stuff got removed from the gradle files. Oops! Thanks for
> that.
>
> The next problem is that I get the mask image applied when I run in
> IntellIj in debug mode, but not when run compiled using the same gradle
> settings.
>
> *build.gradle*
> implementation 'org.apache.logging.log4j:log4j-api'
> implementation 'org.apache.pdfbox:pdfbox'
> implementation 'com.github.jai-imageio:jai-imageio-core'
> implementation 'com.github.jai-imageio:jai-imageio-jpeg2000'
> implementation 'org.apache.pdfbox:jbig2-imageio'
> *dependencies-versions.gradle*
> implementation "org.apache.logging.log4j:log4j-api:2.16.0"
> implementation "org.apache.logging.log4j:log4j-core:2.16.0"
> implementation "org.apache.pdfbox:pdfbox:2.0.24"
> implementation "com.github.jai-imageio:jai-imageio-core:1.4.0"
> implementation "com.github.jai-imageio:jai-imageio-jpeg2000:1.4.0"
> implementation "org.apache.pdfbox:jbig2-imageio:3.0.3"
>
> I have tried using runtimeClasspath instead of "implementation" but no
> change.
>
> I would like to set up the logging, but I do not understand from the
> documentation how to do that. The module that instantiates the pdfBox
> objects has the following log4j config:
> <?xml version="1.0" encoding="UTF-8"?>
>
> <Configuration status="warn" xmlns:xi="http://www.w3.org/2001/XInclude" >
>
> <xi:include href="xincludes/log4j2-patterns.xml"/>
>
>
> <Appenders>
>
> <xi:include href="xincludes/log4j2-appender-console.xml"/>
>
> <xi:include href="xincludes/log4j2-appender-file.xml"/>
>
> </Appenders>
>
>
> <Loggers>
>
> <Root level="debug">
>
> <AppenderRef ref="Console" level="debug" />
>
> <AppenderRef ref="File" level="debug" />
>
> </Root>
>
> </Loggers>
>
> </Configuration>
>
> I get logging from our code but not from pdfBox, although when tracing I
> can see that it is logging somewhere ...
>
> Could you give me some advice?
>
> Thanks again.
> Jeremy
>
> On Thu, Jan 13, 2022 at 3:45 AM Tilman Hausherr <TH...@t-online.de>
> wrote:
>
>> Are the JBIG2 and JPX plugins in your classpaths? Did you see any log
>> messages? Did you activate logging?
>>
>> Tilman
>>
>> Am 12.01.2022 um 22:46 schrieb Jeremy Young:
>>> The attached pdf is the first page referred to in this link from Gunnar
>> Brand.
>>> https://www.mail-archive.com/users@pdfbox.apache.org/msg11980.html
>>> When I render this page in pdfbox 2.0.24 I get a blank page using code
>> similar to below, which works for documents which are not using masks.
>>> PDDocument document = PDDocument.load(fileAsByteArray)
>>> PDFRenderer renderer =new PDFRenderer(document);
>>>
>>> // configuring renderer for best image RenderingHints hints =new
>> RenderingHints(null);
>>> hints.put(RenderingHints.KEY_RENDERING,
>> RenderingHints.VALUE_RENDER_SPEED);
>>> hints.put(RenderingHints.KEY_ANTIALIASING,
>> RenderingHints.VALUE_ANTIALIAS_OFF);
>>> hints.put(RenderingHints.KEY_STROKE_CONTROL,
>> RenderingHints.VALUE_STROKE_PURE);
>>> renderer.setRenderingHints(hints);
>>>
>>> // render relevant the pages into memory BufferedImage bufferedImage =
>> renderer.renderImage(0,5, ImageType.BINARY);
>>> I have tried with/without the hints and with different scales and image
>> types.
>>> Any ideas what's going wrong here?
>>> Thanks.
>>>
>>> LIKEZERO Limited is a limited company registered in Scotland with
>>> registered number SC651418. Our registered office is at Quartermile
>>> One, 15 Lauriston Place, Edinburgh, United Kingdom, EH3 9EP
>>>
>>> This email is intended solely for the addressee and may contain
>>> confidential information. If you have received this message in error,
>>> please immediately and permanently delete it. Do not use, copy or
>>> disclose the information contained in this message or in any attachment.
>>>
>>> This email is not in any way intended to create a binding contract.
>>>
>>> We may monitor and record emails for security reasons and for
>>> monitoring compliance with internal policies.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail:users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail:users-help@pdfbox.apache.org
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Mask is not applied.

Posted by Jeremy Young <je...@likezero.co.uk>.
Hi Tilman

The jbig and j2k stuff got removed from the gradle files. Oops! Thanks for
that.

The next problem is that I get the mask image applied when I run in
IntellIj in debug mode, but not when run compiled using the same gradle
settings.

*build.gradle*
implementation 'org.apache.logging.log4j:log4j-api'
implementation 'org.apache.pdfbox:pdfbox'
implementation 'com.github.jai-imageio:jai-imageio-core'
implementation 'com.github.jai-imageio:jai-imageio-jpeg2000'
implementation 'org.apache.pdfbox:jbig2-imageio'
*dependencies-versions.gradle*
implementation "org.apache.logging.log4j:log4j-api:2.16.0"
implementation "org.apache.logging.log4j:log4j-core:2.16.0"
implementation "org.apache.pdfbox:pdfbox:2.0.24"
implementation "com.github.jai-imageio:jai-imageio-core:1.4.0"
implementation "com.github.jai-imageio:jai-imageio-jpeg2000:1.4.0"
implementation "org.apache.pdfbox:jbig2-imageio:3.0.3"

I have tried using runtimeClasspath instead of "implementation" but no
change.

I would like to set up the logging, but I do not understand from the
documentation how to do that. The module that instantiates the pdfBox
objects has the following log4j config:
<?xml version="1.0" encoding="UTF-8"?>

<Configuration status="warn" xmlns:xi="http://www.w3.org/2001/XInclude" >

<xi:include href="xincludes/log4j2-patterns.xml"/>


<Appenders>

<xi:include href="xincludes/log4j2-appender-console.xml"/>

<xi:include href="xincludes/log4j2-appender-file.xml"/>

</Appenders>


<Loggers>

<Root level="debug">

<AppenderRef ref="Console" level="debug" />

<AppenderRef ref="File" level="debug" />

</Root>

</Loggers>

</Configuration>

I get logging from our code but not from pdfBox, although when tracing I
can see that it is logging somewhere ...

Could you give me some advice?

Thanks again.
Jeremy

On Thu, Jan 13, 2022 at 3:45 AM Tilman Hausherr <TH...@t-online.de>
wrote:

> Are the JBIG2 and JPX plugins in your classpaths? Did you see any log
> messages? Did you activate logging?
>
> Tilman
>
> Am 12.01.2022 um 22:46 schrieb Jeremy Young:
> > The attached pdf is the first page referred to in this link from Gunnar
> Brand.
> > https://www.mail-archive.com/users@pdfbox.apache.org/msg11980.html
> > When I render this page in pdfbox 2.0.24 I get a blank page using code
> similar to below, which works for documents which are not using masks.
> > PDDocument document = PDDocument.load(fileAsByteArray)
> > PDFRenderer renderer =new PDFRenderer(document);
> >
> > // configuring renderer for best image RenderingHints hints =new
> RenderingHints(null);
> > hints.put(RenderingHints.KEY_RENDERING,
> RenderingHints.VALUE_RENDER_SPEED);
> > hints.put(RenderingHints.KEY_ANTIALIASING,
> RenderingHints.VALUE_ANTIALIAS_OFF);
> > hints.put(RenderingHints.KEY_STROKE_CONTROL,
> RenderingHints.VALUE_STROKE_PURE);
> > renderer.setRenderingHints(hints);
> >
> > // render relevant the pages into memory BufferedImage bufferedImage =
> renderer.renderImage(0,5, ImageType.BINARY);
> > I have tried with/without the hints and with different scales and image
> types.
> > Any ideas what's going wrong here?
> > Thanks.
> >
> > LIKEZERO Limited is a limited company registered in Scotland with
> > registered number SC651418. Our registered office is at Quartermile
> > One, 15 Lauriston Place, Edinburgh, United Kingdom, EH3 9EP
> >
> > This email is intended solely for the addressee and may contain
> > confidential information. If you have received this message in error,
> > please immediately and permanently delete it. Do not use, copy or
> > disclose the information contained in this message or in any attachment.
> >
> > This email is not in any way intended to create a binding contract.
> >
> > We may monitor and record emails for security reasons and for
> > monitoring compliance with internal policies.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail:users-unsubscribe@pdfbox.apache.org
> > For additional commands, e-mail:users-help@pdfbox.apache.org
>
>

-- 


LIKEZERO Limited is a limited company registered in Scotland with 
registered number SC651418. Our registered office is at Quartermile One, 15 
Lauriston Place, Edinburgh, United Kingdom, EH3 9EP

This email is intended 
solely for the addressee and may contain confidential information. If you 
have received this message in error, please immediately and permanently 
delete it. Do not use, copy or disclose the information contained in this 
message or in any attachment.

This email is not in any way intended to 
create a binding contract.

We may monitor and record emails for security 
reasons and for monitoring compliance with internal policies.

Re: Mask is not applied.

Posted by Tilman Hausherr <TH...@t-online.de>.
Are the JBIG2 and JPX plugins in your classpaths? Did you see any log 
messages? Did you activate logging?

Tilman

Am 12.01.2022 um 22:46 schrieb Jeremy Young:
> The attached pdf is the first page referred to in this link from Gunnar Brand.
> https://www.mail-archive.com/users@pdfbox.apache.org/msg11980.html
> When I render this page in pdfbox 2.0.24 I get a blank page using code similar to below, which works for documents which are not using masks.
> PDDocument document = PDDocument.load(fileAsByteArray)
> PDFRenderer renderer =new PDFRenderer(document);
>
> // configuring renderer for best image RenderingHints hints =new RenderingHints(null);
> hints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
> hints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
> hints.put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
> renderer.setRenderingHints(hints);
>
> // render relevant the pages into memory BufferedImage bufferedImage = renderer.renderImage(0,5, ImageType.BINARY);
> I have tried with/without the hints and with different scales and image types.
> Any ideas what's going wrong here?
> Thanks.
>
> LIKEZERO Limited is a limited company registered in Scotland with 
> registered number SC651418. Our registered office is at Quartermile 
> One, 15 Lauriston Place, Edinburgh, United Kingdom, EH3 9EP
>
> This email is intended solely for the addressee and may contain 
> confidential information. If you have received this message in error, 
> please immediately and permanently delete it. Do not use, copy or 
> disclose the information contained in this message or in any attachment.
>
> This email is not in any way intended to create a binding contract.
>
> We may monitor and record emails for security reasons and for 
> monitoring compliance with internal policies.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail:users-help@pdfbox.apache.org