Giter Club home page Giter Club logo

Comments (3)

Aymkdn avatar Aymkdn commented on July 25, 2024 1

I've just published v1.0.3 with <img> support .... However you have to provide a base64 encoded content for the image, as explained in the README and as demo'ed in the example.js file

from html-to-pdfmake.

Aymkdn avatar Aymkdn commented on July 25, 2024

Yes I could add it someday!

from html-to-pdfmake.

tsiegleauq avatar tsiegleauq commented on July 25, 2024

We might be able to use an URL to a image, rather than the base64 representation, if CORS let's us.

Back in OpenSlides 2(.1 I believe), we used to develop a dynamic solution for images that did not require a direct base64 string. Converting it to OpenSlides 3 is still on my roadmap, but here is how we used to do it:

  • pre-scan the HTML document for image-tags and save the sources (as seen here)
    • we imply images are an absolute URL. CORS is really a topic here, so don't expect external sources to work just fine.
    • That allows you to handle duplicated images pretty well
  • convert the whole list to base64 (as seen here)
    • The base64 string will be generated using Image-Objects and canvas, as seen here

In the end we have a list of URL-to-Base64 pairs.

{
    url-to-image1: base64-of-image1,
}

We then used that to generate the HTML document, that's more-or-less how you are already doing it already, as seen here

As you can see, this was another era of JavaScript. Using async await functions and Promise.all this code could probably be cleaned up a whole lot

from html-to-pdfmake.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.