Printing dash via selenium display unexpectedly

Hi all,

I am using selenium to print my dash app. I push the dash app to windows server, and the printed pdf looks unexpectedly then when I was running it on local.

What I got from local -

What I got from windows server -

Any ideas how to fix this issue when printing?

Thank you,

Hi Erica,

I am trying to achieve the same functionality of printing a dash app as a PDF. Would you have sample code for the above mentioned example? Thanks in advance.


Hi Neerej,

In order to do that, you will need to add the following to your css to hide the toolbar -

.modebar {
display: none !important;

Hope this help!


Hi Erica,

Thanks a lot for the quick response.
I was actually looking to get the python function itself which was used to generate the PDF. My page is primarily constructed as ‘Children’ of an html Div via a call back function. Not sure how to convert the contents of this html div component into PDF.

Thanks for sharing the css to hide the toolbars - will come handy once the PDF generation part is sorted.

Thank you,

Hi Erica,

I got what I was looking for. I used html2canvas.js to achieve exporting dash page as a PDF.

Copying the custom JS script that I used here below for the benefit of any one who might be looking for a solution:

$(document).ready(function () {

$(document).on('click','#downloadpdf', function() {   

    var imgData;
            html2canvas($("#fqcerrorreportoutputsection"), {
                useCORS: false,
                onrendered: function (canvas) {
                    imgData = canvas.toDataURL(
  				if ($(document).width() > $(document).height()) {
  				var doc = new jsPDF('l', 'mm', [$(document).width(), $(document).height()]); //
  				else {
  				var doc = new jsPDF('p', 'mm', [$(document).height(), $(document).width()]); //
  				doc.addImage(imgData, 'JPEG', 0, 0, $(document).width(), $(document).height());
                    // doc.addImage(imgData, 'PNG', 20, 20);


Thanks and Regards,

1 Like