How to Create a PDF document with Embedded Fonts and Images in Deno Using PDF-LIB Library Full Tutorial With Example

 

Welcome folks today in this blog post we will be looking at how to embed fonts and images inside pdf documents using deno and pdf-lib library. All the example source code will be given below.

 

 

Requirements

 

 

For this you want Deno to be installed on your system.

 

 

 

Get Started

 

 

Now to get started you need to create a app.ts file inside your root directory and copy paste the following code which is shown below.

 

 

app.ts

 

 

 

 

 

 

Now if you execute this script by deno you need to execute the below command

 

deno run --allow-write --allow-net app.ts

 

So in this command we have used two flags

 

--allow-write flag is required to grant write permissions to deno to create a pdf file inside the system

 

--allow-net flag is required to grant internet permission to deno so that it can download external fonts and images

 

Now if you execute this script by the above command you will see a fancy.pdf will be created inside the root directory

 

 

 

 

 

Now if you open this fancy.pdf file you will see the following result

 

 

 

 

 

Leave a Reply