PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
Dispaly Text and Image in Cell https://forum.pdfsharp.net/viewtopic.php?f=2&t=2369 |
Page 1 of 1 |
Author: | SS4077 [ Fri Mar 15, 2013 1:10 pm ] | ||
Post subject: | Dispaly Text and Image in Cell | ||
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
|
Author: | Thomas Hoevel [ Tue Mar 19, 2013 9:26 am ] |
Post subject: | Re: Dispaly Text and Image in Cell |
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? |
Author: | SS4077 [ Tue Mar 19, 2013 9:47 am ] |
Post subject: | Re: Dispaly Text and Image in Cell |
I would like to have the text 5.0 moved up so that it aligns with the rest of teh row text. Thanks |
Author: | SS4077 [ Wed Mar 27, 2013 12:39 pm ] |
Post subject: | Re: Dispaly Text and Image in Cell |
Is there anything I can do to resolve this issue? Thanks |
Author: | Thomas Hoevel [ Wed Mar 27, 2013 1:07 pm ] |
Post subject: | Re: Dispaly Text and Image in Cell |
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). |
Author: | SS4077 [ Wed Mar 27, 2013 1:24 pm ] | ||
Post subject: | Re: Dispaly Text and Image in Cell | ||
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
|
Author: | Thomas Hoevel [ Wed Mar 27, 2013 2:03 pm ] |
Post subject: | Re: Dispaly Text and Image in Cell |
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). |
Author: | SS4077 [ Wed Mar 27, 2013 2:54 pm ] | ||
Post subject: | Re: Dispaly Text and Image in Cell | ||
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
|
Author: | Thomas Hoevel [ Wed Mar 27, 2013 3:11 pm ] |
Post subject: | Re: Dispaly Text and Image in Cell |
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). |
Author: | SS4077 [ Thu Mar 28, 2013 4:52 pm ] |
Post subject: | Re: Dispaly Text and Image in Cell |
Thomas Removing the extra space fixed my problem thanks again for your help. Steve |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |