itext7 new PdfWriter 就出错

onefox 2023-05-14 19:59:36

VS2022 导入了itext7

测试 HelloWorld 失败……

实际文件夹里是创建了pdf文件,但是内容是空的。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using iText;
using System.Windows.Forms;
using iText.Kernel.Geom;
using iText.Kernel.Pdf.Canvas;
using iText.Kernel.Pdf.Xobject;
using iText.Kernel.Pdf;
using System.Security.Cryptography;
using Rectangle = iText.Kernel.Geom.Rectangle;
using iText.Layout.Element;
using iText.Layout.Properties;
using iText.Layout;

//点击按钮创建PDF
        private void button3_Click(object sender, EventArgs e)
        {
            PdfWriter writer = new PdfWriter("D:/hellowprld.pdf");
            PdfDocument pdf = new PdfDocument(writer);
            Document document = new Document(pdf);
            document.Add(new Paragraph("Hello World!"));
            document.Close();
        }

 

 

...全文
86 回复 打赏 收藏 转发到动态 举报
写回复
回复
切换为时间正序
请发表友善的回复…
发表回复
相关推荐

109,345

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者