I have a Jasper Report which creates a PDF in Java Spring. I have been trying to change the zoom level for hours and have not been successful. Whenever I open the pdf's using Adobe reader, its 149% (and coworkers is even worse). There was a similar question which did not help.
I have tried the following property names and none of them have worked
- "zoom"
- "net.sf.jasperreports.viewer.zoom"
- "net.sf.jasperreports.viewer.zoom"
- com.jaspersoft.studio.viewer.zoom
- com.jaspersoft.studio.unit.viewer.zoom
The values I have tried are
- 0.5
- 1.1
- 2
I have checked my Adobe Reader properties and zoom is set to default, and accessibility is also off.
As Villat indicated in comment one way to set zoom level is "
this.zoom=50;
"You can do this either by indicating it in jrxml
or
by setting it to the
SimplePdfExporterConfiguration
if exporting from javaHowever
It is up to the reader (application used to open pdf), to decide if it will/can execute the javascript.
For example in standard Adobe Acrobat Reader DC a user can manually turn this off under menu Edit>>Preferences
Furthermore, if the reader is already open it seems to not always like to change the zoom level through javascript, my installed reader works properly only if it opens with the pdf.
Alternative solution
If you are exporting in java you can post elaborate the pdf adding a OpenAction, see Bruno Lowagie's answer https://stackoverflow.com/a/24095098/5292302
Hence once exported, you call a similar method, if memory allows it you can also do this in memory using a
ByteArrayOutputStream
or similar.This solution is more reliable, but in the the end it's always up to to the reader that user is using if it will be respected or not.