PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Mon Sep 20, 2021 1:31 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Fri Aug 13, 2021 12:21 pm 
Offline

Joined: Thu Aug 12, 2021 11:33 am
Posts: 1
Hello,
I have a problem with adding watermarks to some PDF's. While the code below adds them correctly, the whole page becomes black after it.
The links for both the source and the result files are below. Please advise on this bug.

https://www.dropbox.com/s/ol8pju00n751k ... e.pdf?dl=0
https://www.dropbox.com/s/4t2zkn9fst81m ... n.pdf?dl=0

Code:
public class PdfMaker
    {
        public void CopyPdf(string source, string destination)
        {
            var bytes = File.ReadAllBytes(source);
            bytes = AddWatermarksToPdf(bytes);
            File.WriteAllBytes(destination, bytes);
        }

        private byte[] AddWatermarksToPdf(byte[] pdfBytes)
        {
            var pdf = new PdfWrapper(pdfBytes);

            var watermarkText = "Hello, World!";

            var watermarks = new[]
            {
                new PdfWatermark
                {
                    Text = watermarkText,
                    Coordinates = new Point(25, 100),
                    Angle = 90,
                    BrushColor = Color.Black,
                    Font = new Font("Arial", 4, FontStyle.Regular, GraphicsUnit.World)
                },
                new PdfWatermark
                {
                    Text = watermarkText,
                    Coordinates = new Point(5, 200),
                    Angle = 90,
                    BrushColor = Color.White,
                    Font = new Font("Arial", 1, FontStyle.Regular, GraphicsUnit.World)
                }
            };

            pdf.AddWaterMark(watermarks);

            return pdf.ToArray();
        }
    }


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group