PdfTextElement Class
Represents the text area with the ability to span several pages and inherited from the PdfLayoutElement class
Inherited Members
Namespace: Syncfusion.Pdf.Graphics
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfTextElement : PdfLayoutElement
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page to the document.
PdfPage page = document.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Use the font installed in the machine
PdfFont font = new PdfTrueTypeFont(new Font("Arial", 14));
//Create PDF text element
PdfTextElement element = new PdfTextElement("Hello World!!!", font, PdfBrushes.Black);
//Draw the text element.
element.Draw(graphics);
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Create PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics
'Use the font installed in the machine
Dim font As PdfFont = New PdfTrueTypeFont(New Font("Arial", 14))
'Create PDF text element
Dim element As New PdfTextElement("Hello World!!!", font, PdfBrushes.Black)
'Draw the text element.
element.Draw(graphics)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
Constructors
PdfTextElement()
Initializes a new instance of the PdfTextElement class.
Declaration
public PdfTextElement()
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page to the document.
PdfPage page = document.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Use the font installed in the machine
PdfFont font = new PdfTrueTypeFont(new Font("Arial", 14));
//Create PDF text element
PdfTextElement element = new PdfTextElement();
//Set text.
element.Text = "Hello World!!!";
//Set font.
element.Font = font;
//Draw the text element.
element.Draw(graphics);
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Create PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics
'Use the font installed in the machine
Dim font As PdfFont = New PdfTrueTypeFont(New Font("Arial", 14))
'Create PDF text element
Dim element As New PdfTextElement()
'Set text.
element.Text = "Hello World!!!"
'Set font.
element.Font = font
'Draw the text element.
element.Draw(graphics)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
PdfTextElement(String)
Initializes a new instance of the PdfTextElement class with text to draw into the PDF.
Declaration
public PdfTextElement(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to draw into the PDF. |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page to the document.
PdfPage page = document.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Use the font installed in the machine
PdfFont font = new PdfTrueTypeFont(new Font("Arial", 14));
//Create PDF text element
PdfTextElement element = new PdfTextElement("Hello World!!!");
//Set font.
element.Font = font;
//Draw the text element.
element.Draw(graphics);
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Create PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics
'Use the font installed in the machine
Dim font As PdfFont = New PdfTrueTypeFont(New Font("Arial", 14))
'Create PDF text element
Dim element As New PdfTextElement("Hello World!!!")
'Set font.
element.Font = font
'Draw the text element.
element.Draw(graphics)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
PdfTextElement(String, PdfFont)
Initializes a new instance of the PdfTextElement class with the text and PdfFont.
Declaration
public PdfTextElement(string text, PdfFont font)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to draw into the PDF. |
PdfFont | font | The PdfFont that defines the text format. |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page to the document.
PdfPage page = document.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Use the font installed in the machine
PdfFont font = new PdfTrueTypeFont(new Font("Arial", 14));
//Create PDF text element
PdfTextElement element = new PdfTextElement("Hello World!!!", font);
//Draw the text element.
element.Draw(graphics);
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Create PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics
'Use the font installed in the machine
Dim font As PdfFont = New PdfTrueTypeFont(New Font("Arial", 14))
'Create PDF text element
Dim element As New PdfTextElement("Hello World!!!", font)
'Draw the text element.
element.Draw(graphics)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
PdfTextElement(String, PdfFont, PdfBrush)
Initializes a new instance of the PdfTextElement class with text,PdfFont and PdfBrush.
Declaration
public PdfTextElement(string text, PdfFont font, PdfBrush brush)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to draw into the PDF. |
PdfFont | font | The PdfFont that defines the text format. |
PdfBrush | brush | The PdfBrush that determines the color and texture of the drawn text. |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page to the document.
PdfPage page = document.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Use the font installed in the machine
PdfFont font = new PdfTrueTypeFont(new Font("Arial", 14));
//Create PDF text element
PdfTextElement element = new PdfTextElement("Hello World!!!", font, PdfBrushes.Black);
//Draw the text element.
element.Draw(graphics);
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Create PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics
'Use the font installed in the machine
Dim font As PdfFont = New PdfTrueTypeFont(New Font("Arial", 14))
'Create PDF text element
Dim element As New PdfTextElement("Hello World!!!", font, PdfBrushes.Black)
'Draw the text element.
element.Draw(graphics)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
PdfTextElement(String, PdfFont, PdfPen)
Initializes a new instance of the PdfTextElement class with text,PdfFont and PdfPen.
Declaration
public PdfTextElement(string text, PdfFont font, PdfPen pen)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to draw into the PDF. |
PdfFont | font | The PdfFont that defines the text format. |
PdfPen | pen | The PdfPen that determines the color, width, and style of the text |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page to the document.
PdfPage page = document.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Use the font installed in the machine
PdfFont font = new PdfTrueTypeFont(new Font("Arial", 14));
//Create PDF text element
PdfTextElement element = new PdfTextElement("Hello World!!!", font, PdfPens.Black);
//Draw the text element.
element.Draw(graphics);
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Create PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics
'Use the font installed in the machine
Dim font As PdfFont = New PdfTrueTypeFont(New Font("Arial", 14))
'Create PDF text element
Dim element As New PdfTextElement("Hello World!!!", font, PdfPens.Black)
'Draw the text element.
element.Draw(graphics)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
PdfTextElement(String, PdfFont, PdfPen, PdfBrush, PdfStringFormat)
Initializes a new instance of the PdfTextElement class with text,PdfFont,PdfPen,PdfBrush and PdfStringFormat.
Declaration
public PdfTextElement(string text, PdfFont font, PdfPen pen, PdfBrush brush, PdfStringFormat format)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to draw into the PDF. |
PdfFont | font | The PdfFont that defines the text format. |
PdfPen | pen | The PdfPen that determines the color, width, and style of the text |
PdfBrush | brush | The PdfBrush that determines the color and texture of the drawn text. |
PdfStringFormat | format | The PdfStringFormat that determines string format. |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page to the document.
PdfPage page = document.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Use the font installed in the machine
PdfFont font = new PdfTrueTypeFont(new Font("Arial", 14));
//Create PDF string format.
PdfStringFormat format = new PdfStringFormat();
//Set alignments.
format.Alignment = PdfTextAlignment.Center;
format.LineAlignment = PdfVerticalAlignment.Middle;
//Create PDF text element
PdfTextElement element = new PdfTextElement("Hello World!!!", font, PdfPens.Red, PdfBrushes.Black, format);
//Draw the text element.
element.Draw(page, new RectangleF(0, 0, 200, 20));
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Create PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics
'Use the font installed in the machine
Dim font As PdfFont = New PdfTrueTypeFont(New Font("Arial", 14))
'Create PDF string format.
Dim format As New PdfStringFormat()
'Set alignments.
format.Alignment = PdfTextAlignment.Center
format.LineAlignment = PdfVerticalAlignment.Middle
'Create PDF text element
Dim element As New PdfTextElement("Hello World!!!", font, PdfPens.Red, PdfBrushes.Black, format)
'Draw the text element.
element.Draw(page, New RectangleF(0, 0, 200, 20))
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
Properties
Brush
Gets or sets the PdfBrush that will be used to draw the text with color and texture.
Declaration
public PdfBrush Brush { get; set; }
Property Value
Type | Description |
---|---|
PdfBrush | The PdfBrush that determines the color and texture of the drawn text |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page to the document.
PdfPage page = document.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Use the font installed in the machine
PdfFont font = new PdfTrueTypeFont(new Font("Arial", 14));
//Create PDF text element
PdfTextElement element = new PdfTextElement();
//Set text.
element.Text = "Hello World!!!";
//Set font.
element.Font = font;
//Set PDF brush.
element.Brush = PdfBrushes.RoyalBlue;
//Draw the text element.
element.Draw(graphics);
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Create PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics
'Use the font installed in the machine
Dim font As PdfFont = New PdfTrueTypeFont(New Font("Arial", 14))
'Create PDF text element
Dim element As New PdfTextElement()
'Set text.
element.Text = "Hello World!!!"
'Set font.
element.Font = font
'Set PDF brush.
element.Brush = PdfBrushes.RoyalBlue
'Draw the text element.
element.Draw(graphics)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
Font
Gets or sets a PdfFont that defines the text format.
Declaration
public PdfFont Font { get; set; }
Property Value
Type | Description |
---|---|
PdfFont | The PdfFont that defines the text format |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page to the document.
PdfPage page = document.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Use the font installed in the machine
PdfFont font = new PdfTrueTypeFont(new Font("Arial", 14));
//Create PDF text element
PdfTextElement element = new PdfTextElement();
//Set text.
element.Text = "Hello World!!!";
//Set font.
element.Font = font;
//Set PDF brush.
element.Brush = PdfBrushes.RoyalBlue;
//Draw the text element.
element.Draw(graphics);
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Create PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics
'Use the font installed in the machine
Dim font As PdfFont = New PdfTrueTypeFont(New Font("Arial", 14))
'Create PDF text element
Dim element As New PdfTextElement()
'Set text.
element.Text = "Hello World!!!"
'Set font.
element.Font = font
'Set PDF brush.
element.Brush = PdfBrushes.RoyalBlue
'Draw the text element.
element.Draw(graphics)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
Pen
Gets or sets a PdfPen that determines the color, width, and style of the text
Declaration
public PdfPen Pen { get; set; }
Property Value
Type | Description |
---|---|
PdfPen | The PdfPen that determines the color, width, and style of the text |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page to the document.
PdfPage page = document.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Use the font installed in the machine
PdfFont font = new PdfTrueTypeFont(new Font("Arial", 14));
//Create PDF text element
PdfTextElement element = new PdfTextElement();
//Set text.
element.Text = "Hello World!!!";
//Set font.
element.Font = font;
//Set PDF pen.
element.Pen = PdfPens.Red;
//Draw the text element.
element.Draw(graphics);
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Create PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics
'Use the font installed in the machine
Dim font As PdfFont = New PdfTrueTypeFont(New Font("Arial", 14))
'Create PDF text element
Dim element As New PdfTextElement()
'Set text.
element.Text = "Hello World!!!"
'Set font.
element.Font = font
'Set PDF pen.
element.Pen = PdfPens.Red
'Draw the text element.
element.Draw(graphics)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
StringFormat
Gets or sets the PdfStringFormat that will be used to set the string format
Declaration
public PdfStringFormat StringFormat { get; set; }
Property Value
Type | Description |
---|---|
PdfStringFormat | The PdfStringFormat used to set the string format |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page to the document.
PdfPage page = document.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Use the font installed in the machine
PdfFont font = new PdfTrueTypeFont(new Font("Arial", 14));
//Create PDF string format.
PdfStringFormat format = new PdfStringFormat();
//Set alignments.
format.Alignment = PdfTextAlignment.Center;
format.LineAlignment = PdfVerticalAlignment.Middle;
//Create PDF text element
PdfTextElement element = new PdfTextElement("Hello World!!!", font, PdfPens.Red);
//Set PDF string format.
element.StringFormat = format;
//Draw the text element.
element.Draw(page, new RectangleF(0, 0, 200, 20));
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Create PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics
'Use the font installed in the machine
Dim font As PdfFont = New PdfTrueTypeFont(New Font("Arial", 14))
'Create PDF string format.
Dim format As New PdfStringFormat()
'Set alignments.
format.Alignment = PdfTextAlignment.Center
format.LineAlignment = PdfVerticalAlignment.Middle
'Create PDF text element
Dim element As New PdfTextElement("Hello World!!!", font, PdfPens.Red)
'Draw the text element.
element.Draw(page, New RectangleF(0, 0, 200, 20))
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
Text
Gets or sets a value indicating the text that should be printed.
Declaration
public string Text { get; set; }
Property Value
Type | Description |
---|---|
System.String | The System.String to draw to the PDF |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page to the document.
PdfPage page = document.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Use the font installed in the machine
PdfFont font = new PdfTrueTypeFont(new Font("Arial", 14));
//Create PDF text element
PdfTextElement element = new PdfTextElement();
//Set text.
element.Text = "Hello World!!!";
//Set font.
element.Font = font;
//Draw the text element.
element.Draw(graphics);
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Create PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics
'Use the font installed in the machine
Dim font As PdfFont = New PdfTrueTypeFont(New Font("Arial", 14))
'Create PDF text element
Dim element As New PdfTextElement()
'Set text.
element.Text = "Hello World!!!"
'Set font.
element.Font = font
'Draw the text element.
element.Draw(graphics)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
Methods
Draw(PdfPage, PointF, PdfLayoutFormat)
Draws the text on the page in the specified location with PdfLayoutFormat. It returns the PdfTextLayoutResult which contains last page and bounds where the text element drawn.
Declaration
public PdfTextLayoutResult Draw(PdfPage page, PointF location, PdfLayoutFormat format)
Parameters
Type | Name | Description |
---|---|---|
PdfPage | page | Current page where the text should be drawn. |
System.Drawing.PointF | location | PointF structure that specifies the start location on the page. |
PdfLayoutFormat | format | The PdfLayoutFormat that represents the layout settings |
Returns
Type | Description |
---|---|
PdfTextLayoutResult | The PdfTextLayoutResult that represents the layout result of the drawn text. |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page to the document.
PdfPage page = document.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Use the font installed in the machine
PdfFont font = new PdfTrueTypeFont(new Font("Arial", 14));
//Create PDF text element
PdfTextElement element = new PdfTextElement("Hello World!!!", font, PdfBrushes.Black);
//Create layout format
PdfLayoutFormat format=new PdfLayoutFormat();
format.Layout=PdfLayoutType.Paginate;
//Draw the text with layout format
element.Draw(page, new PointF(0, 0), format);
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Create PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics
'Use the font installed in the machine
Dim font As PdfFont = New PdfTrueTypeFont(New Font("Arial", 14))
'Create PDF text element
Dim element As New PdfTextElement("Hello World!!!", font, PdfBrushes.Black)
'Create layout format
Dim format As New PdfLayoutFormat()
format.Layout = PdfLayoutType.Paginate
'Draw the text with layout format
element.Draw(page, New PointF(0, 0), format)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
Draw(PdfPage, PointF, Single, PdfLayoutFormat)
Draws the text on the page in the specified location,width and PdfLayoutFormat. It returns the PdfTextLayoutResult which contains last page and bounds where the text element drawn
Declaration
public PdfTextLayoutResult Draw(PdfPage page, PointF location, float width, PdfLayoutFormat format)
Parameters
Type | Name | Description |
---|---|---|
PdfPage | page | Current page where the text should be drawn. |
System.Drawing.PointF | location | PointF structure that specifies the start location on the page. |
System.Single | width | Width of the text bounds. |
PdfLayoutFormat | format | The PdfLayoutFormat that represents the layout settings |
Returns
Type | Description |
---|---|
PdfTextLayoutResult | The PdfTextLayoutResult that represents the layout result of the drawn text. |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page to the document.
PdfPage page = document.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Use the font installed in the machine
PdfFont font = new PdfTrueTypeFont(new Font("Arial", 14));
//Create PDF text element
PdfTextElement element = new PdfTextElement("Hello World!!!", font, PdfBrushes.Black);
//Create layout format
PdfLayoutFormat format=new PdfLayoutFormat();
format.Layout=PdfLayoutType.Paginate;
//Draw the text with layout format
element.Draw(page, new PointF(0, 0), 200, format);
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Create PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics
'Use the font installed in the machine
Dim font As PdfFont = New PdfTrueTypeFont(New Font("Arial", 14))
'Create PDF text element
Dim element As New PdfTextElement("Hello World!!!", font, PdfBrushes.Black)
'Create layout format
Dim format As New PdfLayoutFormat()
format.Layout = PdfLayoutType.Paginate
'Draw the text with layout format
element.Draw(page, New PointF(0, 0), 200, format)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
Draw(PdfPage, RectangleF, PdfLayoutFormat)
Draws the text on the page with specified layout rectangle and PdfLayoutFormat. It returns the PdfTextLayoutResult which contains last page and bounds where the text element drawn.
Declaration
public PdfTextLayoutResult Draw(PdfPage page, RectangleF layoutRectangle, PdfLayoutFormat format)
Parameters
Type | Name | Description |
---|---|---|
PdfPage | page | Current page where the text should be drawn. |
System.Drawing.RectangleF | layoutRectangle | RectangleF structure that specifies the bounds of the text. |
PdfLayoutFormat | format | The PdfLayoutFormat that represents the layout settings |
Returns
Type | Description |
---|---|
PdfTextLayoutResult | The PdfTextLayoutResult that represents the layout result of the drawn text. |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a page to the document.
PdfPage page = document.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Use the font installed in the machine
PdfFont font = new PdfTrueTypeFont(new Font("Arial", 14));
//Create PDF text element
PdfTextElement element = new PdfTextElement("Hello World!!!", font, PdfBrushes.Black);
//Create layout format
PdfLayoutFormat format=new PdfLayoutFormat();
format.Layout=PdfLayoutType.Paginate;
//Draw the text with layout format
element.Draw(page, new RectangleF(0, 0, 200, 400), format);
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Create PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics
'Use the font installed in the machine
Dim font As PdfFont = New PdfTrueTypeFont(New Font("Arial", 14))
'Create PDF text element
Dim element As New PdfTextElement("Hello World!!!", font, PdfBrushes.Black)
'Create layout format
Dim format As New PdfLayoutFormat()
format.Layout = PdfLayoutType.Paginate
'Draw the text with layout format
element.Draw(page, New RectangleF(0, 0, 200, 400), format)
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
Layout(PdfLayoutParams)
Layouts the element.
Declaration
protected override PdfLayoutResult Layout(PdfLayoutParams param)
Parameters
Type | Name | Description |
---|---|---|
PdfLayoutParams | param | Lay outing parameters. |
Returns
Type | Description |
---|---|
PdfLayoutResult | Returns lay outing results. |