Mike's Notes
OfficeParser is a great open-source tool by Harsk Ankur for office documents. I found this gem through Ray Camden's blog newsletter.
Harsk's blog is detailed and useful for understanding different file formats and how to convert between them.
Could be useful in the future for Pipi-generated docs.
Resources
- https://www.raymondcamden.com/2026/10/17/generating-pdfs-from-word-templates-with-officeparser
- https://officeparser.harshankur.com/
- https://harshankur.com/
- https://github.com/harshankur/officeParser
- https://developer.adobe.com/document-services/docs/overview/document-generation-api/
- https://officeparser.harshankur.com/#spec/template
- https://www.docugenerate.com/
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl
- https://officeparser.harshankur.com/blog/
References
- Reference
Repository
- Home > Ajabbi Research > Library > Subscriptions > RaymondCamden.com
- Home > Handbook >
Last Updated
20/10/2026
OfficeParser
Raymond Camden: My name is Raymond Camden. I'm a married father of eight living in beautiful Lafayette, Louisiana. I'm a developer evangelist/advocate looking for my next role. Most of my time is spent writing, researching, or presenting. When I'm not behind a computer, I'm an avid Xbox/Playstation player, enjoy movies, and read like crazy.
...
I've been singing the praises of the officeParser library for a while. It's an open source JavaScript library that can parse, extract, and convert between PDFs and Office documents, as well as OpenOffice, ePub and more. My demos have all focused on client-side examples but obviously the library would work great in a server side workflow as well. I haven't worked at Adobe for years now, but I still get strangely excited working with documents. I'll just add that to the long list of reasons I'm a big nerd.
A few weeks ago, I reached out to Harsh Ankur about an idea inspired by Adobe's Document Generation API. This was probably my favorite API in their suite of PDF services. You take a Word document, put in tokens, and call the API with your data. The API would swap out the tokens with real data and give you a PDF in return. (Or Word again if you wanted that.) I suggested this to Harsh and then - voila - he added it!
At this time, the token system is simply a replacement system. You add My name is in your Word document, and if you pass { "name":"Juniper Montage"} via the library's APIs you'll get My name is Juniper Montage on the way out.
This new support is a core API, OfficeTemplate, and supports both replacing values from a regular JavaScript object or returning an array of results from a JavaScript array of objects. (Which, by the way, is something I was trying to get Adobe to add to their APIs. One of their competitors, DocuGenerate, has had this for a while.)
Here's how simple it is to use. First, create and save a Word document. Formatting doesn't matter - make it as pretty or simple as you would like. Here's an example with a few tokens:
Customer Report for {{
customerName}}
On {{ date }}, the customer {{ customerName }} currently has {{ productsTotal
}} in the market. Their gross profit for the year {{ reportYear }} was {{ profit }}
with losses of {{ losses }}.
Our recommendation: {{ recommendation }}
Report created by {{ reporter }}.
Imagine this is stored as customerReport.docx. To turn this into a PDF, you would first import the relevant libraries (in the sample below I'm using an npm installed version, not CDN):
import { OfficeConverter, OfficeTemplate } from 'officeparser/browser-native-pdf'
Then - grab the Word document as binary data:
const template = new Uint8Array(await response.arrayBuffer())
Get some sample data:
customerName: 'Northwind & Co',
date: '2026-10-16',
productsTotal: 7,
reportYear: 2026,
profit: 2500,
losses: 125,
recommendation: 'Continue growing. Duh',
reporter: 'Juniper Montage',
}
Next, use the library to convert the template:
const docx = await OfficeTemplate.render(template, { data })
Finally, turn the rendered document into a PDF. The result's value is the PDF's binary data:
generatorConfig: { pdfConfig: { engine: 'native' } },
})
At this point you can do whatever, like open it in a new tab:
window.open(URL.createObjectURL(pdf), '_blank')
As a note, this requires an additional package, only in the browser, pdf-lib.
A Real Demo
To show this in action, I built a simple demo that lets you fill in a form, and get the result as a PDF.
The entry form
This form is tied to a bit of JavaScript that grabs the values, makes use of Intl to format dates, numbers, and currencies, and then uses officeParser to create a dynamic PDF from your values. Here's an example:
Customer Report for Foo Bar Products
On October 22, 2026, the customer Foo Bar Products currently has 390,189 in the market. Their gross profit for the year 2026 was $9,100,000.00 with losses of $300,000.00.
Our recommendation: They should keep working on their stuff. And things.
Report created by Juniper Montage.
Try this yourself here:
You can find the complete source for this here:
As I mentioned above, currently the token system is relatively simple, but I've been talking with Harsh about some improvements that I bet will land pretty soon. Let me know what you think!

No comments:
Post a Comment