PdfTextDirection
16 Dec 20251 minute to read
Public enum to define the text direction.
// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Load the font file
let font: PdfTrueTypeFont = new PdfTrueTypeFont(read('./resources/Fonts/', 'Arial.ttf'), 10);
// Add a string format
let format: PdfStringFormat = new PdfStringFormat();
format.alignment = PdfTextAlignment.right;
format.textDirection = PdfTextDirection.rightToLeft;
// Draw a text with right to left direction
page.graphics.drawString('Hello World مرحبا بالعالم', font, {x: 10, y: 20, width: 300, height: 200}, new PdfBrush({r: 0, g: 0, b: 255}), format);
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();-
leftToRight- Specifies the type ofleftToRight. -
none- Specifies the type ofnone. -
rightToLeft- Specifies the type ofrightToLeft.