PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu May 02, 2024 1:13 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Migra Doc table image
PostPosted: Tue Sep 02, 2008 6:18 am 
Offline

Joined: Tue Sep 02, 2008 6:06 am
Posts: 5
Location: India
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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Sep 02, 2008 7:35 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3097
Location: Cologne, Germany
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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Sep 02, 2008 8:35 am 
Offline

Joined: Tue Sep 02, 2008 6:06 am
Posts: 5
Location: India
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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Sep 02, 2008 10:25 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3097
Location: Cologne, Germany
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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Sep 02, 2008 11:17 am 
Offline

Joined: Tue Sep 02, 2008 6:06 am
Posts: 5
Location: India
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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Sep 03, 2008 4:37 am 
Offline

Joined: Tue Sep 02, 2008 6:06 am
Posts: 5
Location: India
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..


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Sep 03, 2008 8:28 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3097
Location: Cologne, Germany
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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Sep 03, 2008 9:57 am 
Offline

Joined: Tue Sep 02, 2008 6:06 am
Posts: 5
Location: India
ok thanks agian thomas:)


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

All times are UTC


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 75 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