<?php
session_start();
include('../config.php');
include($rutaPhp.$rutaHtml.'/librerias/constantes.php');

if($_GET['NombreTemporalPDF']) $NombreTemporalPDF=$_GET['NombreTemporalPDF']; else $NombreTemporalPDF=$_POST['NombreTemporalPDF'];

$fichero=$rutaHtml.'/'.$RutaTemporalSubidaDocumentos.$NombreTemporalPDF;

echo '<p>'.$fichero.'</p>';

?>

    <div class="toolbar">
        
        <div class="tool">
            <button class="boton" id="botonFirmar">Firmar</button>
        </div>
        <div class="tool">
            <button class="boton" id="botonCancelar">Cancelar</button>
        </div>
        <div class="tool">
            <button class="boton" id="botonEnviar">ENVIAR</button>
        </div>
        
    </div>
    
    <div id="pdf-container"></div>
    
    <div id="firma_velo" style="display:none">
    	<div id="firma">
    		<p>FIRMA</p>
            <canvas width="600" height="300" id="firma-canvas"></canvas>
            <button class="boton" id="firma-boton-borrar">Borra</button>
            <button class="boton" id="firma-boton-cancelar">Cancela</button>
            <button class="boton" id="firma-boton-ok">OK</button>
        </div>
    </div>


<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.6.347/pdf.min.js"></script>
<script>pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.6.347/pdf.worker.min.js';</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/4.3.0/fabric.min.js"></script>

<script src="<?php echo $rutaHtml; ?>/librerias/firmas.js"></script>

<script>

var pdf = new PDFAnnotate("pdf-container", "<?php echo $fichero; ?>", {
  onPageUpdated(page, oldData, newData) {
    console.log(page, oldData, newData);
  },
  ready() {
    console.log("Plugin initialized successfully");
  },
  scale: 1.5,
  pageImageCompression: "MEDIUM", // FAST, MEDIUM, SLOW(Helps to control the new PDF file size)
});

</script>
