【问题标题】:Is there a way to customize the number of pages being printed on JavaScript / React?有没有办法自定义在 JavaScript / React 上打印的页面数量?
【发布时间】:2023-01-13 01:15:58
【问题描述】:

我目前正在开发一个使用 Chart.js 的 React 应用程序。最近,我在使用 Chrome 时发现了一个新错误:每当我尝试打印包含图表的页面时,都会生成 600 多页额外的空白页。

无论我使用 cmd + print 还是 window.print() 进行打印,都会发生这种情况。

重要的是人们可以在我们的应用程序上打印这些报告。这个问题目前在 Chrome 上发生,但在 Safari 上没有。

有什么方法可以使用 CSS 或 JavaScript 设置打印的页数? 也许@media print 上有一些财产?

对你的帮助表示感谢!

【问题讨论】:

    标签: reactjs google-chrome printing chart.js


    【解决方案1】:

    我进一步调查了这个问题。 v108 Google Chrome 更新为许多用户带来了打印预览问题。

    有一个解决方法涉及应用此 CSS:

      .chartjs-size-monitor-expand > div {
        position: fixed !important; // cannot stay “absolute”
      }
    
      chartjs-size-monitor,
      .chartjs-size-monitor-shrink,
      .chartjs-size-monitor-expand,
      .chartjs-size-monitor-expand > div {
        position: fixed !important; // cannot stay “absolute”
      }
    

    来源:Hundreds of blank pages and/or disproportion when printing a web page, after chrome version ~103 release (solved)

    这解决了我的问题!希望它可以帮助任何需要它的人。

    【讨论】:

      猜你喜欢
      • 2022-12-20
      • 1970-01-01
      • 2013-06-10
      • 1970-01-01
      • 2021-04-03
      • 1970-01-01
      • 2021-04-19
      • 2013-10-10
      • 2016-05-31
      相关资源
      最近更新 更多