-
Notifications
You must be signed in to change notification settings - Fork 4
/
base64.html
63 lines (59 loc) · 4.22 KB
/
base64.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Imprimir a partir de base64</title>
</head>
<body>
<label for="impresoras">Seleccione una impresora</label>
<br>
<select name="" id="impresoras"></select>
<br>
<br>
<label for="contenido">PDF como base64:</label>
<br>
<textarea id="contenido" cols="60"
rows="10">JVBERi0xLjcKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZwovT3V0bGluZXMgMiAwIFIKL1BhZ2VzIDMgMCBSID4+CmVuZG9iagoyIDAgb2JqCjw8IC9UeXBlIC9PdXRsaW5lcyAvQ291bnQgMCA+PgplbmRvYmoKMyAwIG9iago8PCAvVHlwZSAvUGFnZXMKL0tpZHMgWzYgMCBSCl0KL0NvdW50IDEKL1Jlc291cmNlcyA8PAovUHJvY1NldCA0IDAgUgovRm9udCA8PCAKL0YxIDggMCBSCi9GMiA5IDAgUgovRjMgMTAgMCBSCj4+Cj4+Ci9NZWRpYUJveCBbMC4wMDAgMC4wMDAgNjEyLjAwMCA3OTIuMDAwXQogPj4KZW5kb2JqCjQgMCBvYmoKWy9QREYgL1RleHQgXQplbmRvYmoKNSAwIG9iago8PAovUHJvZHVjZXIgKP7/AGQAbwBtAHAAZABmACAAMgAuADAALgA0ACAAKwAgAEMAUABEAEYpCi9DcmVhdGlvbkRhdGUgKEQ6MjAyNDA0MTUyMDA3NDMtMDUnMDAnKQovTW9kRGF0ZSAoRDoyMDI0MDQxNTIwMDc0My0wNScwMCcpCj4+CmVuZG9iago2IDAgb2JqCjw8IC9UeXBlIC9QYWdlCi9NZWRpYUJveCBbMC4wMDAgMC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MjQgMDAwMDAgbiAKMDAwMDAwMDQ3MyAwMDAwMCBuIAowMDAwMDAwNTc2IDAwMDAwIG4gCjAwMDAwMDA4MzggMDAwMDAgbiAKMDAwMDAwMDk0NSAwMDAwMCBuIAowMDAwMDAxMDU3IDAwMDAwIG4gCjAwMDAwMDExNjcgMDAwMDAgbiAKdHJhaWxlcgo8PAovU2l6ZSAxMgovUm9vdCAxIDAgUgovSW5mbyA1IDAgUgovSURbPGVjM2ZkZmYxNGE4NThiMmEzMWIxZTAxMDdjZDA1NTQ4PjxlYzNmZGZmMTRhODU4YjJhMzFiMWUwMTA3Y2QwNTU0OD5dCj4+CnN0YXJ0eHJlZgoxMTk2CiUlRU9GCg==</textarea>
<br>
<button id="imprimir">Imprimir</button>
<script>
document.addEventListener("DOMContentLoaded", async () => {
const $impresoras = document.querySelector("#impresoras"),
$contenido = document.querySelector("#contenido");
const $imprimir = document.querySelector("#imprimir");
const imprimir = async () => {
const respuestaHttp = await fetch("http://localhost:8080/base64", {
method: "POST",
body: JSON.stringify({
nombreImpresora: $impresoras.value,
contenido: $contenido.value,
serial: "",
})
});
if (respuestaHttp.status === 200) {
alert("Impreso correctamente")
} else {
const mensajeDeError = await respuestaHttp.text();
alert("Error: " + mensajeDeError)
}
}
$imprimir.onclick = () => {
imprimir();
}
const refrescarListaDeImpresoras = async () => {
const respuestaHttp = await fetch("http://localhost:8080/impresoras");
const impresoras = await respuestaHttp.json();
for (const impresora of impresoras) {
const opcion = Object.assign(document.createElement("option"), {
value: impresora,
text: impresora,
});
$impresoras.appendChild(opcion);
}
}
refrescarListaDeImpresoras();
})
</script>
</body>
</html>