【问题标题】:How to create a custom page width using the Dart PDF package?如何使用 Dart PDF 包创建自定义页面宽度?
【发布时间】:2019-11-09 06:50:40
【问题描述】:

我使用 Flutter 包 pdf 1.3.24 here 创建了一个 PDF 文件,但我不知道如何创建具有自定义页面宽度的文档。该文件是一张收据,将在热敏打印机上打印。

这是我设置页面格式的方法:

pdf.addPage(MultiPage(

    pageFormat: PdfPageFormat.standard.copyWith(marginBottom: 1.5 * PdfPageFormat.cm),

      crossAxisAlignment: CrossAxisAlignment.start,

      header: (Context context) {
...

PdfPageFormat 仅接受一系列预定义的页面尺寸,其中不包括 80 毫米卷筒热敏打印机和连续页面长度。

【问题讨论】:

    标签: flutter dart pdf-generation


    【解决方案1】:
      pageFormat: PdfPageFormat(8 * PdfPageFormat.cm, 20 * PdfPageFormat.cm, marginAll: 0.5 * PdfPageFormat.cm),
    

    会给你一个 8x20 厘米的页面,页边距为 5 毫米

    【讨论】:

    • 可变页长(例如热敏打印机收据)呢?
    • 目前还没有,您的回答是一个巨大的进步。
    猜你喜欢
    • 2020-08-30
    • 1970-01-01
    • 2012-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-25
    • 2012-02-28
    • 1970-01-01
    相关资源
    最近更新 更多