PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Mar 19, 2024 7:55 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Tue Jan 30, 2018 1:54 pm 
Offline

Joined: Tue Jan 30, 2018 10:25 am
Posts: 4
Hi,

I'm new here so sorry for anny mistakes I make.

I've been looking/trying for 2 days to find a solution for my problem. Please help me.

I have mixed PDF-Sharp and MigraDoc to create an offer Printout / PDF (Version 1.31).
Thus far everything works fine, but I have a problem with the description text I want to show. The string is long and would print out over sevral lines, but the programming only makes one line, which gets cut of at the page edge.

following a code snippit.
Code:
 

               Document MigDoc = new Document();
               Section sec = MigDoc.AddSection();
           
               // Create a renderer and prepare (=layout) the document
               MigraDoc.Rendering.DocumentRenderer docRenderer = new MigraDoc.Rendering.DocumentRenderer(MigDoc);
               docRenderer.PrepareDocument();

                Paragraph paraArt;
                paraArt = sec.AddParagraph();
                paraArt.Format.Font.Name = "Arial";
                paraArt.Format.Font.Size = 9;
                paraArt.Format.Font.Color = MigraDoc.DocumentObjectModel.Colors.Black;

                paraArt.AddText(Description);
                docRenderer.RenderObject(XGfx, StartP.X+35, StartP.Y + 43, 350, paraArt);


As mentioned I want the text to break line and fit in a width of 350 units. If I add boarders to the paragraph then the boarder does actually stop at the desired width
attached are three pictures. one shows the amount of text I want shown. The second shows the output PDF I get and the second with boarders.

One thing that gets me is I did have it working, but after a simple adjustment in the header (additional Text lines) it switched to one line only.
Is there a command for this, which I haven't found or not understood yet?

Thank you for any help.


Attachments:
File comment: Result PDF with boarders
MigraDoc3.jpg
MigraDoc3.jpg [ 88.37 KiB | Viewed 3993 times ]
File comment: Result I am getting.
MigraDoc2.jpg
MigraDoc2.jpg [ 44.38 KiB | Viewed 3993 times ]
File comment: Content of string trying to be shown
MigraDoc1.jpg
MigraDoc1.jpg [ 86.05 KiB | Viewed 3993 times ]
Top
 Profile  
Reply with quote  
PostPosted: Tue Jan 30, 2018 3:42 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3092
Location: Cologne, Germany
Hi!

You add the paragraph after calling PrepareDocument(). Maybe that's the whole problem.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 31, 2018 8:33 am 
Offline

Joined: Tue Jan 30, 2018 10:25 am
Posts: 4
Super thanks.
Done the job. Didn't think it would be a problem!


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 83 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