Cordova print plugin extra page on landscape printing

Hi,
I’m trying to print a screenshot of the APP using Cordova Print Plugin with this method:

Note that I added 1px red border to see div’s limits.

    /**
     * printScreenShot method (simplified version)
     * This method prints current app view.
     */
    printScreenShot() {
        // Capture image using cordova screenshot plugin
        navigator.screenshot.save(
            function(error,res) {
                if(error) {
                    // Show error
                    let alert = Alert.create({
                        title: 'Error',
                        subTitle: 'Screenshot',
                        message: 'Some error occurred while trying to make screenshot',
                        buttons: ['OK']
                    });
                    this.nav.present(alert);
                } else {
                    // Define HTML content
                    let fileContent:string = [
                        '<div style="width:100%; height: 100%; border: 1px solid red;">',
                        '   <img style="height: 90%;" src="'+res.filePath+'" />',
                        '</div>'
                    ].join('');

                    // FIXME: Print captured image
                    cordova.plugins.printer.print(fileContent, {
                        name:'capture.html',
                        landscape: true
                    });
                }
            },
            'jpg', // screenshot format
            95     // screenshot quality
        );
    }

It works well but always appears a second page to the print preview (see image):

Anyone is facing this same issue? How can I remove this second page?

PD: This error does not occur if I set the landscape parameter to false.
PD2: Sorry for my bad english.

Thanks in advance !

1 Like

Can you elaborate ,hopw to implement Print/connect printer in ionic 2… Any link will be helpful

Is printer plugin is available for ionic 2. Can you share the examples source link will be helpful

Im having the same problem did you ever find a fix?

Using example from ionic 2 docs when landscape is set to true I get an empty page after each page.