Hopding / react-native-pdf-lib

Library for creating and editing PDFs in React Native.
https://www.npmjs.com/package/react-native-pdf-lib
188 stars 75 forks source link

adding 5+ pages crashes the app #46

Open tepho opened 5 years ago

tepho commented 5 years ago

i played a little with the example given, them when i increased the number of pages to 5, it completely crashed the app

works

ghost commented 5 years ago

Same problem here (on Android only, iOS is fine). I think it is related to the number of text boxes drawn instead of the pages added. Memory usage of the PDF generator seems to be proportional to the number of drawText() calls. Creating a single-page PDF file with 66 lines where each line is ~75 characters long caused the app's memory usage to increase from ~75 mb (before write() method is called) to ~330 mb.

Another thing that caught my attention is that the output file is ~1.2 mb, which I thought was kind of high considering this is only a single-page text file.

appa3151 commented 4 years ago

same issue come...

thekevinbrown commented 4 years ago

We've worked around this for the time being by creating every page as a separate PDF, then stitching them together at the end.

We first noticed a memory problem on iOS actually, so note that if you put enough content in it'll face similar issues. I imagine that PRs would be welcome to solve this, but I'm not the maintainer, so can't say for sure.

tioluwani94 commented 3 years ago

We've worked around this for the time being by creating every page as a separate PDF, then stitching them together at the end.

We first noticed a memory problem on iOS actually, so note that if you put enough content in it'll face similar issues. I imagine that PRs would be welcome to solve this, but I'm not the maintainer, so can't say for sure.

Hi @thekevinbrown how do you go about stitching the separate PDFs created together at the end?

thekevinbrown commented 3 years ago

I created a native module which uses com.tom_roush.pdfbox.multipdf.PDFMergerUtility on Android, and Core Graphics on iOS.