react-pdf icon indicating copy to clipboard operation
react-pdf copied to clipboard

ncaught (in promise) abort("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 134217728,

Open ninicdennis opened this issue 6 years ago • 4 comments

Describe the bug The bug occurs when I try to map over an array filled with text that passes it into a tag. After about an array count of 45, I get the error above. Anything lower will render completely without any issues. To Reproduce There are a few issues of this that exist, that specifically rely on high page counts or data counts, none really give a proper solution. Here is my snippet for rendering:

                  finished_data.map(singleUnit => {
                    switch(true){
                      case singleUnit.title: return <Text style={styles.tags}>{singleUnit.data} {"\n\n"}</Text>;
                      case singleUnit.bold: return <Text style={{color: singleUnit.styleData.color, backgroundColor: singleUnit.styleData.bgcolor, fontFamily: 'Crimson Bold',}}>{singleUnit.data}</Text>;
                      case singleUnit.underline: return <Text style={{color: singleUnit.styleData.color, backgroundColor: singleUnit.styleData.bgcolor, fontFamily: 'Crimson Regular', textDecoration: 'underline'}}>{singleUnit.data}</Text>
                      case singleUnit.italics: return <Text style={{color: singleUnit.styleData.color, backgroundColor: singleUnit.styleData.bgcolor, fontFamily:'Crimson Italic',}}>{singleUnit.data}</Text>;
                      case singleUnit.normal: return <Text>{singleUnit.data} </Text>;
                      case singleUnit.span: return <Text style={{color: singleUnit.styleData.color, backgroundColor: singleUnit.styleData.bgcolor,fontFamily: 'Crimson Regular'}}>{singleUnit.data}</Text>;
                      case singleUnit.color: return <Text style={{color: singleUnit.styleData.color, backgroundColor: singleUnit.styleData.bgcolor, fontFamily: 'Crimson Regular'}}>{singleUnit.data}</Text>;
                      case singleUnit.underline_bold: return <Text style={{color: singleUnit.styleData.color, backgroundColor: singleUnit.styleData.bgcolor, fontFamily:'Crimson Bold', textDecoration: 'underline'}}>{singleUnit.data}</Text>;
                      case singleUnit.italic_bold: return <Text style={{color: singleUnit.styleData.color, backgroundColor: singleUnit.styleData.bgcolor, fontFamily:'Crimson Italic Bold',}}>{singleUnit.data}</Text>;
                      case singleUnit.italic_underline: return <Text style={{color: singleUnit.styleData.color, backgroundColor: singleUnit.styleData.bgcolor, fontFamily:'Crimson Italic', textDecoration: 'underline'}}>{singleUnit.data}</Text>;
                      case singleUnit.all3: return <Text style={{color: singleUnit.styleData.color, backgroundColor: singleUnit.styleData.bgcolor,fontFamily: 'Crimson Italic Bold', textDecoration: 'underline'}}> {singleUnit.data} </Text>;
                      case singleUnit.notes: return <Text style={{ fontFamily: 'Crimson Regular',}}>{'\n\n'}{singleUnit.data}</Text>;
                      case singleUnit.anchor: return <Text style={{color: singleUnit.styleData.color, backgroundColor: singleUnit.styleData.bgcolor, textDecoration: 'underline', fontFamily: 'Crimson Regular'}}> {singleUnit.data} </Text>;
                      case singleUnit.finished: return <Text>{"\n\n"}</Text>;

                    }

Expected behavior The expected result in my scenario would just be the text provided with the proper highlighting and color changes, as a bove I set the text decoration, color, and font, which can change. I use a switch statement to determine which text has what.

Screenshots For privacy, I can not give out any screenshots.

Desktop (please complete the following information):

  • OS: Fedora 31
  • Browser Firefox, Chrome
  • React-pdf version latest

ninicdennis avatar Feb 26 '20 21:02 ninicdennis

As further testing, it seems the issue actually stems on a few different things. The first is the Regex I have implemented in the statement is slowing it down. Taking this out, I am able to render on the pdf more than originally, but still not the amount I wanted. The next is font, which same deal. And lastly the tag is also causing this. Removing it all and passing all of the data without anything will render any length of data just fine.

I also have another instance where I am doing the exact same thing, with zero stlying, and can successfully render without any issue. The layout is the same, just without any sort of styling or fancy edits.

I found a person able to recreate the bug here using a .map() function, although he is able to render over 1000, which is marginally more than what I can achieve. Any help is needed, and feel free to reach out if you have any further questions.

ninicdennis avatar Feb 28 '20 17:02 ninicdennis

@pupper-bot were you ever able to come up with any solutions to your problem. I too am getting the same error as well as other users on this thread #314.

clarson1229 avatar Jul 02 '20 16:07 clarson1229

@clarson1229 , I was not able to find a solution to this problem. It came down to how many items we were rendering, plus the amount of things being changed, ergo if I was adding any sort of style, and the fonts. I have not revisited, as I found it as a lost cause. From my understanding, this is a ram limitation issue with the PDF generator. I have yet to see anyone with a solution that actually works for dynamic pdf generation with mutiple colors, font types, etc etc... Maybe I will revisit this sometime in the future and see what I can find.

ninicdennis avatar Jul 02 '20 16:07 ninicdennis

Try https://github.com/diegomura/react-pdf/issues/1063#issuecomment-749087846

Skywalker13 avatar Dec 21 '20 17:12 Skywalker13