I'm working with the KendoQRCode Widget that is working fine! I'm also using the exportPDF/SVG/Image functions that all do a great job!
Now I would like to send several created QRCodes (defined in KendoQRCode Widgets) to a single PDF file, so the user can print them all by one PDF file (see attachment). I don't know if that is possible at all so I tried several things. The closest I came to do that:
The exportImage function does not throw an error but the QRCode is not in the generated PDF file. Using the function exportSVG throws an error: "TypeError: e.transform is not a function. (In 'e.transform()', 'e.transform' is undefined)".
So I wonder how do I send several QRCodes coming from the KendoQRCode Widget(s) into a single PDF file (if possible)? The KendoQRCode Widgets are all displayed in the page and therefore programmatically accessible.
5 Answers, 1 is accepted
You could export a wrapper element similar to this demo. The other option that I can suggest is to get the export groups of the separate QR codes again with the drawDOM method and export a common parent. You will need to manually position the elements in this case - example.
Excellent, thank you, Daniel! The keyword was 'drawDOM'. In my project I wanted to build all QRCodes in background but, based on documentation, I realised they have to be visible and in a HTML container (DIV) to export them all. It works!
I now struggle with the page size and border. I have set it that way:
The weird thing now: Even though I have defined the paper size (A4) and the margins the exported PDF looks 1:1 as they are presented in the #dummydiv: 3 lines of QRCodes, cut off on the right side of the PDF file. See therefore the attachment:
- all_qrcodes.png : Shows all the QRCodes in the dummydiv inside the Browser
- cut_off_in_pdf.png : Shows the right side of the PDF-exported dummydiv (cut off at margin-right)
I would have guessed the kendo.drawing.exportPDF function would consider the page size and margins but it doesn't. To check this out I made the Browser window smaller so that there are 4 QRCodes on each line. Exporting this shows then also 4 QRCodes in the exported PDF file.
It would work if I set a hardcoded dummydiv length to the official A4 length (minus set margins) but then I'm loosing any dynamic (like changing the paperSize or landscape/portrait). So the question is: Should the kendo.drawing.exportPDF function care/consider set pageSize and margin or do I have to do this programmatically?
Furthermore I realised that no second PDF page will be created for the left QRCodes. They are just not showing/displayed in the exported PDF (kinda cut off at the bottom). I assume this is also related to the overall problem.
I have created a fully working demo showing you the effect the format (A4) and margins will be ignored. Just press the "Export Dom" button to export the QRCodes. There is also a side effect having the QRCode size of 120 with more than 223 chars. I have commented that inside the code:
You should pass the paperSize and margin to the drawDOM options in order for the automatic page breaking to work - updated example.
As for the issue with the longer values - the size of the modules is determined so that it is whole pixels so depending on the size of the encoded data, it may not always be possible to fill the entire available space. For longer values, I would suggest to increase the size.
Excellent support, that solved the problem, thank you!
As you said I increased the size and the QRCode was filling the whole space. Works that way as well, perfect!