如何更改Adobe Reader的缩放级别? [英] How to change adobe readers zoom level?

查看:194
本文介绍了如何更改Adobe Reader的缩放级别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Jasper报告,可以在Java Spring中创建PDF.我一直在尝试将缩放级别更改几个小时,但没有成功.每当我使用Adobe Reader打开pdf时,它的149%(甚至更糟糕).有一个类似的问题没有帮助.

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

我尝试过的值是

  • 0.5
  • 1.1
  • 2

我已经检查了我的Adobe Reader属性,并且缩放设置为默认值,并且可访问性也已关闭.

I have checked my Adobe Reader properties and zoom is set to default, and accessibility is also off.

推荐答案

别墅 https://stackoverflow.com/questions/58243442/jasperreport-and-pdf-default-zoom#comment102859833_58243442>评论设置缩放级别的一种方法是"this.zoom=50;"

As Villat indicated in comment one way to set zoom level is "this.zoom=50;"

您可以通过在jrxml中进行指示来实现

You can do this either by indicating it in jrxml

<property name="net.sf.jasperreports.export.pdf.javascript" value="this.zoom=50;"/>

or

设置为SimplePdfExporterConfiguration

....
SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
configuration.setPdfJavaScript("this.zoom=50;");
exporter.setConfiguration(configuration);

但是

由读者(用于打开pdf的应用程序)决定是否/可以执行javascript.

However

It is up to the reader (application used to open pdf), to decide if it will/can execute the javascript.

例如,在标准Adobe Acrobat Reader DC中,用户可以在菜单编辑>>首选项"下手动将其关闭

For example in standard Adobe Acrobat Reader DC a user can manually turn this off under menu Edit>>Preferences

此外,如果阅读器已经打开,似乎并不总是希望通过javascript更改缩放级别,那么我安装的阅读器只有在打开pdf时才能正常工作.

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.

如果您使用Java导出,则可以发布带有OpenAction的详细pdf文件,请参见 Bruno Lowagie 回答 https://stackoverflow.com/a/24095098/5292302

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

public void manipulatePdf(String src, String dest) throws IOException, DocumentException {
    PdfReader reader = new PdfReader(src);
    PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest));
    PdfDestination pdfDest = new PdfDestination(PdfDestination.XYZ, 0,
    reader.getPageSize(1).getHeight(), 0.75f);
    PdfAction action = PdfAction.gotoLocalPage(1, pdfDest, stamper.getWriter());
    stamper.getWriter().setOpenAction(action);
    stamper.close();
    reader.close();
}

因此,一旦导出,您将调用类似的方法,如果内存允许,您也可以使用ByteArrayOutputStream或类似方法在内存中执行此操作.

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.

这篇关于如何更改Adobe Reader的缩放级别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆