Right To Left Text Rendering
UniPDF support rendering text that use right to left direction just like regular left to right text. This guides will show you how to render hebrew text as an example.
Before you begin
You should get your API key from your UniCloud account.
If this is your first time using UniPDF SDK, follow this guide to set up a local development environment.
Clone the project repository
In your terminal, clone the examples repository. It contains the Go code we will be using for this guide.
git clone https://github.com/unidoc/unipdf-examples.git
Navigate to the hebrew-text
folder in the unipdf-examples directory.
cd unipdf-examples/hebrew-text
How it works
Lines 9-15
import the UniPDF packages and other required dependencies.
The init function in lines 17-24
authenticates your request with your UNIDOC_LICENSE_API_KEY
.
Lines 26-58
define main function which contains line that loads TTF font file (line 27
) that support hebrew text.
In line 35-38
we could just create a Styled Paragraph using a hebrew text and set the font to use the one we loaded at line 27
. This is similar to how we create regular Styled Paragraph.
Run the code
Run this command to see the result. This will also get all the required dependencies to run the program.
go run pdf_write_hebrew.go
Sample output
Open the output PDF with a PDF viewer and you will see the texts rendered correctly.