PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

How to Add Image and Text in the same line using MigraDoc
https://forum.pdfsharp.net/viewtopic.php?f=2&t=2374
Page 1 of 1

Author:  er.narendraojha [ Wed Mar 20, 2013 1:14 pm ]
Post subject:  How to Add Image and Text in the same line using MigraDoc

Hi,

I want to add a logo image and Header Text in each Page in my PDF file. When I add the image and then I add the text both image and text are not aligned in same row. I also tried the same using the Table. But again it was negative.
I am using the below code...

Section section = this.document.AddSection();

// Put a logo in the header
MigraDoc.DocumentObjectModel.Shapes.Image image = section.Headers.Primary.AddImage("../../ABCD.png");
image.Height = "2.0cm";
image.LockAspectRatio = true;
image.RelativeVertical = RelativeVertical.Line;
//image.RelativeHorizontal = RelativeHorizontal.Margin;
image.Top = ShapePosition.Top;
image.Left = ShapePosition.Left;
image.WrapFormat.Style = WrapStyle.Through;
image.RelativeHorizontal = RelativeHorizontal.Column;

// Create the text frame for the address
addressFrame = section.AddTextFrame();
addressFrame.Height = "3.0cm";
addressFrame.Width = "7.0cm";
addressFrame.Left = ShapePosition.Right;
addressFrame.RelativeHorizontal = RelativeHorizontal.Margin;
addressFrame.Top = "0.0cm";
addressFrame.RelativeVertical = RelativeVertical.Page;

// Put sender in address frame
paragraph = addressFrame.AddParagraph("Company Name,");
paragraph.Format.SpaceBefore = "2.1cm";
paragraph.Format.Font.Name = "Arial";
paragraph.Format.Font.Size = 7;
paragraph.Format.SpaceBefore= "3.1cm";
paragraph.Format.Font.Color = Colors.Green;

This Code give me an out put with Logo Image on the top left and the text is just below the logo image. Where as I want the text should be just after right to the logo image. is this possible using Migra doc? Please find attached image for expected out put.

Attachments:
File comment: Expected result using Migra Doc
Presentation2.png
Presentation2.png [ 11.8 KiB | Viewed 22133 times ]

Author:  Thomas Hoevel [ Wed Mar 20, 2013 1:37 pm ]
Post subject:  Re: How to Add Image and Text in the same line using MigraDo

Hi!
Images and TextFrames are Shapes.
You can set the position of a Shape absolutely (using e.g. RelativeVertical.Page and RelativeHorizontal.Page). Just place them where you want them.

Author:  er.narendraojha [ Thu Mar 21, 2013 6:26 am ]
Post subject:  Re: How to Add Image and Text in the same line using MigraDo

Hi Thoms,

I tried using the RelativeHorizontal.Page and RelativeVertical.Page and all other combinations but it did not work:-(. Any help.

Author:  er.narendraojha [ Thu Mar 21, 2013 2:57 pm ]
Post subject:  Re: How to Add Image and Text in the same line using MigraDo

Hi,

When I tried some of the other combination it finally worked.. thanks MigraDoc :-) you rocks...

Author:  nitsuj [ Thu Mar 27, 2014 6:32 am ]
Post subject:  Re: How to Add Image and Text in the same line using MigraDo

I'm having a similar issue, got a paragraph and want an image on the left and the text to the right to wrap if needed.

Do you mind sharing the code that finaly worked for you?

Author:  Thomas Hoevel [ Thu Mar 27, 2014 12:47 pm ]
Post subject:  Re: How to Add Image and Text in the same line using MigraDo

Similar question discussed here:
viewtopic.php?p=8036#p8036

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/