generar pdf
Publicado por mac dev (13 intervenciones) el 14/05/2020 23:35:56
hola estoy tratando de generar un pdf desde un archivo html que tiene codigo javascript y el archivo saliente es un php. pero el problema lo tengo en el siguiente codigo
esta variable prueba esta en el .php saliente y no carga el "numeroPdf" que se encuentra en el html.
desde aca tiene que agarrar el "numeroPdf"
tengo un html (vista) que tiene el "numeroPdf" y despues esta funcion ajax()
detalles.php este archivo necesito ejecutarlo poniendolo en una pestaña nueva para que genere el pdf
1
2
1
var prueba = document.getElementById("numeroPdf").innerText;
esta variable prueba esta en el .php saliente y no carga el "numeroPdf" que se encuentra en el html.
desde aca tiene que agarrar el "numeroPdf"
tengo un html (vista) que tiene el "numeroPdf" y despues esta funcion ajax()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<td id="numeroPdf">{numFac}</td>
<script>
function ajax()
{const http = new XMLHttpRequest();
const url = 'http://localhost/reportes/detalles.php';
http.onreadystatechange = function (){
if(this.readyState == 4 && this.status == 200){
let prueba = document.getElementById("numeroPdf").innerText; //reconoce el número
} }http.open('GET', url)
http.send();
}document.getElementById("btnPdf").addEventListener("click", function(){
ajax();
});
</script>
detalles.php este archivo necesito ejecutarlo poniendolo en una pestaña nueva
1
target="_blank"
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
<?php
require_once('C:\xampp\htdocs\reportes\pdf\mPDF.php');
$conn=new mysqli('localhost','root','*****','base'); //**** y base están correctos
$numero = {prueba}; // no reconoce el número$query="SELECT * FROM detalle WHERE
det_factura = $numero"; // no reconoce el número $prepare=$conn->prepare($query); $prepare->execute(); $resultSets=$prepare->get_result(); while($resultado[]=$resultSets->fetch_array()); $resultSets->close(); $prepare->close(); $conn->close();$html='<header class="clearfix">
<h1>Remito</h1> <table class="table table-striped table-bordered table-hover table-condensed"> <tr class="danger"> <thead> <th align="left" width="0%" class="active">N° de Factura</th> <th align="left" width="0%" class="active">Fecha</th> <th align="left" width="0%" class="active">Producto</th> </tr> </thead> <tbody>'; $mpdf = new mPDF('c' , 'A4'); $css=file_get_contents('C:/xampp/htdocs/MMotos/app/cms/reportes/plantilla/css/style.css'); $mpdf->writeHTML($css,1); $mpdf->writeHTML($html); $mpdf->Output('reporte.pdf','I');?>Valora esta pregunta


0
