使用 window.print() 为 Safari 打印

Printing for Safari with window.print()

我正在尝试打印我的 vue-routes 之一。因此 vue-html-to-paper 不能与 Vue3 一起正常工作。使用 print.js,无法以某种方式包含本地 css 文件。

然后我做了以下基本的 css 打印:

// global printing
@media print {
  @page {
    size: A4;
  }

  // hide buttons and non-content
  button,
  aside {
    display: none !important;
  }

  // somehow there are no line-break, so border content
  div {
    max-width: 100vw;
  }

  // footer
  body::after {
    content: url("../assets/printfooter.png");

    // center
    display: flex;
    justify-content: center;
  }
}

正如我在

上所期望的那样,它工作起来既流畅又简单

尝试在 Safari 上打印无效。

有什么提示可以让 Apple 满意或者我可以改进什么吗?

我很确定问题出在@page 规则,我的 Safari 不支持它。查看更多: https://developer.mozilla.org/de/docs/Web/CSS/@page

我最终使用 pdfkit 服务器端创建了 pdf。