Aspose.Pdf

Set Text Rendering Mode

Text Rendering is also featured by Aspose.Pdf . There are some pre-defined rendering modes in Aspose.Pdf that can be applied on Text paragraphs by using an enumeration, RenderingMode .

 

The pre-defined modes in RenderingMode enumeration are given below:

 

Rendering Mode Name

Description

FillText

Fills text mode

StrokeText

Stroke text (outline) mode

FillStrokeText

Fill and Stroke text mode

InvisibleText

Invisible text mode

 

To apply text rendering, you just need to follow these steps:

 

 

After setting the Text.TextInfo.RenderingMode property, the Text paragraph will be rendered according to the rendering mode selected by you.

 

Code Snippet

 

[C#]

 

//Instantiate Pdf instance by calling its empty constructor

Pdf pdf1 = new Pdf()

 

//Create a section in the Pdf object

Section sec1 = pdf1.Sections.Add();

 

//Create 1st text paragraph

Text text1 = new Text(sec1,"FillText mode");

 

//Set rendering mode to FillText

text1.TextInfo.RenderingMode=RenderingMode.FillText;

 

//Create 2nd text paragraph

Text text2 = new Text(sec1,"StrokeText mode (outline)");

 

//Set rendering mode to StrokeText

text2.TextInfo.RenderingMode=RenderingMode.StrokeText;

 

//Create 3rd text paragraph

Text text3 = new Text(sec1,"FillStrokeText mode");

 

//Set rendering mode to FillStrokeText

text3.TextInfo.RenderingMode=RenderingMode.FillStrokeText;

 

//Create 4th text paragraph

Text text4 = new Text(sec1,"InvisibleText mode");

 

//Set rendering mode to InvisibleText

text4.TextInfo.RenderingMode=RenderingMode.InvisibleText;

 

//Add 1st, 2nd, 3rd and 4th text paragraphs to the section

sec1.Paragraphs.Add(text1);

sec1.Paragraphs.Add(text2);

sec1.Paragraphs.Add(text3);

sec1.Paragraphs.Add(text4);

 

//Save the Pdf

pdf1.Save(...);

 

[VB.NET]

 

'Instantiate Pdf instance by calling its empty constructor

Dim pdf1 As Pdf =  New Pdf()

 

'Create a section in the Pdf object

Dim sec1 As Section =  pdf1.Sections.Add()

 

'Create 1st text paragraph

Dim text1 As Text =  New Text(sec1,"FillText mode")

 

'Set rendering mode to FillText

text1.TextInfo.RenderingMode=RenderingMode.FillText

 

'Create 2nd text paragraph

Dim text2 As Text =  New Text(sec1,"StrokeText mode (outline)")

 

'Set rendering mode to StrokeText

text2.TextInfo.RenderingMode=RenderingMode.StrokeText

 

'Create 3rd text paragraph

Dim text3 As Text =  New Text(sec1,"FillStrokeText mode")

 

'Set rendering mode to FillStrokeText

text3.TextInfo.RenderingMode=RenderingMode.FillStrokeText

 

'Create 4th text paragraph

Dim text4 As Text =  New Text(sec1,"InvisibleText mode")

 

'Set rendering mode to InvisibleText

text4.TextInfo.RenderingMode=RenderingMode.InvisibleText

 

'Add 1st, 2nd, 3rd and 4th text paragraphs to the section

sec1.Paragraphs.Add(text1)

sec1.Paragraphs.Add(text2)

sec1.Paragraphs.Add(text3)

sec1.Paragraphs.Add(text4)

 

'Save the Pdf

pdf1.Save(...)

 

[JAVA]

//Instantiate Pdf instance by calling its empty constructor

Pdf pdf1 = new Pdf();

 

//Create a new section in the Pdf object

Section sec1 = pdf1.getSections().add();

 

//Create 1st text paragraph

Text text1 = new Text(sec1,"FillText mode");

 

//Set rendering mode to FillText

text1.getTextInfo().setRenderingMode(RenderingMode.FillText);

 

//Create 2nd text paragraph

Text text2 = new Text(sec1,"StrokeText mode (outline)");

 

//Set rendering mode to StrokeText

text2.getTextInfo().setRenderingMode(RenderingMode.StrokeText);

 

//Create 3rd text paragraph

Text text3 = new Text(sec1,"FillStrokeText mode");

 

//Set rendering mode to FillStrokeText

text3.getTextInfo().setRenderingMode(RenderingMode.FillStrokeText);

 

//Create 4th text paragraph

Text text4 = new Text(sec1,"InvisibleText mode");

 

//Set rendering mode to InvisibleText

text4.getTextInfo().setRenderingMode(RenderingMode.InvisibleText);

 

//Add 1st, 2nd and 3rd text paragraphs to the section

sec1.getParagraphs().add(text1);

sec1.getParagraphs().add(text2);

sec1.getParagraphs().add(text3);             

sec1.getParagraphs().add(text4);

 

//Save the Pdf

FileOutputStream out = new FileOutputStream(new File("..."));

pdf1.save(out);

 

Using the above code, will produce the output as follows:

 

Note: The InvisibleText mode can't be seen