/ PDF / PdfTextDirection
Search results

PdfTextDirection API in JavaScript PDF API control

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, [10, 20, 300, 200], undefined, new PdfBrush([0, 0, 255]), format);
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();
  • leftToRight - Specifies the type of leftToRight.
  • none - Specifies the type of none.
  • rightToLeft - Specifies the type of rightToLeft.