make Image horizontal docx
-
This post is deleted!
-
@bjrmatos Thank you so muchh... Its working Now.
Also one more thing how can we use if else like this
{{#if images.length === 2 }}
run this code
{{/if}}How can we check array.length is equal to 2 or not?
-
You can implement a custom handlebars helper
function arrayHasLength2(arr) { return arr.length === 2 }
The helpers for office templates are coded here
-
so how can we use it in docx?
-
@sagarxoxo you can call it like this
{{#if (arrayHasLength2 images) }} run this code {{/if}}
it is called handlebars subexpressions
-
Can you please provide an example in playground @bjrmatos @jan_blaha
-
-
arr.length cannot read properties of undefined (reading 'length')
-
that is because your data actually does not always have the
images
property, also i see that in some cases it is even not an array but a number instead, you need to update thearrayHasLength2
helper to handle whatever the conditions of your data need to be.for example, you can update it like this, to ensure that it handles non-existent
images
function arrayHasLength2(arr) { return Array.isArray(arr) && arr.length === 2 }
-
Thank you @bjrmatos you were really helpful
-
is there any way to make apply css on images docx "object-fit: cover"?
-
hi @sagarxoxo, it is not possible right now, we have options to keep the aspect ratio of image but nothing specifically the produced the same than object-fit: cover
-
is it possible to add dom on docxImage
-
@sagarxoxo since the docxImage generation (and docx generation in general) is not based on html, then the DOM does not have a meaning here. but also internally the docx is a chunk of XML files and nodes but not sure what you exactly plan to do with it. what would be the case for you to have access to the DOM (in the context of xml nodes)