View previous topic :: View next topic |
Author |
Message |
mav23
Joined: 02 Sep 2008 Posts: 5 Location: India
|
Posted: 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 |
|
Back to top |
|
|
Thomas Hoevel
Joined: 16 Oct 2006 Posts: 387 Location: Cologne, Germany
|
Posted: 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. _________________ Regards
Thomas Hoevel
PDFsharp Team |
|
Back to top |
|
|
mav23
Joined: 02 Sep 2008 Posts: 5 Location: India
|
Posted: 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 |
|
Back to top |
|
|
Thomas Hoevel
Joined: 16 Oct 2006 Posts: 387 Location: Cologne, Germany
|
Posted: 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. _________________ Regards
Thomas Hoevel
PDFsharp Team |
|
Back to top |
|
|
mav23
Joined: 02 Sep 2008 Posts: 5 Location: India
|
Posted: 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 |
|
Back to top |
|
|
mav23
Joined: 02 Sep 2008 Posts: 5 Location: India
|
Posted: 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.. |
|
Back to top |
|
|
Thomas Hoevel
Joined: 16 Oct 2006 Posts: 387 Location: Cologne, Germany
|
Posted: 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 _________________ Regards
Thomas Hoevel
PDFsharp Team |
|
Back to top |
|
|
mav23
Joined: 02 Sep 2008 Posts: 5 Location: India
|
Posted: Wed Sep 03, 2008 9:57 am Post subject: |
|
|
ok thanks agian thomas:) |
|
Back to top |
|
|
|