PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
Image position along with text https://forum.pdfsharp.net/viewtopic.php?f=2&t=995 |
Page 1 of 1 |
Author: | koutnypetr [ Thu Dec 17, 2009 11:57 pm ] | ||
Post subject: | Image position along with text | ||
Hi, I'm trying to create simple PDF using MigraDoc, but with no avail. My aim is to create one paragraph filled out with string and one image placed into that paragraph. I'd like to position image to the right so the text will appear to the left from the image, as attached image illustrates. I'm not sure if MigraDoc is capable for doing this stuff, but I guess it's common request so it must be supported, but I don't know the way how to create it. Any help will be greatly appreciated!
|
Author: | mikesowerbutts [ Fri Dec 18, 2009 10:42 am ] |
Post subject: | Re: Image position along with text |
Hi koutnypetr, I would start by creating a Paragraph object then adding the text/image to that. a MigraDoc Image object has a "WrapFormat" property which i presume will do what you need. I would so something like this: Code: Paragraph _p = new Paragraph(); Image _img = _p.AddImage("myimg.jpg"); _img.Left = 100; _img.Top = 10; _img.WrapFormat.DistanceLeft = _img.WrapFormat.DistanceBottom = 5; _p.AddText("some text here"); Setting the WrapFormat properties on the Image should hopefully make the text wrap with some padding. And setting the .Top and .Left Properties of the image will set it's position relative to the Top Left of the Paragraph Object it is contained within. I have not tested to see if this actually works, but i think its a good place to start. Mike |
Author: | koutnypetr [ Fri Dec 18, 2009 11:20 am ] | ||
Post subject: | Re: Image position along with text | ||
Hi Mike, first of all, I'd like to thank you for the quick reply. That's the problem, I was aware of WrapFormat property, but didn't find any useful result. I tried your posted code and the result is attached. Problem is obvious - the text is vertically aligned to the bottom, I'd expect text position to be vertically aligned to the top just right after the picture. Do you have any ideas, please? Thanks for your time, Mike!
|
Author: | koutnypetr [ Mon Jan 11, 2010 6:29 am ] |
Post subject: | Re: Image position along with text |
Still noone? I can't believe nobody can horizontally align image as I described |
Author: | Apfelkuacha [ Wed Oct 27, 2021 2:24 pm ] |
Post subject: | Re: Image position along with text |
For those who also have this issue (I also did): The image doesn't change the location if it is added to the paragraph. Instead add it to the section like this: image = Section.AddImage(...) That way setting the image.Left does have an effect! Compared to adding it to the paragraph, setting the Left property doesn't change anything. Setting image.Top doesn't work both ways, here you could use image.WrapFormat.DistanceTop instead to set the Top distance. That should definatly be a point which should be fixed, as I found loads of people with problems here and the solution were hacks like adding a table around. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |