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

203
Views
Agregue contenido de texto a pdf antes de mostrarlo en el visor de pdf usando pdf.js

Necesita establecer el nombre desde el margen superior 90px en pdf

Estoy usando el visor suministrado con pdf.js, el mismo disponible aquí https://mozilla.github.io/pdf.js/web/viewer.html

Intenté establecer contenido de texto usando el siguiente código pero no funcionó

 page.getTextContent().then(function(textContent){ var textLayer = new TextLayerBuilder({ textLayerDiv : $textLayerDiv.get(0), pageIndex : page_num - 1, viewport : viewport }); textLayer.setTextContent(textContent); });

Además, intenté modificar el archivo pdf.js para agregar "Prueba" al final de cada etiqueta de intervalo representada, que muestra el texto actualizado usando el elemento de inspección pero no se muestra en el visor.

 function appendText(task, geom, styles, ctx) { geom.str += "Test"; const textDiv = document.createElement("span"); const textDivProperties = { angle: 0, canvasWidth: 0, isWhitespace: false, originalTransform: null, paddingBottom: 0, paddingLeft: 0, paddingRight: 0, paddingTop: 0, scale: 1 };

Además, el contenido de texto aplicado dentro de textLayer directamente en viewer.js enfrenta el mismo problema que no se refleja en el pdf renderizado

 const paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper); paintTask.onRenderContinue = renderContinueCallback; this.paintTask = paintTask; const resultPromise = paintTask.promise.then(function () { return finishPaintTask(null).then(function () { if (textLayer) { const readableStream = pdfPage.streamTextContent({ normalizeWhitespace: true }); textLayer.textContentItemsStr[4] = "Test"; textLayer.setTextContentStream(readableStream); textLayer.render(); } }); }, function (reason) { return finishPaintTask(reason); });
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!