小编Jac*_*cob的帖子

PDFsharp水印

我正在创建一个应用程序,在用户选择的PDF上创建水印,我似乎无法在所选PDF上显示水印,但我也没有错误.任何帮助,将不胜感激.

我使用的是PDFsharp版本1.50.4000

public void WaterMarkPDF(string sourceFileName)
    {
        try
        {
            string watermark = "watermark";
            int emSize = 100;
            string file ="test.pdf";

            File.Copy(sourceFileName, file, true);
            File.SetAttributes(file, File.GetAttributes(file) & ~FileAttributes.ReadOnly);

            // Take in pdf from the form
            PdfDocument document = PdfReader.Open(file);

            // change the version cause sometimes newer versions break it
            if (document.Version < 14)
                document.Version = 14;

            XFont font = new XFont("Times New Roman", emSize, XFontStyle.BoldItalic);
            for (int idx = 0; idx < document.Pages.Count; idx++)
            {
                var page = document.Pages[idx];

                // Get …
Run Code Online (Sandbox Code Playgroud)

c# pdfsharp

5
推荐指数
1
解决办法
2067
查看次数

标签 统计

c# ×1

pdfsharp ×1