Automatically open the printer dialog after providing PDF download

前端 未结 3 1924
灰色年华
灰色年华 2020-11-28 11:38

I am currently opening a pdf file in a new tab in my browser but I need to know how to open a printer dialog to print the pdf jasper report after pressing a commandButton

3条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 12:07

    There is a Primefaces's component for that purpose.

    Something like this might work, not tested though.

    
        
            
        
    
        
    

    Note :

    does have a print button to print the displayed pdf.

    Edit :

    You have to embed the pdf file inside an iframe and use the JavaScript print() function on it, or you can activate the auto-print function in the PDF itself. But it is definitely possible.

    See this question on SO : Can a PDF file's print dialog be opened with Javascript?

    How to Use JavaScript to Print a PDF

提交回复
热议问题