How to paste a SVG image to Word from Web (the Async Clipboard API)?

Anonymous
2023-02-23T02:50:37.8566667+00:00

How to paste a SVG image to Word from Web (the Async Clipboard API)?

  • I try it like this:
const clipboardData = {};
const blobSvg = new Blob([svgText], {type:'image/svg+xml'}
try {
    console.log(clipboardData)
	await navigator.clipboard.write([
        new ClipboardItem(clipboardData),
	]);
} catch (err:any) {
	console.error(err.name, err.message);
}

Word did not accept it. Something wrong with encoding type content ofimage/svg+xml


Other info:

  • I insert svg in Word properly, then copy it, and inspect the content of image/svg+xml ,which is binary data.(with the help of web online tool)
  • So, i wonder which encoding algorithm was used to image/svg+xml in Office?

How many html elements are supported by microsoft_365?

Currently, i know that element for div,table... is supported paste to office and preserve style , by set text/html in ClipboardItem

Is there a official list for html element supported paste in office?

Office
Office
A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.
1,485 questions
0 comments No comments
{count} votes