itext7 new PdfWriter 就出错

onefox onefox 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

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();
        }

 

 

...全文
评论 1
收藏 已收藏
分享
返回顶部
onefox
C# 111,129 成员 642,540 内容