PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Jul 14, 2024 4:02 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Wed Mar 20, 2013 1:14 pm 
Offline

Joined: Wed Mar 20, 2013 1:02 pm
Posts: 8
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 22130 times ]
Top
 Profile  
Reply with quote  
PostPosted: Wed Mar 20, 2013 1:37 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
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.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu Mar 21, 2013 6:26 am 
Offline

Joined: Wed Mar 20, 2013 1:02 pm
Posts: 8
Hi Thoms,

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


Top
 Profile  
Reply with quote  
PostPosted: Thu Mar 21, 2013 2:57 pm 
Offline

Joined: Wed Mar 20, 2013 1:02 pm
Posts: 8
Hi,

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


Top
 Profile  
Reply with quote  
PostPosted: Thu Mar 27, 2014 6:32 am 
Offline

Joined: Thu Mar 27, 2014 6:30 am
Posts: 5
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?


Top
 Profile  
Reply with quote  
PostPosted: Thu Mar 27, 2014 12:47 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
Similar question discussed here:
viewtopic.php?p=8036#p8036

_________________
Regards
Thomas Hoevel
PDFsharp Team


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 34 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:  
cron
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group