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?