【问题标题】:Node WebKit change print settings in source codeNode WebKit 更改源代码中的打印设置
【发布时间】:2014-02-02 05:17:38
【问题描述】:

所以我有一个使用 node WebKit 构建的应用程序,它创建了一个要打印的图像,但我无法通过使用 CSS 来消除所有边距,所以这是我的 CSS。

<style media="print">
  @page {
    size: 216mm 356mm;
    margin: 0; padding: 0;
    width: 216mm; height: 356mm;
  }

  html, body {
    margin: 0; padding: 0;
    width: 216mm; height: 356mm;
  }

  img {
    display: block;
    width: 100%; height: 100%;
  }
</style>

我已经尝试了各种尺寸、属性和技巧的组合,但输出仍然有很大的边距/填充。因此,由于 Node WebKit 是开源的,我想我应该戴上 C++ 帽子,在更高的层次上做。

我应该编辑 Node Webkit 中的数千个文件中的哪个以保持向前兼容?

【问题讨论】:

    标签: css node.js node-webkit


    【解决方案1】:

    我想通了,在下载了 node-webkit 源代码并构建了几次编辑page-setup.cc::CalculateSizesWithinRect 后,我可以无边距打印了。

    源代码现在改为

    void PageSetup::CalculateSizesWithinRect(const gfx::Rect& bounds, int text_height) {
      effective_margins_.header = 0;
      effective_margins_.footer = 0;
      effective_margins_.left = 0;
      effective_margins_.top = 0;
      effective_margins_.right = 0;
      effective_margins_.bottom = 0;
    

    【讨论】:

    • 您是否在 node-webkit 0.11 或更高版本上尝试过此操作?我在源代码中找不到任何类似的引用或函数。
    • 我没有,你能成功构建吗?
    • 不,我实际上已经放弃了。 :( 感谢您的回复!
    • 在推特上联系我,我会提供更多帮助。 daveymackintosh
    猜你喜欢
    • 1970-01-01
    • 2015-04-29
    • 1970-01-01
    • 2013-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-24
    • 2012-12-12
    相关资源
    最近更新 更多