@krakaw/zip-text-replace

0.0.4 • Public • Published

zip-text-replace

Unzip a file, replace text within a file and re-zip it.

let replaceDocx = new Replacer({
		input: {
			path: "./test_input.docx"
		},
		output: {
			name: "test_output.docx",
			writeFile: true
		},
		replace:{
			srcFiles: ["word/document.xml"],
			replacements: [
				{
					key: "{replace_me}",
					value: "My New Text",
					escapeKey: true
				}
			]
		}
	});
	replaceDocx.replace();

	let replacerXlsx = new Replacer({
		input: {
			path: "./test_input.xlsx"
		},
		output: {
			name: "test_output.xlsx",
			writeFile: false //Get a stream instead
		},
		replace:{
			srcFiles: ["xl/sharedStrings.xml"],
			replacements: [
				{
					key: "{replace_me}",
					value: "Another New String",
					escapeKey: true
				}
			]
		}

	});
  const stream = replacerXlsx.replace();

Readme

Keywords

none

Package Sidebar

Install

npm i @krakaw/zip-text-replace

Weekly Downloads

1

Version

0.0.4

License

ISC

Unpacked Size

5.29 kB

Total Files

5

Last publish

Collaborators

  • krakaw