PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 7:34 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri Aug 26, 2016 4:33 pm 
Offline

Joined: Thu Aug 18, 2016 9:58 pm
Posts: 2
So I'm using MigraDoc/PdfSharp to create a PDF document. My app is an ASP.NET Webforms project I have a png file that is in a folder that resides in my solution but when I push it to my web server it cannot find the image. The question: What should my path to the image be on the webserver??? I'm launching the document via an .aspx webpage and code looks like:

Code:
protected void Page_Load(object sender, EventArgs e)
           {
                  Document document = CreateDocument();
               

                   // Send PDF to browser
            MemoryStream stream = new MemoryStream();
            renderer.PdfDocument.Save(stream, false);
            Response.Clear();
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-length", stream.Length.ToString());
            Response.BinaryWrite(stream.ToArray());
            Response.Flush();
            stream.Close();
            Response.End();

             }

 public static Document CreateDocument()
        {
            Document document = new Document();

            DefineContentSection(document);
         }

 static void DefineContentSection(Document document)
{

      var image = section.AddImage(// What should my path to the image be on the webserver???)
}

Please Help!! I know this has to be a very simple solution.


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 27, 2016 6:14 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 909
Location: CCAA
Hi!

The Assembly class has properties that allow to find out where the assembly was loaded from (Location) and where it was copied from (Codebase).

To find your image, use the path where it was copied from.

See also:
http://stackoverflow.com/a/864497/1015447

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 27, 2016 7:53 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
See also:
http://stackoverflow.com/a/3184310/162529

_________________
Regards
Thomas Hoevel
PDFsharp Team


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

All times are UTC


Who is online

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