如何实现打印PDF的时候直接调用浏览器的打印插件,而不弹出WebSDK内置的打印选项框?

可以自定义一个“打印”按钮,调用print()接口,以实现您想要的效果。

示例代码如下:

var curDocPageCount;
var Events = UIExtension.PDFViewCtrl.Events;
 
pdfui.eventEmitter.on(Events.renderFileSuccess, pdfDoc => { 
    curDocPageCount = pdfDoc.getPageCount(); 
}); 
   
function diyPrint(){
    var doc_pages = []; 
    for (var i = 0; i < curDocPageCount; i++) { 
        doc_pages.push(i); 
    } 
    pdfui.print({ 
     pages: doc_pages, 
     printType: ['page', 'annot'], 
     quality: 300, 
     showHeaderFooter: false 
    }, function(message) { 
         switch(message.state) { 
             case 'start': 
             console.log('Start generating page images') 
             break; 
             case 'progress': 
             console.log('Page image URI has been generated', message.pageIndex, message.imageURI, message.total) 
             break; 
             case 'end': 
             console.log('Finish generating page images') 
             break; 
         } 
    }) 
}