Flutter PDF pdfGraphics.drawLine 在某些 PDF 查看器和打印时不显示

Flutter PDF pdfGraphics.drawLine not showing on some PDF viewers and when printed

提问人:sirbird phoenix 提问时间:10/17/2023 最后编辑:sirbird phoenix 更新时间:10/17/2023 访问量:22

问:

我正在制作一个 Flutter 应用程序,使用 pdf 包生成 PDF,该应用程序可以使用 pw 生成形状。CustomPaint,它会显示在 Google Chrome 的 PDF 查看器和 Acrobat 上,但不会显示在 PDF 点睛上。另外,当我尝试打印它时,pw生成的行。CustomPaint 未出现,可能是由于太薄。

generateBarredArea(int totalWidth, int width, int height, int sectionNumber) {
print("generate Barred Area");
print(
    "totalWidth: $totalWidth width: $width height: $height sectionNumber: $sectionNumber");

return pw.Container(
  width: width.toDouble(),
  height: height.toDouble(),
  child: pw.CustomPaint(
    size: PdfPoint(width.toDouble(), height.toDouble()),
    painter: (PdfGraphics canvas, PdfPoint size) {
      int x = width;

      for (int i = sectionNumber;
          i > 0;
          i--, x -= (totalWidth / sectionNumber).toInt()) {
        if (x > 0) {
          canvas.drawLine(x.toDouble(), 0, x.toDouble(), height.toDouble());
        }
      }

      canvas.setColor(PdfColors.black);
      canvas.setLineWidth(10.0);
      canvas.fillPath();
    },
  ),
);

}

我尝试更改canvas.setColor和canvas.setLineWidth,但它们不起作用。如何更改线条的粗细?请帮帮我!

Flutter PDF 打印 线

评论


答: 暂无答案