PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Image not found
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1915
Page 1 of 1

Author:  galastur [ Mon Feb 20, 2012 1:18 pm ]
Post subject:  Image not found

Hi All,

I have just started playing with PDFsharp & MigraDoc and I have a problem referencing an image. This is a wpf project, and I have a folder "Images" under the root directory. Inside the Images folder I have a picture "mypic.jpg", with it is build action set to "Content", and the copy to output directory "copy always"

Root
___Images (folder)
______mypic.jpg
___Window1.xaml

This is the code:

Code:
 static void CreateHeader()
        {
            // Put a logo in the header
            Image image = section.Headers.Primary.AddImage("../Images/mypic.jpg");
            image.Height = "0.5cm";
            image.LockAspectRatio = true;
            image.RelativeVertical = RelativeVertical.Line;
            image.RelativeHorizontal = RelativeHorizontal.Margin;
            image.Top = ShapePosition.Top;
            image.Left = ShapePosition.Right;
            image.WrapFormat.Style = WrapStyle.Through;
        }


Any help will be greatly appreciate it.

Thanks

Author:  galastur [ Mon Feb 20, 2012 1:23 pm ]
Post subject:  Re: Image not found

Found the right way to reference it:

Image image = section.Headers.Primary.AddImage("Images/mypic.jpg");

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/