Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

222
Vistas
How do I display a PDF I retrieved from a server onto a PDF.js custom pdf viewer page?

I have a pdf sitting in my cshtml page via @Html.HiddenFor(m => m.ConstructedLinkToPdfDocumentForPDFJS) that I need to pass to a javascript file. This javascript file is using PDF.js to display that PDF on a custom pdf viewer I made for my website. I have it passed as a hiddenfor just to try to do it from a server that I made solely for storing this pdf and retrieving it. I am constructing a string link in a C# file on my server that links to a pdf file that is stored on said server. It fully constructs the string to that pdf file, and passes it up to my model to be seen by Javascript, but somehow in Javascript the string ends up as undefined from the following code:

var fullLink;
const initialState =
{
    pdfDoc: null,
    currentPage: 1,
    pageCount: 0,
    zoom: 1,
};

//On load
$(document).ready(function () {
    fullLink = document.getElementById('#ConstructedLinkToPdfDocumentForPDFJS');
});

//Load pdf document
pdfjsLib
    .getDocument(fullLink)
    .promise.then((data) => {
        initialState.pdfDoc = data;
        console.log('pdfDocument', initialState.pdfDoc);

        pageCount.textContent = initialState.pdfDoc.numPages;

        renderPage();
    })
    .catch((err) => {
        alert(err.message);
    });

Should I not be using document.getElementById() and instead use something else?

about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda