Search Unity

Question PDF Creation in a WebGL Project

Discussion in 'Web' started by T0RED, Mar 25, 2022.

  1. T0RED

    T0RED

    Joined:
    Oct 3, 2018
    Posts:
    6
    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
     
  2. rcongdo

    rcongdo

    Joined:
    Oct 23, 2014
    Posts:
    3
    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.
     
    De-Panther and T0RED like this.
  3. T0RED

    T0RED

    Joined:
    Oct 3, 2018
    Posts:
    6
    Thank you very much! Your Solution works and also when its not very elegant, its fine for me for now :)
     
  4. QasimJUD

    QasimJUD

    Joined:
    Apr 18, 2022
    Posts:
    3
    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.
     
  5. james_sg

    james_sg

    Joined:
    Jun 30, 2020
    Posts:
    11
    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 :)