/modules/phreedom/includes/jzebra/sample.html

http://phreedom.googlecode.com/ · HTML · 677 lines · 576 code · 101 blank · 0 comment · 0 complexity · baefc8af592d30c73a7b8e97f50bad2c MD5 · raw file

  1. <html>
  2. <head><title>jZebra Demo</title>
  3. <script type="text/javascript">
  4. function findPrinter() {
  5. var applet = document.jzebra;
  6. if (applet != null) {
  7. // Searches for locally installed printer with "zebra" in the name
  8. applet.findPrinter("zebra");
  9. }
  10. // *Note: monitorFinding() still works but is too complicated and
  11. // outdated. Instead create a JavaScript function called
  12. // "jzebraDoneFinding()" and handle your next steps there.
  13. monitorFinding();
  14. }
  15. function findPrinters() {
  16. var applet = document.jzebra;
  17. if (applet != null) {
  18. // Searches for locally installed printer with "zebra" in the name
  19. applet.findPrinter("\\{dummy printer name for listing\\}");
  20. }
  21. monitorFinding2();
  22. }
  23. function print() {
  24. var applet = document.jzebra;
  25. if (applet != null) {
  26. // Send characters/raw commands to applet using "append"
  27. // Hint: Carriage Return = \r, New Line = \n, Escape Double Quotes= \"
  28. applet.append("A590,1600,2,3,1,1,N,\"jZebra " + applet.getVersion() + " sample.html\"\n");
  29. applet.append("A590,1570,2,3,1,1,N,\"Testing the print() function\"\n");
  30. applet.append("P1\n");
  31. // Send characters/raw commands to printer
  32. applet.print();
  33. }
  34. // *Note: monitorPrinting() still works but is too complicated and
  35. // outdated. Instead create a JavaScript function called
  36. // "jzebraDonePrinting()" and handle your next steps there.
  37. monitorPrinting();
  38. /**
  39. * PHP PRINTING:
  40. * // Uses the php `"echo"` function in conjunction with jZebra `"append"` function
  41. * // This assumes you have already assigned a value to `"$commands"` with php
  42. * document.jZebra.append(<?php echo $commands; ?>);
  43. */
  44. /**
  45. * SPECIAL ASCII ENCODING
  46. * //applet.setEncoding("UTF-8");
  47. * applet.setEncoding("Cp1252");
  48. * applet.append("\xDA");
  49. * applet.append(String.fromCharCode(218));
  50. * applet.append(chr(218));
  51. */
  52. }
  53. function printZPLImage() {
  54. var applet = document.jzebra;
  55. if (applet != null) {
  56. // Sample text
  57. applet.append("^XA\n");
  58. applet.append("^FO50,50^ADN,36,20^FDPRINTED USING JZEBRA " + applet.getVersion() + "\n");
  59. // *Note; As of 2/14/2012, Raw image printing is only supported in
  60. // ZPLII and ESCP modes, and is an experimental feature.
  61. //
  62. // A second parameter MUST be specified to "appendImage()", for
  63. // jZebra to use raw image printing. If this is not supplied, jZebra
  64. // will send PostScript data to your raw printer! This is bad!
  65. // - Make sure image width and image height are divisible by 8.
  66. // - ESCP image widths should be EXACTLY the pixel width of the
  67. // printer according to the ESCP printing guidelines
  68. // - ESCP support uses the "ESC V" method. If "ESC ." is needed
  69. // contact the mailing list.
  70. // - The applet will append the special raw markup:
  71. // i.e. ^GFA, char(27), etc.
  72. // applet.appendImage("logo.png", "ESCP");
  73. applet.appendImage(getPath() + "img/image_sample_bw.png", "ZPLII");
  74. while (!applet.isDoneAppending()) {
  75. // Note, enless while loops are bad practice.
  76. // Create a JavaScript function called "jzebraDoneAppending()"
  77. // instead and handle your next steps there.
  78. }
  79. // Finish printing
  80. applet.append("^FS\n");
  81. applet.append("^XZ\n");
  82. // Send characters/raw commands to printer
  83. applet.print();
  84. }
  85. // *Note: monitorPrinting() still works but is too complicated and
  86. // outdated. Instead create a JavaScript function called
  87. // "jzebraDonePrinting()" and handle your next steps there.
  88. monitorPrinting();
  89. }
  90. function print64() {
  91. var applet = document.jzebra;
  92. if (applet != null) {
  93. // Use jZebra's `"append64"` function. This will automatically convert provided
  94. // base64 encoded text into ascii/bytes, etc.
  95. applet.append64("QTU5MCwxNjAwLDIsMywxLDEsTiwialplYnJhIHNhbXBsZS5odG1sIgpBNTkwLDE1NzAsMiwzLDEsMSxOLCJUZXN0aW5nIHRoZSBwcmludDY0KCkgZnVuY3Rpb24iClAxCg==");
  96. // Send characters/raw commands to printer
  97. applet.print();
  98. }
  99. // *Note: monitorPrinting() still works but is too complicated and
  100. // outdated. Instead create a JavaScript function called
  101. // "jzebraDonePrinting()" and handle your next steps there.
  102. monitorPrinting();
  103. }
  104. function printPages() {
  105. var applet = document.jzebra;
  106. if (applet != null) {
  107. applet.append("A590,1600,2,3,1,1,N,\"jZebra 1\"\n");
  108. applet.append("A590,1570,2,3,1,1,N,\"Testing the printPages() function\"\n");
  109. applet.append("P1\n");
  110. applet.append("A590,1600,2,3,1,1,N,\"jZebra 2\"\n");
  111. applet.append("A590,1570,2,3,1,1,N,\"Testing the printPages() function\"\n");
  112. applet.append("P1\n");
  113. applet.append("A590,1600,2,3,1,1,N,\"jZebra 3\"\n");
  114. applet.append("A590,1570,2,3,1,1,N,\"Testing the printPages() function\"\n");
  115. applet.append("P1\n");
  116. applet.append("A590,1600,2,3,1,1,N,\"jZebra 4\"\n");
  117. applet.append("A590,1570,2,3,1,1,N,\"Testing the printPages() function\"\n");
  118. applet.append("P1\n");
  119. applet.append("A590,1600,2,3,1,1,N,\"jZebra 5\"\n");
  120. applet.append("A590,1570,2,3,1,1,N,\"Testing the printPages() function\"\n");
  121. applet.append("P1\n");
  122. applet.append("A590,1600,2,3,1,1,N,\"jZebra 6\"\n");
  123. applet.append("A590,1570,2,3,1,1,N,\"Testing the printPages() function\"\n");
  124. applet.append("P1\n");
  125. applet.append("A590,1600,2,3,1,1,N,\"jZebra 7\"\n");
  126. applet.append("A590,1570,2,3,1,1,N,\"Testing the printPages() function\"\n");
  127. applet.append("P1\n");
  128. applet.append("A590,1600,2,3,1,1,N,\"jZebra 8\"\n");
  129. applet.append("A590,1570,2,3,1,1,N,\"Testing the printPages() function\"\n");
  130. applet.append("P1\n");
  131. // Mark the end of a label, in this case P1 plus a newline character
  132. // jZebra knows to look for this and treat this as the end of a "page"
  133. // for better control of larger spooled jobs (i.e. 50+ labels)
  134. applet.setEndOfDocument("P1\n");
  135. // The amount of labels to spool to the printer at a time. When
  136. // jZebra counts this many `EndOfDocument`'s, a new print job will
  137. // automatically be spooled to the printer and counting will start
  138. // over.
  139. applet.setDocumentsPerSpool("3");
  140. // Send characters/raw commands to printer
  141. applet.print();
  142. }
  143. // *Note: monitorPrinting() still works but is too complicated and
  144. // outdated. Instead create a JavaScript function called
  145. // "jzebraDonePrinting()" and handle your next steps there.
  146. monitorPrinting();
  147. }
  148. function printXML() {
  149. var applet = document.jzebra;
  150. if (applet != null) {
  151. // Appends the contents of an XML file from a SOAP response, etc.
  152. // a valid relative URL or a valid complete URL is required for the XML
  153. // file. The second parameter must be a valid XML tag/node containing
  154. // base64 encoded data, i.e. <node_1>aGVsbG8gd29ybGQ=</node_1>
  155. // Example:
  156. // applet.appendXML("http://yoursite.com/zpl.xml", "node_1");
  157. // applet.appendXML("http://justtesting.biz/jZebra/dist/epl.xml", "v7:Image");
  158. applet.appendXML(getPath() + "misc/zpl_sample.xml", "v7:Image");
  159. // Send characters/raw commands to printer
  160. //applet.print(); // Can't do this yet because of timing issues with XML
  161. }
  162. // Monitor the append status of the xml file, prints when appending if finished
  163. // *Note: monitorAppending() still works but is too complicated and
  164. // outdated. Instead create a JavaScript function called
  165. // "jzebraDoneAppending()" and handle your next steps there.
  166. monitorAppending();
  167. }
  168. function printHex() {
  169. var applet = document.jzebra;
  170. if (applet != null) {
  171. // Using jZebra's "append()" function, hexadecimanl data can be sent
  172. // by using JavaScript's "\x00" notation. i.e. "41 35 39 30 2c ...", etc
  173. // Example:
  174. // applet.append("\x41\x35\x39\x30\x2c"); // ...etc
  175. applet.append("\x41\x35\x39\x30\x2c\x31\x36\x30\x30\x2c\x32\x2c\x33\x2c\x31\x2c\x31\x2c\x4e\x2c\x22\x6a\x5a\x65\x62\x72\x61\x20\x73\x61\x6d\x70\x6c\x65\x2e\x68\x74\x6d\x6c\x22\x0A\x41\x35\x39\x30\x2c\x31\x35\x37\x30\x2c\x32\x2c\x33\x2c\x31\x2c\x31\x2c\x4e\x2c\x22\x54\x65\x73\x74\x69\x6e\x67\x20\x74\x68\x65\x20\x70\x72\x69\x6e\x74\x48\x65\x78\x28\x29\x20\x66\x75\x6e\x63\x74\x69\x6f\x6e\x22\x0A\x50\x31\x0A");
  176. // Send characters/raw commands to printer
  177. applet.print();
  178. }
  179. // *Note: monitorPrinting() still works but is too complicated and
  180. // outdated. Instead create a JavaScript function called
  181. // "jzebraDonePrinting()" and handle your next steps there.
  182. monitorPrinting();
  183. /**
  184. * CHR/ASCII PRINTING:
  185. * // Appends CHR(27) + CHR(29) using `"fromCharCode"` function
  186. * // CHR(27) is commonly called the "ESCAPE" character
  187. * document.jzebra.append(String.fromCharCode(27) + String.fromCharCode(29));
  188. */
  189. }
  190. function printFile() {
  191. var applet = document.jzebra;
  192. if (applet != null) {
  193. // Using jzebra's "appendFile()" function, a file containg your raw EPL/ZPL
  194. // can be sent directly to the printer
  195. // Example:
  196. // applet.appendFile("http://yoursite/zpllabel.txt"); // ...etc
  197. applet.appendFile(getPath() + "misc/zpl_sample.txt");
  198. applet.print();
  199. }
  200. // *Note: monitorPrinting() still works but is too complicated and
  201. // outdated. Instead create a JavaScript function called
  202. // "jzebraDonePrinting()" and handle your next steps there.
  203. monitorPrinting();
  204. }
  205. function printImage(scaleImage) {
  206. var applet = document.jzebra;
  207. if (applet != null) {
  208. // Using jZebra's "appendImage()" function, a png, jpeg file
  209. // can be sent directly to the printer supressing the print dialog
  210. // Example:
  211. // applet.appendImage("http://yoursite/logo1.png"); // ...etc
  212. // Sample only: Searches for locally installed printer with "pdf" in the name
  213. // Can't use Zebra, because this function needs a PostScript capable printer
  214. applet.findPrinter("\\{dummy printer name for listing\\}");
  215. while (!applet.isDoneFinding()) {
  216. // Note, enless while loops are bad practice.
  217. // Create a JavaScript function called "jzebraDoneFinding()"
  218. // instead and handle your next steps there.
  219. }
  220. // Sample only: If a PDF printer isn't installed, try the Microsoft XPS Document
  221. // Writer. Replace this with your printer name.
  222. var printers = applet.getPrinters().split(",");
  223. for (i in printers) {
  224. if (printers[i].indexOf("Microsoft XPS") != -1 ||
  225. printers[i].indexOf("PDF") != -1) {
  226. applet.setPrinter(i);
  227. }
  228. }
  229. // No suitable printer found, exit
  230. if (applet.getPrinter() == null) {
  231. alert("Could not find a suitable printer for printing an image.");
  232. return;
  233. }
  234. // Optional, set up custom page size. These only work for PostScript printing.
  235. // setPaperSize() must be called before setAutoSize(), setOrientation(), etc.
  236. if (scaleImage) {
  237. applet.setPaperSize("8.5in", "11.0in"); // US Letter
  238. //applet.setPaperSize("210mm", "297mm"); // A4
  239. applet.setAutoSize(true);
  240. //applet.setOrientation("landscape");
  241. //applet.setOrientation("reverse-landscape");
  242. //applet.setCopies(3); //Does not seem to do anything
  243. }
  244. // Append our image (only one image can be appended per print)
  245. applet.appendImage(getPath() + "img/image_sample.png");
  246. }
  247. // Very important for images, uses printPS() insetad of print()
  248. // *Note: monitorAppending2() still works but is too complicated and
  249. // outdated. Instead create a JavaScript function called
  250. // "jzebraDoneAppending()" and handle your next steps there.
  251. monitorAppending2();
  252. }
  253. function printPDF() {
  254. var applet = document.jzebra;
  255. if (applet != null) {
  256. applet.findPrinter("\\{dummy printer name for listing\\}");
  257. while (!applet.isDoneFinding()) {
  258. // Note, enless while loops are bad practice.
  259. // Create a JavaScript function called "jzebraDoneFinding()"
  260. // instead and handle your next steps there.
  261. }
  262. // Sample only: If a PDF printer isn't installed, try the Microsoft XPS Document
  263. // Writer. Replace this with your printer name.
  264. var printers = applet.getPrinters().split(",");
  265. for (i in printers) {
  266. if (printers[i].indexOf("Microsoft XPS") != -1 ||
  267. printers[i].indexOf("PDF") != -1) {
  268. applet.setPrinter(i);
  269. }
  270. }
  271. // No suitable printer found, exit
  272. if (applet.getPrinter() == null) {
  273. alert("Could not find a suitable printer for a PDF document");
  274. return;
  275. }
  276. // Append our pdf (only one pdf can be appended per print)
  277. applet.appendPDF(getPath() + "misc/pdf_sample.pdf");
  278. }
  279. // Very important for PDF, uses printPS() instead of print()
  280. // *Note: monitorAppending2() still works but is too complicated and
  281. // outdated. Instead create a JavaScript function called
  282. // "jzebraDoneAppending()" and handle your next steps there.
  283. monitorAppending2();
  284. }
  285. // Gets the current url's path, such as http://site.com/example/dist/
  286. function getPath() {
  287. var path = window.location.href;
  288. return path.substring(0, path.lastIndexOf("/")) + "/";
  289. }
  290. function printHTML() {
  291. var applet = document.jzebra;
  292. if (applet != null) {
  293. applet.findPrinter("\\{dummy printer name for listing\\}");
  294. while (!applet.isDoneFinding()) {
  295. // Wait
  296. }
  297. // Sample only: If a PDF printer isn't installed, try the Microsoft XPS Document
  298. // Writer. Replace this with your printer name.
  299. var printers = applet.getPrinters().split(",");
  300. for (i in printers) {
  301. if (printers[i].indexOf("Microsoft XPS") != -1 ||
  302. printers[i].indexOf("PDF") != -1) {
  303. applet.setPrinter(i);
  304. }
  305. }
  306. // No suitable printer found, exit
  307. if (applet.getPrinter() == null) {
  308. alert("Could not find a suitable printer for an HTML document");
  309. return;
  310. }
  311. // Preserve formatting for white spaces, etc.
  312. var colA = fixHTML('<h2>* jZebra HTML Printing *</h2>');
  313. colA = colA + '<color=red>Version:</color> ' + applet.getVersion() + '<br />';
  314. colA = colA + '<color=red>Visit:</color> <http://code.google.com/p/jzebra';
  315. // HTML image
  316. var colB = '<img src="' + getPath() + 'img/image_sample.png">';
  317. // Append our image (only one image can be appended per print)
  318. applet.appendHTML('<html><table face="monospace" border="1px"><tr height="6cm">' +
  319. '<td valign="top">' + colA + '</td>' +
  320. '<td valign="top">' + colB + '</td>' +
  321. '</tr></table></html>');
  322. }
  323. // Very important for html, uses printHTML() instead of print()
  324. // *Note: monitorAppending3() still works but is too complicated and
  325. // outdated. Instead create a JavaScript function called
  326. // "jzebraDoneAppending()" and handle your next steps there.
  327. monitorAppending3();
  328. }
  329. // Fixes some html formatting for printing. Only use on text, not on tags! Very important!
  330. // 1. HTML ignores white spaces, this fixes that
  331. // 2. The right quotation mark breaks PostScript print formatting
  332. // 3. The hyphen/dash autoflows and breaks formatting
  333. function fixHTML(html) { return html.replace(/ /g, "&nbsp;").replace(/â&#x20AC;&#x2122;/g, "'").replace(/-/g,"&#8209;"); }
  334. function printToFile() {
  335. var applet = document.jzebra;
  336. if (applet != null) {
  337. // Send characters/raw commands to applet using "append"
  338. // Hint: Carriage Return = \r, New Line = \n, Escape Double Quotes= \"
  339. applet.append("A590,1600,2,3,1,1,N,\"jZebra " + applet.getVersion() + " sample.html\"\n");
  340. applet.append("A590,1570,2,3,1,1,N,\"Testing the print() function\"\n");
  341. applet.append("P1\n");
  342. // Send characters/raw commands to file
  343. // Ex: applet.printToFile("\\\\server\\printer");
  344. // Ex: applet.printToFile("/home/user/test.txt");
  345. applet.printToFile("C:\\jzebra_test.txt");
  346. }
  347. // *Note: monitorPrinting() still works but is too complicated and
  348. // outdated. Instead create a JavaScript function called
  349. // "jzebraDonePrinting()" and handle your next steps there.
  350. monitorPrinting();
  351. }
  352. function chr(i) {
  353. return String.fromCharCode(i);
  354. }
  355. // *Note: monitorPrinting() still works but is too complicated and
  356. // outdated. Instead create a JavaScript function called
  357. // "jzebraDonePrinting()" and handle your next steps there.
  358. function monitorPrinting() {
  359. var applet = document.jzebra;
  360. if (applet != null) {
  361. if (!applet.isDonePrinting()) {
  362. window.setTimeout('monitorPrinting()', 100);
  363. } else {
  364. var e = applet.getException();
  365. alert(e == null ? "Printed Successfully" : "Exception occured: " + e.getLocalizedMessage());
  366. }
  367. } else {
  368. alert("Applet not loaded!");
  369. }
  370. }
  371. function monitorFinding() {
  372. var applet = document.jzebra;
  373. if (applet != null) {
  374. if (!applet.isDoneFinding()) {
  375. window.setTimeout('monitorFinding()', 100);
  376. } else {
  377. var printer = applet.getPrinter();
  378. alert(printer == null ? "Printer not found" : "Printer \"" + printer + "\" found");
  379. }
  380. } else {
  381. alert("Applet not loaded!");
  382. }
  383. }
  384. function monitorFinding2() {
  385. var applet = document.jzebra;
  386. if (applet != null) {
  387. if (!applet.isDoneFinding()) {
  388. window.setTimeout('monitorFinding2()', 100);
  389. } else {
  390. var printersCSV = applet.getPrinters();
  391. var printers = printersCSV.split(",");
  392. for (p in printers) {
  393. alert(printers[p]);
  394. }
  395. }
  396. } else {
  397. alert("Applet not loaded!");
  398. }
  399. }
  400. // *Note: monitorAppending() still works but is too complicated and
  401. // outdated. Instead create a JavaScript function called
  402. // "jzebraDoneAppending()" and handle your next steps there.
  403. function monitorAppending() {
  404. var applet = document.jzebra;
  405. if (applet != null) {
  406. if (!applet.isDoneAppending()) {
  407. window.setTimeout('monitorAppending()', 100);
  408. } else {
  409. applet.print(); // Don't print until all of the data has been appended
  410. // *Note: monitorPrinting() still works but is too complicated and
  411. // outdated. Instead create a JavaScript function called
  412. // "jzebraDonePrinting()" and handle your next steps there.
  413. monitorPrinting();
  414. }
  415. } else {
  416. alert("Applet not loaded!");
  417. }
  418. }
  419. // *Note: monitorAppending2() still works but is too complicated and
  420. // outdated. Instead create a JavaScript function called
  421. // "jzebraDoneAppending()" and handle your next steps there.
  422. function monitorAppending2() {
  423. var applet = document.jzebra;
  424. if (applet != null) {
  425. if (!applet.isDoneAppending()) {
  426. window.setTimeout('monitorAppending2()', 100);
  427. } else {
  428. applet.printPS(); // Don't print until all of the image data has been appended
  429. // *Note: monitorPrinting() still works but is too complicated and
  430. // outdated. Instead create a JavaScript function called
  431. // "jzebraDonePrinting()" and handle your next steps there.
  432. monitorPrinting();
  433. }
  434. } else {
  435. alert("Applet not loaded!");
  436. }
  437. }
  438. // *Note: monitorAppending3() still works but is too complicated and
  439. // outdated. Instead create a JavaScript function called
  440. // "jzebraDoneAppending()" and handle your next steps there.
  441. function monitorAppending3() {
  442. var applet = document.jzebra;
  443. if (applet != null) {
  444. if (!applet.isDoneAppending()) {
  445. window.setTimeout('monitorAppending3()', 100);
  446. } else {
  447. applet.printHTML(); // Don't print until all of the image data has been appended
  448. // *Note: monitorPrinting() still works but is too complicated and
  449. // outdated. Instead create a JavaScript function called
  450. // "jzebraDonePrinting()" and handle your next steps there.
  451. monitorPrinting();
  452. }
  453. } else {
  454. alert("Applet not loaded!");
  455. }
  456. }
  457. function useDefaultPrinter() {
  458. var applet = document.jzebra;
  459. if (applet != null) {
  460. // Searches for default printer
  461. applet.findPrinter();
  462. }
  463. monitorFinding();
  464. }
  465. function jzebraReady() {
  466. // Change title to reflect version
  467. var applet = document.jzebra;
  468. var title = document.getElementById("title");
  469. if (applet != null) {
  470. title.innerHTML = title.innerHTML + " " + applet.getVersion();
  471. document.getElementById("content").style.background = "#F0F0F0";
  472. }
  473. }
  474. /**
  475. * By default, jZebra prevents multiple instances of the applet's main
  476. * JavaScript listener thread to start up. This can cause problems if
  477. * you have jZebra loaded on multiple pages at once.
  478. *
  479. * The downside to this is Internet Explorer has a tendency to initilize the
  480. * applet multiple times, so use this setting with care.
  481. */
  482. function allowMultiple() {
  483. var applet = document.jzebra;
  484. if (applet != null) {
  485. var multiple = applet.getAllowMultipleInstances();
  486. applet.allowMultipleInstances(!multiple);
  487. alert('Allowing of multiple applet instances set to "' + !multiple + '"');
  488. }
  489. }
  490. function printPage() {
  491. $("#content").html2canvas({
  492. canvas: hidden_screenshot,
  493. onrendered: function() {printBase64Image($("canvas")[0].toDataURL('image/png'));}
  494. });
  495. }
  496. function printBase64Image(base64data) {
  497. var applet = document.jzebra;
  498. if (applet != null) {
  499. applet.findPrinter("\\{dummy printer name for listing\\}");
  500. while (!applet.isDoneFinding()) {
  501. // Note, endless while loops are bad practice.
  502. }
  503. var printers = applet.getPrinters().split(",");
  504. for (i in printers) {
  505. if (printers[i].indexOf("Microsoft XPS") != -1 ||
  506. printers[i].indexOf("PDF") != -1) {
  507. applet.setPrinter(i);
  508. }
  509. }
  510. // No suitable printer found, exit
  511. if (applet.getPrinter() == null) {
  512. alert("Could not find a suitable printer for printing an image.");
  513. return;
  514. }
  515. // Optional, set up custom page size. These only work for PostScript printing.
  516. // setPaperSize() must be called before setAutoSize(), setOrientation(), etc.
  517. applet.setPaperSize("8.5in", "11.0in"); // US Letter
  518. applet.setAutoSize(true);
  519. applet.appendImage(base64data);
  520. }
  521. // Very important for images, uses printPS() insetad of print()
  522. // *Note: monitorAppending2() still works but is too complicated and
  523. // outdated. Instead create a JavaScript function called
  524. // "jzebraDoneAppending()" and handle your next steps there.
  525. monitorAppending2();
  526. }
  527. function logFeatures() {
  528. if (document.jzebra != null) {
  529. var applet = document.jzebra;
  530. var logging = applet.getLogPostScriptFeatures();
  531. applet.setLogPostScriptFeatures(!logging);
  532. alert('Logging of PostScript printer capabilities to console set to "' + !logging + '"');
  533. }
  534. }
  535. </script>
  536. <script type="text/javascript" src="js/jquery-1.7.1.js"></script>
  537. <script type="text/javascript" src="js/html2canvas.js"></script>
  538. <script type="text/javascript" src="js/jquery.plugin.html2canvas.js"></script>
  539. </head>
  540. <body id="content" bgcolor="#FFF380">
  541. <h1 id="title">jZebra Sample Applet</h1><br />
  542. <table border="1px" cellpadding="5px" cellspacing="0px"><tr>
  543. <td valign="top"><h2>All Printers</h2>
  544. <input type=button onClick="findPrinter()" value="Detect Printer"><br />
  545. <input type=button onClick="findPrinters()" value="List All Printers"><br />
  546. <input type=button onClick="useDefaultPrinter()" value="Use Default Printer"><br /><br />
  547. <applet name="jzebra" code="jzebra.PrintApplet.class" archive="./jzebra.jar" width="50px" height="50px">
  548. <param name="printer" value="zebra">
  549. </applet><br />
  550. </td><td valign="top"><h2>Raw Printers Only</h2>
  551. <a href="http://code.google.com/p/jzebra/wiki/WhatIsRawPrinting" target="new">What is Raw Printing?</a><br />
  552. <input type=button onClick="print()" value="Print" /><br />
  553. <input type=button onClick="print64()" value="Print Base64" /><br />
  554. <input type=button onClick="printPages()" value="Print Spooling Every 3" /><br />
  555. <input type=button onClick="printXML()" value="Print XML" /><br />
  556. <input type=button onClick="printHex()" value="Print Hex" /><br />
  557. <input type=button onClick="printFile()" value="Print File" /><br />
  558. <input type=button onClick="printZPLImage()" value="Print ZPL Image" /><br />
  559. <input type=button onClick="printToFile()" value="Print To File" /><br />
  560. </td><td valign="top"><h2>PostScript Printers Only</h2>
  561. <a href="http://code.google.com/p/jzebra/wiki/WhatIsPostScriptPrinting" target="new">What is PostScript Printing?</a><br />
  562. <input type=button onClick="printHTML()" value="Print HTML" /><br />
  563. <input type=button onClick="printPDF()" value="Print PDF" /><br />
  564. <input type=button onClick="printImage(false)" value="Print PostScript Image" /><br />
  565. <input type=button onClick="printImage(true)" value="Print Scaled PostScript Image" /><br />
  566. <input type=button onClick="printPage()" value="Print Current Page" /><br />
  567. <input type=button onClick="logFeatures()" value="Log Printer Features on Print" /><br />
  568. </td><td valign="top"><h2>Misc</h2>
  569. <input type=button onClick="allowMultiple()" value="Allow Multiple Applets" /><br /></td></tr></table>
  570. </body><canvas id="hidden_screenshot" style="display:none;" />
  571. <br /><br />To view the applet's html source code:<strong> Right Click This Page --> View Source</strong> and look for <strong>&lt;applet&gt &lt;/applet&gt;</strong> code.
  572. <br /><br />The applet is invoked with JavaScript through: <strong>document.jzebra.applet.append("RAW DATA");</strong> and <strong>document.jzebra.applet.print();</strong>. For more details, Right Click This Page --> View Source and look for <strong>&lt;script&gt &lt;/script&gt;</strong> code.
  573. <br /><br />If the applet loads above, you can view it's output by enabling the Java console through Control Panel.
  574. <br /><br />To get the latest version, or submit a bug visit: <a href="http://code.google.com/p/jzebra">http://code.google.com/p/jzebra</a><br />
  575. <br /><br /><strong>Java Console:</strong> Please copy/paste details from the <a href="http://java.com/en/download/help/javaconsole.xml">java console</a> when submitting a bug report
  576. </html>