Newline in FormattedTextArea

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v5)  /  Newline in FormattedTextArea

DynamicPDF CoreSuite for .NET (v5) Forum

 Jan 27 2011 4:45 AM
Our customer has a wish to create "soft" newlines in a formattedtextarea. Consider the following two samples of HTML that *should* yield different PDF output, but yields the same PDF output:

1.
<p>Some text<br />with a soft linebreak</p>

2.
<p>Some text</p><p>with a hard linebreak</p>

These two HTML samples yield the exact same PDF output using FormattedTextArea. How is it possible to just add a linebreak in example 1, instead of a new paragraph?
 Jan 27 2011 8:45 AM
Posted by a ceTe Software moderator
Hello,

Are you trying to add the indent to the paragraph? If so you will have to set indent to the paragraph using the Indent property of the Paragraph class. By default the indent will be set to zero and this is the reason you are seeing the same behavior for both of your examples. Below is the code to set indent for the paragraph.

        FormattedTextAreaStyle style = new FormattedTextAreaStyle(FontFamily.Helvetica, 14, true);
            string text="<p>Some text <br />with a soft linebreak </p>" ;
            FormattedTextArea area = new FormattedTextArea(text, 10, 150, 200, 100, style);
           
        string formattedText = "<p>Some text to check the paragraph</p><p>with a hard linebreak with HTML br tag and this should be added with some indent</p> ";
            FormattedTextArea formattedTextArea = new FormattedTextArea(formattedText, 10, 10, 200, 100, FontFamily.Helvetica, 14, true);
            formattedTextArea.Style.Paragraph.Indent = 20;
           
            Document document = new Document();
            Page page = new Page();
            page.Elements.Add(formattedTextArea);
            page.Elements.Add(area);
            document.Pages.Add(page);
            document.Draw(@"C:\Temp\Test.pdf");

Thanks,
ceTe Software Team.
 Jan 27 2011 2:30 PM
I do not wish to indent the text. I want the first example to look like this in the PDF:

[begin]
Some text
with a soft linebreak
[end]

And the second example to look like this:

[begin]
Some text

with a hard linebreak
[end]

(The PDF rendering code should be equal for both cases)
 Jan 28 2011 6:41 AM
Posted by a ceTe Software moderator
Hello,

You can use the SpacingAfter property of the paragraph style class to set the desired spacing btween the paragraphs using our DynamicPDF Generator API. Below is the code for it.

            FormattedTextAreaStyle style = new FormattedTextAreaStyle(FontFamily.Helvetica, 14, true);
            string text = "<p>Some text <br />with a soft linebreak </p>";
            FormattedTextArea area = new FormattedTextArea(text, 10, 10, 200, 100, style);

            string formattedText = "<p>Some text </p><p>with a hard linebreak </p> ";
            FormattedTextArea formattedTextArea = new FormattedTextArea(formattedText, 10, 150, 200, 100, FontFamily.Helvetica, 14, true);
            formattedTextArea.Style.Paragraph.SpacingAfter = 10;

            Document document = new Document();
            Page page = new Page();
            page.Elements.Add(area);
            page.Elements.Add(formattedTextArea);
            document.Pages.Add(page);
            document.Draw(@"C:\Temp\Test.pdf");

Thanks,
ceTe Software Support Team.
 Jan 28 2011 6:45 AM
Tried using the SpacingAfter property, but that affects both the soft linebreaks and the hard linebreaks. I get hard linebreaks for both <p> and <br/> with indent = 0, spacingafter = 12, spacingbefore = 0
 Jan 28 2011 6:49 AM
To clarify, I want this in the SAME FormattedTextArea object. Not different FormattedTextArea objects. As stated earlier "same code" for both cases.

/Peter
 Jan 28 2011 7:16 AM
Posted by a ceTe Software moderator
Hello Peter,

Can you please let us know what build of our DynamicPDF product you are using? Also please send over the sample code which you are using and output PDF document to our support team at: support@cete.com so that they can look into it further.

Thanks,
ceTe Software Support Team.
 Jan 28 2011 8:32 AM
Resolved with new version of the ceTe assembly!
 Apr 25 2011 6:19 PM
One small addition query how can we add a line (not line break just a simple line to the formattedtext
 Apr 26 2011 4:38 AM
Posted by a ceTe Software moderator
Hello,

Can you please send over more details about your requirements and also tell us what you are trying to achieve using our DynamicPDF product to our support team at: support@cete.com so that they can look into it further?

Thanks,
ceTe Software Support Team.
 Jun 21 2011 10:57 AM
Posted by a ceTe Software moderator
Hello,

If anyone is having the same issue with v5, please send an email to support@cete.com referring to the URL of this post so we can send you the latest build that fixes the issue. 

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 3:39 AM.