相关疑难解决方法(0)

Javascript仅打印iframe内容

这是我的代码

<script>
var body = "dddddd"    
var script = "<script>window.print();</scr'+'ipt>";

var newWin = $("#printf")[0].contentWindow.document; 
newWin.open();
newWin.close();

$("body",newWin).append(body+script);

</script>
<iframe id="printf"></iframe>
Run Code Online (Sandbox Code Playgroud)

这可以,但它打印父页面,我如何让它只打印iframe?

javascript printing jquery

58
推荐指数
6
解决办法
18万
查看次数

如何使用JavaScript将pdf文件直接发送到打印机?

如何使用JavaScript将PDF文件直接发送到打印机?

我在论坛中找到了两个答案:

<embed src="vehinvc.pdf" id = "Pdf1" name="Pdf1" hidden>
<a onClick="document.getElementById('Pdf1').printWithDialog()" style="cursor:hand;">Print file</a>
Run Code Online (Sandbox Code Playgroud)

<OBJECT id = "Pdf2" name="Pdf2" CLASSID="clsid:CA8A9780-280D-11CF-A24D-444553540000" WIDTH="364" HEIGHT="290">
     <PARAM NAME='SRC' VALUE="file.pdf">
</OBJECT>
<a onClick="document.Pdf2.printWithDialog()">Print file</a> 
Run Code Online (Sandbox Code Playgroud)

但我的问题是它只适用于IE,并且在Firefox或Chrome中无效.

这有什么解决方案吗?

html javascript printing pdf

33
推荐指数
5
解决办法
12万
查看次数

如何从浏览器打印PDF

在Web应用程序中,是否可以强制在客户端上打印PDF文件?如果浏览器配置为在窗口内打开PDF,我想调用window.print()会起作用,但是某些浏览器(比如我的)被配置为在外部打开PDF.

html javascript pdf

26
推荐指数
2
解决办法
8万
查看次数

Firefox 19从JavaScript打印PDF

我有一个"打印"按钮,可以调用以下JavaScript

window.frames.myPdfFrame.print();
Run Code Online (Sandbox Code Playgroud)

其中"myPdfFrame"指的是带有src的PDF的iframe.

在Chrome和Firefox 18(及以下版本)中,这会按预期打开打印对话框,但从Firefox 19开始,我收到以下错误

Error: Permission denied to access property 'print'
Run Code Online (Sandbox Code Playgroud)

我认为这与使用Firefox 19而不是Adobe插件发布嵌入式PDF查看器有关.使用PDF插件工具栏中的打印图标按预期工作.

有没有办法从Javascript调用Firefox 19中的内联PDF中的打印对话框?

javascript pdf firefox

16
推荐指数
1
解决办法
1万
查看次数

提供PDF下载后自动打开打印机对话框

我目前正在浏览器的新选项卡中打开pdf文件,但我需要知道如何在按下commandButton后打开打印机对话框来打印pdf jasper报告

这是在新选项卡中打开pdf的方法:

public void printJasper() {

    JasperReport compiledTemplate = null;
    JRExporter exporter = null;
    ByteArrayOutputStream out = null;
    ByteArrayInputStream input = null;
    BufferedOutputStream output = null;

    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExternalContext externalContext = facesContext.getExternalContext();
    HttpServletResponse response = (HttpServletResponse) externalContext.getResponse();

    try {

        List<String> sampleList = new ArrayList<String>();
        sampleList.add("Fist sample string");
        sampleList.add("Second sample string");

        JRBeanCollectionDataSource beanCollectionDataSource = new JRBeanCollectionDataSource(sampleList);
        Map<String, Object> reportValues = new HashMap<String, Object>();
        reportValues.put("anyTestValue", "test value");

        facesContext = FacesContext.getCurrentInstance();
        externalContext = facesContext.getExternalContext();
        response = (HttpServletResponse) externalContext.getResponse();

        FileInputStream file …
Run Code Online (Sandbox Code Playgroud)

printing pdf jsf jasper-reports primefaces

5
推荐指数
2
解决办法
1万
查看次数

标签 统计

javascript ×4

pdf ×4

printing ×3

html ×2

firefox ×1

jasper-reports ×1

jquery ×1

jsf ×1

primefaces ×1