Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files from any .NET platform (C#, VB.NET, ASP.NET, .NET Core) and Java applications (J2SE and J2EE) with fast and high quality performance.

Tue Apr 06, 2021 6:27 am

Hi,

We are using the following code to watermark pdf document:

Code: Select all
using (var pdf = new PdfDocument())
{
    pdf.LoadFromFile(file);

    var pdfBrush = settings.GetBrush();
    var firtPage = pdf.Pages[0];
    var brush = new PdfTilingBrush(new SizeF(firtPage.Canvas.ClientSize.Width, firtPage.Canvas.ClientSize.Height));
    brush.Graphics.SetTransparency(settings.Transparency);
    brush.Graphics.Save();

    var transformParams = settings.GetTransformParams(firtPage.Size);
    brush.Graphics.TranslateTransform(transformParams.offsetX, transformParams.offsetY);
    brush.Graphics.RotateTransform(transformParams.rotationAngle);

    brush.Graphics.DrawString(settings.Text,
        new PdfFont(settings.GetFontFamily(), settings.FontSize), pdfBrush, 0, 0,
        new PdfStringFormat(settings.GetTextAlignment()));
    brush.Graphics.Restore();

    foreach (PdfPageBase page in pdf.Pages)
        page.Canvas.DrawRectangle(brush, new RectangleF(new PointF(0, 0), page.Canvas.ClientSize));

    var pf = settings.Permissions;
    var permPassword = Guid.NewGuid().ToString();
    if (!string.IsNullOrWhiteSpace(settings.PasswordForOpening))
        pdf.Security.Encrypt(settings.PasswordForOpening, permPassword, pf, PdfEncryptionKeySize.Key256Bit);
    else
        pdf.Security.Encrypt(permPassword, pf);

    pdf.SaveToFile(tempLocation);
}


Question from a BO - "...a prospect is worried that even though they put a PW on the documents they sent out, there is software (including Adobe Pro) where users can actually remove the watermark."

So what is the best way to protect the document?

Regards,
Velislav

profiler007
 
Posts: 31
Joined: Wed Nov 13, 2019 11:32 am

Tue Apr 06, 2021 9:53 am

Hello,

Thanks for your inquiry.
Kindly note that the open password cannot protect the content of the document from being modified. To achieve your requirement, you need to set the security permission and the permission password, as shown below. Feel free to contact us if you have further issues.
Code: Select all
            PdfDocument pdf = new PdfDocument();
            pdf.LoadFromFile("input.pdf");
            //Allow FullQualityPrint only
            pdf.Security.Encrypt("", "test", PdfPermissionsFlags.FullQualityPrint, PdfEncryptionKeySize.Key256Bit);
            pdf.SaveToFile("output.pdf");


Sincerely
Elena
E-iceblue support team
User avatar

Elena.Zhang
 
Posts: 279
Joined: Thu Jul 23, 2020 1:18 am

Thu Apr 08, 2021 6:45 am

Hello,

Greetings from E-iceblue!
Has the issue been solved now? Could you please give us some feedback at your convenience?

Sincerely,
Andy
E-iceblue support team
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 73
Joined: Mon Mar 29, 2021 3:03 am

Thu Apr 08, 2021 7:29 am

Works for us, thanks!

profiler007
 
Posts: 31
Joined: Wed Nov 13, 2019 11:32 am

Thu Apr 08, 2021 8:14 am

profiler007 wrote:Works for us, thanks!


Hello,
Glad to hear that the issue has been solved.

If you encounter any issues related to our product in the future, just feel free to contact us.
Have a nice day!

Sincerely,
Andy
E-iceblue support team
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 73
Joined: Mon Mar 29, 2021 3:03 am

Return to Spire.Doc

cron