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

229
Views
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
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!