I am using the PDF creator to generate a pdf file which is a "text" from Summernote textarea. All seem to be working fine except when I try to print the file and then I get the following error:
Could not parse color "var(--bs-body-bg)"
parseColor @ browser.min.js:7
(anonymous) @ browser.min.js:7
parseStyle @ browser.min.js:7
(anonymous) @ browser.min.js:7
applyStyle @ browser.min.js:7
parseElement @ browser.min.js:7
(anonymous) @ browser.min.js:7
parseElement @ browser.min.js:7
(anonymous) @ browser.min.js:7
parseElement @ browser.min.js:7
(anonymous) @ browser.min.js:7
parseElement @ browser.min.js:7
(anonymous) @ browser.min.js:7
parseElement @ browser.min.js:7
(anonymous) @ browser.min.js:7
parseElement @ browser.min.js:7
(anonymous) @ browser.min.js:7
parseElement @ browser.min.js:7
(anonymous) @ browser.min.js:7
parseElement @ browser.min.js:7
(anonymous) @ browser.min.js:7
parseElement @ browser.min.js:7
(anonymous) @ browser.min.js:7
parseElement @ browser.min.js:7
convertHtml @ browser.min.js:7
htmlToPdfMake @ browser.min.js:7
1.module.exports @ browser.min.js:7
_createContent @ pdfContent.js:105
_createPdf @ pdfCreator.js:244
download @ pdfCreator.js:89
Object.keys.forEach.data. @ BaseComponent.js:470
(anonymous) @ parser.js:727
(anonymous) @ parser.js:469
dmx.parse @ parser.js:404
(anonymous) @ on.js:14
a @ events.js:280
dispatch @ jquery-3.5.1.slim.min.js:2
v.handle @ jquery-3.5.1.slim.min.js:2Understand this errorAI
object.js:128 Uncaught (in promise) Error: unsupported number: NaN
at number (object.js:128:11)
at PDFDocument.rect (vector.js:111:36)
at Object.drawBackground (textDecorator.js:149:5)
at renderLine (printer.js:480:16)
at renderPages (printer.js:399:6)
at PdfPrinter.createPdfKitDocument (printer.js:165:2)
at pdfMake.js:128:21
And this is what I see in the console when I inspect it
<span style="background-color: var(--bs-body-bg); font-size: var(--bs-body-font-size); font-weight: var(--bs-body-font-weight); text-align: var(--bs-body-text-align);">A heterogeneous mass is seen measuring 56 x 54 cm, arising from fundus of gallbladder with resultant wall irregularity. A heterogeneous mass is seen measuring 56 x 54 cm, arising from fundus of gallbladder extending into the liver. </span>
I think this happens when I try to edit the text in the text box.
Any suggestion will be much appreiated.
@brad Thank you for your response.
The text was not copy and pasted from somewhere. I have buttons on my page which when clicked, insert the text into the editor.
This is how it is:
I have a button with an onclick function, and the function insert text into the the editor when clicked.
The error therefore is created when I try to paragraph the text or remove the spaces which create the span thereby adding the style to it
If I enter the text manually into the editor, and I add some paragraphs, or spaces and I try to clear the paragraphs or the spaces, the span get created in the code and I think is caused by the bootstrap classes.
The same way when my buttons which contains the text release the text into the editor, it'll seem fine untill i try to remove some spaces or do away with some paragraphs, then the error appears.
If i don't remove the paragraphs or spaces, the pdf creator works fine but the moment i did, then the error appears.
Before editing: <p><br></p><p>Mass like areas obliterating the gallbladder lumen with multiple internal cystic spaces suggestive of adenomyosis are noted arising from anterior wall . Focal area of thickening is seen in fundus with bright echogenic foci showing distal comet-tail artifact. Multiple cystic spaces within the adenomyoma are seen in fundus . Mass like areas obliterating the gallbladder lumen with multiple internal cystic spaces suggestive of adenomyosis are noted arising from fundus . Focal area of thickening is seen in fundus with bright echogenic foci showing distal comet-tail artifact. <br></p><p>Multiple echogenic calcific foci are seen in its walls. Multiple focal, noncontiguous, hypoechoic pockets of edema fluid within the thickened walls seen. <br></p>
After editing: <p><span style="background-color: var(--bs-body-bg); font-size: var(--bs-body-font-size); font-weight: var(--bs-body-font-weight); text-align: var(--bs-body-text-align);">Mass like areas obliterating the gallbladder lumen with multiple internal cystic spaces suggestive of adenomyosis are noted arising from anterior wall . Focal area of thickening is seen in fundus with bright echogenic foci showing distal comet-tail artifact. Multiple cystic spaces within the adenomyoma are seen in fundus . Mass like areas obliterating the gallbladder lumen with multiple internal cystic spaces suggestive of adenomyosis are noted arising from fundus . Focal area of thickening is seen in fundus with bright echogenic foci showing distal comet-tail artifact. </span><span style="background-color: var(--bs-body-bg); font-size: var(--bs-body-font-size); font-weight: var(--bs-body-font-weight); text-align: var(--bs-body-text-align);">Multiple echogenic calcific foci are seen in its walls. Multiple focal, noncontiguous, hypoechoic pockets of edema fluid within the thickened walls seen.</span></p>
I never noticed this before. I just checked my own Summernote text areas on one of my projects and it is doing the same thing. I think this is more of a Summernote Bug than a PDF Creator Bug.
okay so I want to export some text from the summernote editor to pdf.
I have buttons which contains the text so when the user clicks on it, it dynamically inserts text into the editor which have an export button on the page to export the contents into pdf.
All seems to be working until I decide to edits the text in the editor and then the error appears.
Just take this text and put it in a Summernote text area.
<p><br></p><p>Mass like areas obliterating the gallbladder lumen with multiple internal cystic spaces suggestive of adenomyosis are noted arising from anterior wall . Focal area of thickening is seen in fundus with bright echogenic foci showing distal comet-tail artifact. Multiple cystic spaces within the adenomyoma are seen in fundus . Mass like areas obliterating the gallbladder lumen with multiple internal cystic spaces suggestive of adenomyosis are noted arising from fundus . Focal area of thickening is seen in fundus with bright echogenic foci showing distal comet-tail artifact. <br></p><p>Multiple echogenic calcific foci are seen in its walls. Multiple focal, noncontiguous, hypoechoic pockets of edema fluid within the thickened walls seen. <br></p>
Then in the editor remove the first empty paragraph. Then check the code again and it has added span tags with all of the bootstrap attributes.
Unfortunately neither of the suggested fixes worked. I hope this can be resolved. I have been getting on our staff's cases for not pasting as plain text only to find out it isn't their fault.
ChatGPT offers up a couple solutions but they don't seem to be doing anything either. I may be doing something wrong. But thought I would post this here to maybe allow someone to get us on the right track.
$('#summernote').summernote({
styleWithSpan: false, // Prevents Summernote from wrapping content in span tags
});