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

Migra Doc table image
https://forum.pdfsharp.net/viewtopic.php?f=2&t=460
Page 1 of 1

Author:  mav23 [ Tue Sep 02, 2008 6:18 am ]
Post subject:  Migra Doc table image

Hi ,
i have something like this for creating a table via migradoc
Document document = new Document();
Table table = new Table();
Column column = table.AddColumn(Unit.FromInch(7));
Cell cell;
Row row = table.AddRow();
cell = row.Cells[0];
cell.AddParagraph("test");
table.SetEdge(0, 0, 1, 1, Edge.Box, BorderStyle.Single, 1.5);
document.LastSection.Add(table);

problem is i want to add a background image to the table not for a cell.
how to do this? someone please help

Author:  Thomas Hoevel [ Tue Sep 02, 2008 7:35 am ]
Post subject: 

Hello!

AFAIK background images are not supported - neither for cells nor for tables.

You can achieve a similar effect if you add an image just before you add the table. Set the WrapStyle of the image to "Through" and the table will be drawn above the image.

Author:  mav23 [ Tue Sep 02, 2008 8:35 am ]
Post subject: 

Hi thomas ,
thanks a lot for the quick reply,can u help me out in the code part a bit?
I need the code to add an image.Right now am stuck as to how to implement this in migradoc,as i just started using this pdf tool

Document document = new Document();
Section section = document.AddSection();
section.AddImage("test.gif");
Table table = new Table();
Column column = table.AddColumn(Unit.FromInch(7));
Cell cell;
Row row = table.AddRow();
cell = row.Cells[0];
cell.AddParagraph("test");
table.SetEdge(0, 0, 1, 1, Edge.Box, BorderStyle.Single, 1.5);
document.LastSection.Add(table);

it will be helpful if u can add code, the way u wanted me to implement image functionality.I created a section and added an image just before i create the table.Now how i proceed to add imagewrapstyle as through?plz help me with the code

Author:  Thomas Hoevel [ Tue Sep 02, 2008 10:25 am ]
Post subject: 

AddImage returns the image and allows you to change its appearance:
Code:
MigraDoc.DocumentObjectModel.Shapes.Image image = section.AddImage("<filename goes here>");
image.WrapFormat.Style = MigraDoc.DocumentObjectModel.Shapes.WrapStyle.Through;

Or with the appropriate usings:
Code:
Image image = section.AddImage("<filename goes here>");
image.WrapFormat.Style = WrapStyle.Through;
image.Width = Unit.FromInch(7);


The height of the image and the height of the table should match and you should take care that the table will never split on a pagebreak.

Author:  mav23 [ Tue Sep 02, 2008 11:17 am ]
Post subject: 

thank you very much thomas
i got what i wanted:)i was trying to get a watermark effect with this actually..
and its done now:) thank you once again for the quick replies u gave me

Author:  mav23 [ Wed Sep 03, 2008 4:37 am ]
Post subject: 

hi
just a quick clarification..
in my code i have cell.AddParagraph("test")
the text is coming after leaving a small gap from left side of table.so when am applying image ,the image is starting where the text starts am i missing something? or is it by default that way? anything i can do to make the image start from table left end without leaving gap..

Author:  Thomas Hoevel [ Wed Sep 03, 2008 8:28 am ]
Post subject: 

Hello!

It's a feature: the text in the table is left aligned with the text outside the table.

You can give the image a negative left position to make up for the padding of the table

Author:  mav23 [ Wed Sep 03, 2008 9:57 am ]
Post subject: 

ok thanks agian thomas:)

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