Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

245
Views
guarde la edición de pdf en el servidor usando pdfannotate

Estoy usando el complemento jsPDF para crear un archivo pdf. Actualmente, el método puede generar un archivo de descarga basado en el botón de clic. en lugar de eso, me gustaría guardar el archivo en el servidor cuando hago clic en el botón. algunas investigaciones utilizo jquery.ajax para enviar los datos al servidor de archivos.

Código

 PDFAnnotate.prototype.savePdf = function() { var inst = this; var doc = new jspdf.jsPDF(); inst.fabricObjects.forEach(function(fabricObj, index) { if (index != 0) { doc.addPage(); doc.setPage(index + 1); } doc.addImage( fabricObj.toDataURL({ format: 'png' }), inst.pageImageCompression == "NONE" ? "PNG" : "JPEG", 0, 0, doc.internal.pageSize.getWidth(), doc.internal.pageSize.getHeight(), `page-${index + 1}`, ["FAST", "MEDIUM", "SLOW"].indexOf(inst.pageImageCompression) >= 0 ? inst.pageImageCompression : undefined ); if (index === inst.fabricObjects.length - 1) { var blob = doc.output('blob'); var formData = new FormData(); formData.append('pdf', blob); var xhr = new XMLHttpRequest(); xhr.open('POST', baseurl + "wo/replaceFile", true); xhr.send('pdf'); } }) }

Basado en el método xhr.open I call en el controlador Wo.php/replaceFile()

 if(!empty($_FILES['pdf'])) { $data = $_POST['pdf']; $fname = "test.pdf"; // name the file $file = fopen("testa/pdf/" .$fname, 'w'); fwrite($file, $data); //save data fclose($file); } else { throw new Exception("no data"); } ?>

Pero no ocurrió ninguna acción.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!