Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

228
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda