Persits Software, Inc. Knowledge Base Articles

HOWTO: Display justified text

Summary

Starting with version 1.1.0.2, AspPDF supports justified text (i.e. alignment on both the left and right sides of a paragraph, see image).

This article explains how to display a justified text paragraph.

Solution

A text paragraph to be justified should be enclosed within a <DIV> tag with the ALIGN attribute set to "JUSTIFY", as follows:

<DIV ALIGN="JUSTIFY">
...
</DIV>

A string of text containing the <DIV> tag must be passed to the Canvas.DrawText method with the HTML parameter set to True to enable AspPDF's support for HTML tags.

The following code fragment takes an arbitrary text string Text, encloses it in the <DIV> tags and displays it on a page as a 100-unit-wide column:

Text = "<DIV ALIGN=""JUSTIFY"">" & Text & "</DIV>"
Page.Canvas.DrawText Text, "x=10; y=500; width=100; html=true", Font