GithubHelp home page GithubHelp logo

Comments (6)

anti-the-social avatar anti-the-social commented on June 3, 2024

Have you tried to push img as a child to paragraph?

from docx.

msnyder-wayside avatar msnyder-wayside commented on June 3, 2024

Still an issue, I've verified the arrayBuffer is correct for the uploaded file, but nothing ends up in the final document. Can anyone shed light on what I'm missing here?

const imageResponse = await fetch(item.url!)
const imageArrayBuffer = await imageResponse.arrayBuffer()
const imageParagraph = new Paragraph({
	spacing: {
		after: 150,
	},
	children: [
		new ImageRun({
			data: imageArrayBuffer,
			transformation: {
				width: 100,
				height: 100,
			}
		}),
	],
})

docSectionChildren.push(imageParagraph) // from here they're added to the document section. All of that is working for everything else.

from docx.

kalda341 avatar kalda341 commented on June 3, 2024

ImageRun now requires the mimetype (eg. 'image/png') to be specified undertype property. FWIW this library is much easier to use with Typescript.

from docx.

msnyder-wayside avatar msnyder-wayside commented on June 3, 2024

ImageRun now requires the mimetype (eg. 'image/png') to be specified undertype property. FWIW this library is much easier to use with Typescript.

I'm using TypeScript, but the IImageOptions interface doesn't have a type property:

export interface IImageOptions {
    readonly data: Buffer | string | Uint8Array | ArrayBuffer;
    readonly transformation: IMediaTransformation;
    readonly floating?: IFloating;
    readonly altText?: DocPropertiesOptions;
    readonly outline?: OutlineOptions;
}

But I see this in GitHub: https://github.com/dolanmiu/docx/blob/master/src/file/paragraph/run/image-run.ts where there is a type property. Also, I'm using the current release (8.5.0). Any ideas?

from docx.

msnyder-wayside avatar msnyder-wayside commented on June 3, 2024

I also tried pulling down the repo and using a freshly built version. IImageOptions is updated to have the image type which is good, but it still isn't rendering images.

from docx.

kalda341 avatar kalda341 commented on June 3, 2024

You're right - I forgot that I'm running a fork off of master.
I've always supplied a Blob to IImageOptions (even though it's not in the supported type) - might be worth a try?

from docx.

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.