ramon
February 23, 2016, 8:34am
1
Hello everyone,
I want to install cordova print plugin to my ionic 2 typescript project, so i run:
ionic plugin add https://github.com/katzer/cordova-plugin-printer.git
After plugin installation I run…
ionic build ios
and it appears this build error:
Everything was OK before install this plugin.
My system information:
Cordova CLI: 6.0.0
Gulp version: CLI version 1.2.0
Gulp local: Local version 3.9.1
Ionic Version: 2.0.0-alpha.57
Ionic CLI Version: 2.0.0-beta.17
Ionic App Lib Version: 2.0.0-beta.8
ios-deploy version: 1.8.5
ios-sim version: 5.0.6
OS: Mac OS X El Capitan
Node Version: v4.2.6
Xcode version: Xcode 7.2.1 Build version 7C1002
Anyone is facing same issue?
What can I do?
Thanks
Here is a pull request that fixes this issue. No one seems to be managing the pull requests so it is not in the master branch yet. You can manually copy the code though.
1 Like
ramon
June 14, 2016, 10:47am
3
Thanks @zakton5 !
This update worked for me.
ramon
June 14, 2016, 1:52pm
4
Now, I’m trying to print a screenshot of the APP with this code:
/**
* 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 2nd page to the print preview:
Anyone is experiencing this same issue? @zakton5 , how can I remove this second page?
Related topic
No problem.
To your other problem, yes, I see that all the time. Selecting a printer usually fixes that problem for me. I’m not sure exactly why it creates an additional page beforehand though.