1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Laravel - open a pdf file from shared network using local default app in laptop

Discussão em 'Outras Linguagens' iniciado por nuna, Outubro 17, 2024 às 02:32.

  1. nuna

    nuna Guest

    i have a question regarding to pdf open using local default app. I try to open an uploaded pdf file in a laravel project using local default app for example adobe acrobat. Is it possible to create a laravel function and Js script to perform this action?

    <script>
    document.addEventListener('DOMContentLoaded', function () {
    const inputFields = document.querySelectorAll('.form-control');

    inputFields.forEach(input => {
    input.addEventListener('input', function () {
    if (this.value.length > parseInt(this.getAttribute('maxlength'))) {
    this.value = this.value.slice(0, parseInt(this.getAttribute('maxlength')));
    }
    });
    });

    document.getElementById('editing-button').addEventListener('click', function() {
    const pdfFrame = document.getElementById('pdf-frame');
    const pdfUrl = pdfFrame.src;

    Swal.fire({
    title: 'Loading...',
    html: 'Opening PDF in Adobe Acrobat in <b></b> milliseconds.',
    timer: 3000,
    timerProgressBar: true,
    didOpen: () => {
    Swal.showLoading();
    const b = Swal.getHtmlContainer().querySelector('b');
    let timerInterval = setInterval(() => {
    b.textContent = Swal.getTimerLeft();
    }, 100);
    Swal._timerInterval = timerInterval;
    },
    willClose: () => {
    clearInterval(Swal._timerInterval);
    window.open(pdfUrl, '_blank');
    // extract($_REQUEST);
    // $filename = realpath($filename);
    // //replace internal server path to network path
    // $filename = str_replace("C:\xampp\htdocs\Cloud-Indexing-Laravel\public\storage\input\PO Agro\batch\TRANSKRIP_MINI_AMEEN-1.pdf");
    // function acrobat($filename) {
    // header("Content-type: text/plain");
    // header("Content-Disposition: attachment; filename=acrobat.cmd");
    // print $filename; //dowload file called acrobat.cmd
    // }
    // //call the function with the command to open pdf by default program.
    // acrobat( "start \"\" \"$filename\" ".PHP_EOL." DEL \"%~f0\"");
    }
    });
    });
    });
    </script>

    Continue reading...

Compartilhe esta Página