android phonegap plugin for printing with send2printer
I made a simple example using the android plugin for printplugin Here the
plugin:
https://github.com/EionRobb/phonegap-print-plugins/tree/master/Android
My code is:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Prueba de Impresion</title>
<link href="jquery-mobile/jquery.mobile-1.0a3.min.css" rel="stylesheet"
type="text/css">
<script src="jquery-mobile/jquery-1.5.min.js"
type="text/javascript"></script>
<script src="jquery-mobile/jquery.mobile-1.0a3.min.js"
type="text/javascript"></script>
<script src="phonegap.js" type="text/javascript"></script>
<script src="printplugin.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
function imprime(){
var html = document.getElementById("printHTML").innerHTML;
window.plugins.printPlugin.print(html,
function(result) {
alert("print ok");
},
function(result) {
if (!result.available){
alert("no printing available");
}
else{
//Localised error description
alert(result.error);
}
}
);
}
</script>
<div data-role="page" id="page">
<div data-role="header">
<h1>Prueba de Impresion</h1>
</div>
<div data-role="content">
<button data-icon="gear" onClick="imprime();">Imprimir</button>
Contenido</div>
<div id="printHTML">
<div style="color: red;">
<p>Either the well was very deep, or she fell very slowly,
for she had plenty of time as she went down to look about
her and to wonder what was going to happen next. First, she
tried to look down and make out what she was coming to, but
it was too dark to see anything; then she looked at the
sides of the well, and noticed that they were filled with
cupboards and book-shelves; here and there she saw maps and
pictures hung upon pegs. She took down a jar from one of
the shelves as she passed; it was labelled 'ORANGE
MARMALADE', but to her great disappointment it was empty:
she did not like to drop the jar for fear of killing
somebody, so managed to put it into one of the cupboards as
she fell past it.</p>
</div>
<div style="color: green; page-break-before:always;">
<p>In the Propontis, as far as I can learn, none of that
peculiar substance called BRIT is to be found, the aliment
of the right whale. But I have every reason to believe that
the food of the sperm whale—squid or
cuttle-fish—lurks at the bottom of that sea, because
large creatures, but by no means the largest of that sort,
have been found at its surface. If, then, you properly put
these statements together, and reason upon them a bit, you
will clearly perceive that, according to all human
reasoning, Procopius's sea-monster, that for half a century
stove the ships of a Roman Emperor, must in all probability
have been a sperm whale.</p>
</div>
<div style="color: blue; page-break-before:always;">
<p>They were not their families, nor their wives, nor their
servants; the relationship was peculiar, and so unlike
anything known to us that it is most difficult to describe.
All property among the green Martians is owned in common by
the community, except the personal weapons, ornaments and
sleeping silks and furs of the individuals. These alone can
one claim undisputed right to, nor may he accumulate more of
these than are required for his actual needs. The surplus
he holds merely as custodian, and it is passed on to the
younger members of the community as necessity demands.</p>
</div>
</div>
<div data-role="footer">
<h4>Pie</h4>
</div>
</div>
</body>
</html>
the application runs and displays the message: no printing available, and
in logcat I see the following message: Error: Status=undefined
Message=Class not found at file:///android_asset/www/phonegap.js:473
I have installed 1.4.4 send2printer
if someone could tell me I'm doing wrong Thanks to all in advance
No comments:
Post a Comment