An idea for editing existing documents

117 views
Skip to first unread message

Ziv Barber

unread,
Oct 6, 2017, 4:13:03 AM10/6/17
to node.js officegen package
 Hi everyone,

I'm thinking about a solution to allow editing existing office files.

For most cases you need it for one of the following:

1. You want to create a document with your own template/theme.
2. You want to add additional content, like additional slides to existing PowerPoint file.

The high layer parsing is simple:

- Extract the document file.
- For each resource save it somewhere depend on the type of it. Officegen already has internal lists for images to include, slides, etc.

About parsing the xml files:

We don't need to do a complete parsing of all the files.
The first version can only locate references to other resources so we can re-build a new document and it'll work even if the reference numbers been changed or you change a media file, etc.
Then we can mark locations inside the xml file so for example, you can add additional content to existing slide.
Then we can mark template fields, etc.

So, for example, for existing slide that we are adding content:

The officegen method to create the output file will work the same but it'll see an instruction to add a block of xml code (the old slide's code) + place holders to patch the old code, instead of just instructions to create elements inside the slide:

Example:

Normal slide creating:

- make new p element
- make new p element
- make new p element
...

Same with existing slide:

- make new p element
- insert xml code (+ optional place holders data)
- make new p element
...


Reply all
Reply to author
Forward
0 new messages