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

My Text exceeds the Paragraph width! why?
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3723
Page 1 of 1

Author:  IDE-Lenneper [ Tue Jan 30, 2018 1:54 pm ]
Post subject:  My Text exceeds the Paragraph width! why?

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 1327 times ]
File comment: Result I am getting.
MigraDoc2.jpg
MigraDoc2.jpg [ 44.38 KiB | Viewed 1327 times ]
File comment: Content of string trying to be shown
MigraDoc1.jpg
MigraDoc1.jpg [ 86.05 KiB | Viewed 1327 times ]

Author:  Thomas Hoevel [ Tue Jan 30, 2018 3:42 pm ]
Post subject:  Re: My Text exceeds the Paragraph width! why?

Hi!

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

Author:  IDE-Lenneper [ Wed Jan 31, 2018 8:33 am ]
Post subject:  Re: My Text exceeds the Paragraph width! why?

Super thanks.
Done the job. Didn't think it would be a problem!

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