We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When using the same image in the document, each instance of the image results in a different file inside the generated docx file.
Documents with reused images gets linearly bigger.
Minimum example:
import { Document, ImageRun, Packer, Paragraph } from "docx"; const imageBase64Data = "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAFUlEQVR42mP8z8BQz0AEYBxVSF+FABJADveWkH6oAAAAAElFTkSuQmCC"; const doc = new Document({ sections: [ { children: [ new Paragraph({ children: [ new ImageRun({ data: imageBase64Data, // image transformation: { width: 100, height: 100, }, }), ], }), new Paragraph({ children: [ new ImageRun({ data: imageBase64Data, // same image transformation: { width: 200, height: 200, }, }), ], }), ], }, ], }); Packer.toBuffer(doc).then((buffer) => { fs.writeFileSync("same_image_twice.docx", buffer); // two identical media files inside the docx });
The text was updated successfully, but these errors were encountered:
We could use the git uses for a while now, using a digest of the file as uniqueId of the image.
uniqueId
Git uses SHA1, I'll test if it work well in the ImageRun class.
Sorry, something went wrong.
Seems to work great. Adding tests to spec files in order to open a PR.
No branches or pull requests
When using the same image in the document, each instance of the image results in a different file inside the generated docx file.
Documents with reused images gets linearly bigger.
Minimum example:
The text was updated successfully, but these errors were encountered: