PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri May 03, 2024 4:27 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Fri Mar 15, 2013 1:10 pm 
Offline

Joined: Fri Mar 15, 2013 9:47 am
Posts: 6
Hi,
I am using the following code to create Text and image for a Table cell.
public Paragraph TextImage(string value)
{
Paragraph paragraph = new Paragraph();
paragraph.Format.Alignment = ParagraphAlignment.Center;

Image img = new Image("../../bullet_green.png");
img.ScaleWidth = 0.55;
img.LockAspectRatio = true;
img.WrapFormat.Style = WrapStyle.Through;
img.RelativeHorizontal = RelativeHorizontal.Character;

paragraph.AddText(value);
paragraph.Add(img);

return paragraph;
}

While the code works I would like to position the image so that it aligned with the text
Does anyone have any suggestions?
Please see the attached
Thanks


Attachments:
Capture.PNG
Capture.PNG [ 27.08 KiB | Viewed 9408 times ]
Top
 Profile  
Reply with quote  
PostPosted: Tue Mar 19, 2013 9:26 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3097
Location: Cologne, Germany
Hi!

What is the exact goal: moving the green bullet down to the text "5.0"? Or move the text "5.0" up to the bullet? Or something else?

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Mar 19, 2013 9:47 am 
Offline

Joined: Fri Mar 15, 2013 9:47 am
Posts: 6
I would like to have the text 5.0 moved up so that it aligns with the rest of teh row text.
Thanks


Top
 Profile  
Reply with quote  
PostPosted: Wed Mar 27, 2013 12:39 pm 
Offline

Joined: Fri Mar 15, 2013 9:47 am
Posts: 6
Is there anything I can do to resolve this issue?
Thanks


Top
 Profile  
Reply with quote  
PostPosted: Wed Mar 27, 2013 1:07 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3097
Location: Cologne, Germany
Does the image bullet_green.png contain transparent areas or is it the smallest possible rectangle around the circle?

Setting img.Top and img.Left (IIRC) you should be able to move the image (negative values can also be used).

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Mar 27, 2013 1:24 pm 
Offline

Joined: Fri Mar 15, 2013 9:47 am
Posts: 6
I tried to use img.Top and Left but is does not appear to make any difference.
Yes the image has a transparent area around the green bullet.
I have attached the image if that helps.

Any other suggestions?

Thanks


Attachments:
bullet_green.png
bullet_green.png [ 740 Bytes | Viewed 9364 times ]
Top
 Profile  
Reply with quote  
PostPosted: Wed Mar 27, 2013 2:03 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3097
Location: Cologne, Germany
The text is bottom-aligned with the image (but the image has a large transparent area at the bottom). Cropping the unneeded transparent areas from the image should solve the problem.

If you have to use the image as it is: Try img.WrapFormat.DistanceTop instead of img.Top (my fault).

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Mar 27, 2013 2:54 pm 
Offline

Joined: Fri Mar 15, 2013 9:47 am
Posts: 6
Thomas
Thanks for the reply.

I could not move the text or image with the suggested commands.
I did remove the extra space around the image and that looks pretty good.

My next problem is the combined text and image are always aligned to the bottom of the cell.
How can I get the to be centered in the cell

I am using the following to add the item to the cell
row2.Cells[3].VerticalAlignment = VerticalAlignment.Center;
row2.Cells[3].Format.Alignment = ParagraphAlignment.Center;
row2.Cells[3].Add(TextImage(discount.ToString("0.0")));
but it still will not line up


Attachments:
Capture1.PNG
Capture1.PNG [ 22.91 KiB | Viewed 9362 times ]
Top
 Profile  
Reply with quote  
PostPosted: Wed Mar 27, 2013 3:11 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3097
Location: Cologne, Germany
SS4077 wrote:
I did remove the extra space around the image and that looks pretty good.
Did you remove the space at top and bottom?
Text and image are a unit. I presume height of row is determined by height of image (with space at top).

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu Mar 28, 2013 4:52 pm 
Offline

Joined: Fri Mar 15, 2013 9:47 am
Posts: 6
Thomas
Removing the extra space fixed my problem thanks again for your help. :P
Steve


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

All times are UTC


Who is online

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