Git Product home page Git Product logo

Comments (3)

MattCrum1 avatar MattCrum1 commented on June 9, 2024 1

Ended up getting it to work by sending the $host.image to a function, which sends it straight back again - will keep that, unless there's a way to read $host.image within the IMAGE tag directly:

+++IMAGE getImageObject($host.image) +++

additionalJsContext: { getImageObject: base64data => { const data = base64data; return { width: 8.8, height: 3, data, extension: '.png' }; },

from docx-templates.

jjhbw avatar jjhbw commented on June 9, 2024

If that is the exact error string you're getting, it may have something to do with string literal quoting used, as the 'command' featured in the error message lacks the data:image/png;base64, substring.

Regardless, injecting images like this is not supported, so even if it works I wouldn't count on it working in the future.

If you really want to go this way, you can try is using anonymous function that returns your object, e.g. IMAGE ()=> { width: 6, height: 6, "data:image/png;base64,$host.image", extension: '.png' }, taking special care to get the literal quoting correct. I'm not sure from the top of my head whether this will work, but worth a try.

from docx-templates.

MattCrum1 avatar MattCrum1 commented on June 9, 2024

Thanks @jjhbw - I've set the object value in the JSON array to the correct format - "host.image" value now looks like this:

{ width: 6, height: 6, extension: '.png', data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlUAAAC2CAIAAAB... }

Tried then injecting it like this in the template, but it doesn't seem to like it:

+++IMAGE $host.image +++

Error is ""Error: Error executing command 'IMAGE $host.image': invalid image width: undefined (in cm)"" - which suggests that it is not able to read $host.image?

It shows up fine in an "INS" tag - perhaps it's reading it in as a string rather than an object? Thanks for your patience - not fluent in JS (as may be obvious).

from docx-templates.

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.