1 year ago

#364634

test-img

dark wick

How to create pdf from huge dataset of mongodb data about 10million data rows

I want to create pdf from huge dataset of mongodb. (about 10million rows) No specific format of data. you can assume employee database Iam using MEAN stack(open to new tech if applicable)

Approches tried:

  1. Use nodejs lib. like pdfkit to convert mongodb result (arr of obj) to pdf by doing a for loop in result. (it causes heap out of storage issue + very slow)
  2. Create temporary collection -> do a mongoexport to csv -> csv to html using awk -> html to pdf using wkhtmltopdf tool. (this still is very slow)

After i do mongo query -> i cannot store this data in some variable because it will cause heap out of storage issue, so i cannot do any further processing on this data. I can query using limit and skip to get data in chunks and create html and then pdf from it. but it seems very slow process.

Possible approach i think could be to create small pdfs and then merge them together, or by using streams.

What is the most efficient way to create pdf from huge datasets?

node.js

mongodb

pdf

pdfkit

node-pdfkit

0 Answers

Your Answer

Accepted video resources