PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Jul 19, 2024 5:29 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Feb 23, 2012 6:31 am 
Offline

Joined: Thu Feb 23, 2012 6:19 am
Posts: 2
I am deploying my app via ClickOnce and the document images are not being found at runtime. When debugging the images are displayed properly.

Do I need to calculate a different path?

Code:
        private void CreatePage(Protocol protocol, Document document)
        {
            // Each MigraDoc document needs at least one section.
            Section section = document.AddSection();

            // Put a logo in the header (Images is a folder in the project root)
            Image image = section.Headers.Primary.AddImage("Images/logo.gif");
            image.Height = "1cm";
            image.LockAspectRatio = true;
            ....
        }


Top
 Profile  
Reply with quote  
PostPosted: Thu Feb 23, 2012 8:28 am 
Offline

Joined: Thu Feb 23, 2012 6:19 am
Posts: 2
Here is my work-around:

I put the image in a folder in the startup project. Set BuildAction to Content and CopyAlways. Pass the path 'Image\logo.gif' to my PDF builder class.

In the class

Code:
            // Put a logo in the header
            string file = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, LogoPath);
            //log.Debug("Load image " + file + ", Exists=" + System.IO.File.Exists(file));
            Image image = section.Headers.Primary.AddImage(file);
            image.Height = "1cm";



Perhaps there is a better way but this works.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 45 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