PDF Creation in a WebGL Project

Hello all,
I have the following problem:
I want to build a WebGL application and I have images in the form of byte arrays in my application. I would like to merge these images into a PDF file (In what form, the PDF should look like doesn’t matter for now).

As a solution I thought that I can simply use the library MigraDoc. Since the project is a WebGL application, MigraDoc does not work, respectively the PDF rendering of MigraDoc does not work.

Does anyone have an alternative idea how to get the images into a PDF in my WebGL application?

Best regards and many thanks already
Tobi

A hacked together way we allowed for pdf exports on our WebGL app was to have a .jslib file that generates the information we wanted (text and images) onto the webpage below the unity container. That information was encapsulated in an HTML element and then we generate a “Print” button that will use the browser’s print dialogue to print only that element. Not elegant in the least, but does what we need it to do.

2 Likes

Thank you very much! Your Solution works and also when its not very elegant, its fine for me for now :slight_smile:

Hi there, I have an issue which I don’t know where to start to solve
I have to make PDF data file using unity c# in webGL build I already done this with HTML but is there any way I can do this with unity c#
thanks in advance
Qasim.

Any chance you could explain the workflow? I’ve tried to add the jslib file and use a .cs script to run it but I get javascript errors in chrome when i try to run it. ^

Do i also need to edit the index.html to call the jslib function?

Many thanks :slight_smile:

1 Like