当前位置: 首页> 财经> 访谈 > 东莞市南城区疫情最新_网页设计常见的布局形式_网推平台_宁夏百度公司

东莞市南城区疫情最新_网页设计常见的布局形式_网推平台_宁夏百度公司

时间:2025/7/11 17:51:43来源:https://blog.csdn.net/qq_25699299/article/details/146034678 浏览次数:0次
东莞市南城区疫情最新_网页设计常见的布局形式_网推平台_宁夏百度公司
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
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 System.Windows.Forms;namespace Watermark
{public partial class Form1 : Form{public Form1(){InitializeComponent();}private void Form1_Load(object sender, EventArgs e){string input = @"C:\Users\Administrator\Desktop\PDF\XXXX.pdf";AddWatermarkToDocument(input, input, "AAAAAAAA");}private void AddWatermarkToDocument(string inputPdf, string outputPdf, string watermarkText){// 打开输入 PDF 文件using (PdfDocument document = PdfReader.Open(inputPdf, PdfDocumentOpenMode.Modify)){foreach (PdfPage page in document.Pages){// 创建XGraphics对象用于绘制内容using (XGraphics canvas = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Append)){// 创建字体(确保系统中有该字体或使用支持嵌入的字体)XFont font = new XFont("Arial", 40, XFontStyleEx.Bold);// 计算水印位置(右下角,带边距)XSize textSize = canvas.MeasureString(watermarkText, font);double margin = 50; // 边距50单位double xPosition = page.Width - textSize.Width - margin;double yPosition = page.Height - textSize.Height - margin;// 设置水印颜色和透明度(使用ARGB)XColor color = XColor.FromArgb(128, 0, 0, 0); // 50%透明度的黑色// 绘制水印文本canvas.DrawString(watermarkText, font, XBrushes.Gray, // 或者使用自定义颜色:new XSolidBrush(color)new XPoint(xPosition, yPosition),XStringFormats.Default);}}// 保存修改后的 PDF 文件document.Save(outputPdf);}}}
}

关键字:东莞市南城区疫情最新_网页设计常见的布局形式_网推平台_宁夏百度公司

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: