We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
try (Browser browser = Puppeteer.launch(launchOptions)) { //创建一个浏览器页面 com.ruiyun.jvppeteer.api.core.Page page = browser.newPage(); //设置内容 page.setContent(html); //设置页面标题 page.evaluate("document.title = '" + fileName + "';"); PDFOptions pdfOptions = new PDFOptions(); //设置pdf保存路径 pdfOptions.setPath(filePath); //A4大小 pdfOptions.setFormat(PaperFormats.a4); pdfOptions.setPrintBackground(true); pdfOptions.setPreferCSSPageSize(false); //缩放比例 pdfOptions.setScale(0.7); //设置页边距 PDFMargin margin = new PDFMargin(); margin.setTop("0.8cm"); margin.setBottom("0.8cm"); margin.setLeft("0.8cm"); margin.setRight("0.8cm"); pdfOptions.setMargin(margin); page.pdf(pdfOptions); } catch (Exception e) { log.error("pdf生成失败,参数:{};===原因:{}", param, e.getMessage(), e); }
`
<dependency> <groupId>io.github.fanyong920</groupId> <artifactId>jvppeteer</artifactId> <version>3.1.5</version> </dependency>
com.ruiyun.jvppeteer.exception.ProtocolException: Protocol error (method:Runtime.callFunctionOn): Target closed 前几天没事的,今天出现的几率非常大,跟今天装了360有关吗?但是把360退了卸载了还是没恢复
com.ruiyun.jvppeteer.exception.ProtocolException: Protocol error (method:Runtime.callFunctionOn): Target closed
The text was updated successfully, but these errors were encountered:
这是launchOptions 的配置 public final LaunchOptions launchOptions = LaunchOptions.builder() //指定使用的Chrome的位置 .executablePath("D:\\ChromeForTesting\\chrome.exe") //指定使用 Chrome 浏览器 .product(Product.Chrome) //pdf必须配置headless = true .headless(true) //pdf必须添加这个参数,不然无法打印,具体看这里https://github.com/puppeteer/puppeteer/issues/12470 .args(Collections.singletonList("--no-sandbox")) .build();
Sorry, something went wrong.
可能是页面关闭了。 你把try-resource,改成手动调用browser.close(), 然后page对象监听console事件,close事件,看看发生了什么
破案了,就是360的问题,卸载没卸干净,卸干净了就不报那个错了
可能是页面关闭了。 你把try-resource,改成手动调用browser.close(), 然后page对象监听console事件,close事件,看看发生了什么
问题是,本地也有360,就没这个问题,为什么服务器上就不行
奇妙的问题很多,想不通呢
No branches or pull requests
`
`
com.ruiyun.jvppeteer.exception.ProtocolException: Protocol error (method:Runtime.callFunctionOn): Target closed
前几天没事的,今天出现的几率非常大,跟今天装了360有关吗?但是把360退了卸载了还是没恢复
The text was updated successfully, but these errors were encountered: