I'm trying to add a watermark to my pdf and i'm using code provided on docs (i can't post urls...):
- Code: Select all
using Spire.Pdf;
using System.Drawing;
namespace ImageWatermark
{
class Program
{
static void Main(string[] args)
{
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile("Sample.pdf");
PdfPageBase page = pdf.Pages[0];
Image img = Image.FromFile("logo.png");
page.BackgroundImage = img;
page.BackgroundRegion = new RectangleF(300, 200, 80, 81);
pdf.SaveToFile("result.pdf");
}
}
}
compiler say that System.Drawing.Image connot be converted to System.IO.Stream
I'm using Spire.PDF v 7.1.10 in a wpf project
I've tried to use
- Code: Select all
Image ebLogo = Image.FromFile(Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Resources/logo.jpg"));
MemoryStream stream = new MemoryStream();
ebLogo.Save(stream, ImageFormat.Jpeg);
page.BackgroundImage = ebLogo;
page.BackgroundRegion = new RectangleF(300, 200, 80, 81);
but at live 4 spirepdf throw a System.NullReferenceException
file path is correct and using breakpoints i can see that also stream is not null
any help is appreciated