Print button, how do I remove blank pages?

Print button, how do I remove blank pages?

cris19ncris19n Posts: 55Questions: 18Answers: 0

I am using print buttons, same for PDF printing.
I have headers that use colspan and it was the only way I could find to customize the headers, but I have a problem:
shows 1 or more blank pages, how can I prevent it from displaying blank pages?

Replies

  • kthorngrenkthorngren Posts: 20,145Questions: 26Answers: 4,736

    The only we will be able to help is to see a test case with your custom code.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • cris19ncris19n Posts: 55Questions: 18Answers: 0
    edited August 2020
  • tangerinetangerine Posts: 3,342Questions: 35Answers: 394

    As Kevin said, The only way we will be able to help is to see a test case with your custom code.

  • kthorngrenkthorngren Posts: 20,145Questions: 26Answers: 4,736

    Interesting, when I print with the print example I get just 3 pages with white space at the end. I'm using Chrome on a Mac. Maybe there is a difference with using Windows.

    @colin or @allan may be able to try with a Windows version of Chrome (looks like thats what you are using).

    Kevin

  • colincolin Posts: 15,118Questions: 1Answers: 2,583

    Yep, I'm the same as Kevin, I've tried Firefox and Chrome on Windows and Ubuntu and both are showing that as three pages. Can you try that again in Private Browsing mode in case an extension is affecting this.

    If not, please can you give as much details as possible here. What's your OS, browser, are you filtering, doing something else that could affect this?

    Colin

  • cris19ncris19n Posts: 55Questions: 18Answers: 0

    @colin in private browsing mode I get the same result.
    The operating system uses windows 10, the latest version of chrome, as you can see in the photos I have my own custom filter, it filters by year, user type and user

  • colincolin Posts: 15,118Questions: 1Answers: 2,583

    Yep, I was using those too. Please could you provide a link, with step-by-step instructions on how to reproduce this, so we can see it doing the same.

    Colin

  • cris19ncris19n Posts: 55Questions: 18Answers: 0

    for some reason, when changing the setting you indicate with arrows the blank sheet also disappears, it shouldn't be the best default option but it works.

    I decided to remove this option from my project because it has problems on mobile phones. I found a very cool plugin that works as expected with data tables.

    link of the plugins to export to pdf: https://github.com/simonbengtsson/jsPDF-AutoTable/releases/tag/v3.5.9

    other export options: https://bootstrap-table.com/docs/extensions/export/

  • kthorngrenkthorngren Posts: 20,145Questions: 26Answers: 4,736

    Sounds like you have a different solution but if you want to export the PDF in landscape you need to set the orientation. This example shows how.

    Kevin

  • igor_moreiraigor_moreira Posts: 1Questions: 0Answers: 0

    I haved the same problem, my solution was add title in description :
    extend: 'print',
    text: 'Print',
    ---> title: "Relátorio",
    messageTop: data,
    exportOptions:
    {
    columns: [':visible']
    },
    Case you added, try remove !

  • arfreelancearfreelance Posts: 1Questions: 0Answers: 0

    Remove the height and min-height properties from the body element. These properties are necessary for screen display, but are what cause problems in printing. With the customize function it can be done.

    {
        extend: "print",
        customize: (win) => {
            $(win.document.body)
                .css("height", "auto")
                .css("min-height", "0");
        }
    }
    
  • allanallan Posts: 61,451Questions: 1Answers: 10,055 Site admin

    That's interesting. Thanks for posting that. The print document doesn't have any height assigned to it, so I'm not sure why that fixes it, but if it does it might be a Chrome specific error. I'd be interested to know if anyone else encounters this and we could just apply that fix directly in the Buttons print code.

    Allan

Sign In or Register to comment.