-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding image in Shape #144
Comments
Can you add a minimal docx template file so I can reproduce this? |
template.docx |
I've had the same issue any time I add shapes to a template, even when it doesn't have an image. |
Hmmm weird. When you press 'yes' to recover the file, does it show the document as you expect it to be rendered? |
Yes it shows the document ok, |
I have same issue, but for some shape it's work without any problem and for other it doesn't work (sometimes only moving a shape where it work's correctly to another point in the document do that it doesn't work anymore). |
I had the same issue as well, in my case the problem was that I was putting for the extension 'png' instead of '.png'. Once I put the dot in front of it, it started working. |
Interesting finding. |
I got it, docPr should be unique in whole document. I've found So, the fix would be to parse all docPr ids at the moment of template initialization, remember them and generate image ids considering already taken. Note, that internet says this error-openning happens not in all versions of Word. For me it happens in latest O365 and SharePoint/Word Online. |
Having the same error now. Also have existing images on a template and this is most likely related to that. I was wondering if it would be possible to pass your own custom id to returned image object
which would be then used in the
|
… template before rendering to ensure that image IDs are globally unique.
Should be fixed in v4.6.2. Will be published to NPM shortly. |
Hello, |
@matcobat interesting. Can you post a simple repro case? A template and your command invocation is enough. Doesnt have to be a full runnable repository. |
Sure ! Here is a very simple template that is failing. I'm using the method injectSvg() that is in the documentation : createReport({ (Just replace the Buffer.from(...) by the one that is in the documentation) And the generated document : |
Thanks a lot for this library,
I am facing a problem when i add an image in a shape
for example we have a square and in the square i add the code for the image. It works but the problem appears when we try to open the document, it says that it find unreadbale content
Word found unreadable content in "report (5).docx". Do you want to recover the contents of this document? If you trust the source of this document, click Yes.
If clicking yes it creates a new file with the content
Details for the implementation :
where the image is added
code for getting the image :
getImage:async url => { const resp = await fetch( url ); const buffer = resp.arrayBuffer ? await resp.arrayBuffer() : await resp.buffer(); return { width: 4.5, height: 4.8, data: buffer, extension: '.jpg' }; }, }
any info for this or trick to do this ?
The text was updated successfully, but these errors were encountered: