PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Dec 04, 2021 4:51 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Thu Dec 17, 2009 11:57 pm 
Offline

Joined: Thu Dec 17, 2009 11:42 pm
Posts: 4
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!


Attachments:
sample.jpg
sample.jpg [ 101.46 KiB | Viewed 7211 times ]
Top
 Profile  
Reply with quote  
PostPosted: Fri Dec 18, 2009 10:42 am 
Offline
Supporter

Joined: Fri May 15, 2009 3:28 pm
Posts: 96
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


Top
 Profile  
Reply with quote  
PostPosted: Fri Dec 18, 2009 11:20 am 
Offline

Joined: Thu Dec 17, 2009 11:42 pm
Posts: 4
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!


Attachments:
sample2.jpg
sample2.jpg [ 41.33 KiB | Viewed 7200 times ]
Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 11, 2010 6:29 am 
Offline

Joined: Thu Dec 17, 2009 11:42 pm
Posts: 4
Still noone? I can't believe nobody can horizontally align image as I described :(


Top
 Profile  
Reply with quote  
PostPosted: Wed Oct 27, 2021 2:24 pm 
Offline

Joined: Wed Oct 27, 2021 1:42 pm
Posts: 1
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.


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

All times are UTC


Who is online

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