Spire.PDF for.NET 去水印方法 及用法示例

使用Spire.PDF for.NET的时候,会出现Evaluation Warning : The document was created with Spire.PDF for .NET. 水印。
在这里插入图片描述

如果需求是不到10页的pdf,可以使用官方免费版本,没有水印。
官方免费版本下载地址:
https://u20002878.pipipan.com/fs/20002878-372752254

在这里插入图片描述
另外附上这个dll的一些代码作为参考:
(以下代码参考自:https://www.cnblogs.com/Yesi/p/9844042.html 但稍作修改并非完全相同)

using System;
using System.Drawing;
using System.Windows.Forms;
using Spire.Pdf;
using Spire.Pdf.Graphics;
using Spire.Pdf.Annotations;

namespace GetPDF
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void CreatPDF(string url,string name)
        {
            float x = 50;
            float y = 50;
            string hang1 = "测试文字1";
            string hang2 = "测试文字2";
            string hang3 = "测试文字3";
            PdfDocument pdf = new PdfDocument();//新建一个pdf
            PdfPageBase page = pdf.Pages.Add();//新建pdf的一页
            PdfTrueTypeFont font1 = new PdfTrueTypeFont(new Font("Arial Unicode MS", 30f, FontStyle.Regular), true);//创建一个pdf的字体
            page.Canvas.DrawString(hang1, font1, PdfBrushes.Black, new PointF(x, y)); y += 50;
            page.Canvas.DrawString(hang2, font1, PdfBrushes.Black, new PointF(x, y)); y += 50;
            page.Canvas.DrawString(hang3, font1, PdfBrushes.Black, new PointF(x, y)); y += 50;
           // PdfStringFormat format = new PdfStringFormat();
           // format.MeasureTrailingSpaces = true;
            x += font1.MeasureString(str, format).Width;

            //超链接
            PdfTrueTypeFont font2 = new PdfTrueTypeFont(new Font("Arial Unicode MS", 30f, FontStyle.Underline), true);
            PdfTextWebLink webLink = new PdfTextWebLink();
            webLink.Url = url;
            webLink.Text = url;
            webLink.Font = font2;
            webLink.Brush = PdfBrushes.Blue;
            webLink.DrawTextWebLink(page.Canvas, new PointF(x, y));
            pdf.SaveToFile(name + ".pdf");创建pdf
        }

        private void button1_Click(object sender, EventArgs e)
        {
            CreatPDF(textBox2.Text, textBox1.Text);
        }
    }
}
  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值