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

MigraDoc - Not able to include Image
https://forum.pdfsharp.net/viewtopic.php?f=2&t=590
Page 1 of 1

Author:  abhayp [ Wed Dec 24, 2008 6:23 am ]
Post subject:  MigraDoc - Not able to include Image

Hi

I have a asp.net web application with the structure as follows

Root
- Images
- App_Code
- Myclass.cs
mypage.aspx

In the app_code folder i have a class that creates the Migradoc object for createing the document and include the image in it

Table newTable = section.AddTable();
newTable.Style = "Table";
newTable.Borders.Color = tableBorder;
newTable.Borders.Bottom.Width = 0.6;
newTable.Borders.Left.Width = 0.0;
newTable.Borders.Right.Width = 0.0;
newTable.Borders.Top.Width = 0.0;
newTable.Rows.LeftIndent = 0;

Column column1 = newTable.AddColumn("3cm");
column1 = newTable.AddColumn("13cm");

Row newrow = newTable.AddRow();
newrow.Cells[0].AddImage("../images/logo.gif");

This always shows "image not found" in the pdf document created


:?: Can someone please advice what's wrong in that ?

Author:  Thomas Hoevel [ Thu Jan 08, 2009 10:15 am ]
Post subject:  Re: MigraDoc - Not able to include Image

Hi!
abhayp wrote:
:?: Can someone please advice what's wrong in that ?

Probably wrong working directory.

You can set the ImagePath at the Document.
IIRC the working directory is not the directory with the ASPX file. But there's a method that returns the physical address of the ASPX file.

Author:  Soldier-B [ Thu Jan 08, 2009 2:20 pm ]
Post subject:  Re: MigraDoc - Not able to include Image

Thomas Hoevel wrote:
Hi!
abhayp wrote:
:?: Can someone please advice what's wrong in that ?

Probably wrong working directory.

You can set the ImagePath at the Document.
IIRC the working directory is not the directory with the ASPX file. But there's a method that returns the physical address of the ASPX file.


Server.MapPath("../images/logo.gif")

Author:  jhmb [ Mon Feb 13, 2012 7:36 pm ]
Post subject:  Re: MigraDoc - Not able to include Image

I would appreciate some more explanation on this solution.
I am using Migradoc on a webpage.
The class is in the subdirectory appcode and the images are in the subdirectory images.
I can't find the way to show the images in the output page.
Similar code works fine as a console application (but there it i easy to find the images)

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