I am working with a requirement for one of the modules in the project(.Net Core) which comprises multiple PDF operations, like converting from PDF to HTML, then editing the HTML in a web view editor, finally converting it into a PDF.
I used JavaScript code provided to use a web-based PDF editor (PDFTRON). I tried manual integration with the help of provided official documentation PDFTron MANUAL INTEGRATION GUIDE. I am able to successfully use the library when I run through node js, but when I am using it in Dotnet core it's failing to load simple_wasm/MemGrow.js.mem file which is a subpart of memgrow.js, please find below screenshot for error occurred.
Folder configured for web viewer
Code is as follows:
Index.cshtml
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>
Learn about <a href="https://learn.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.
<label for="file_upload">Choose A file</label>
<input type="file" id="file_upload" name="file_upload" accept=".pdf">
</p>
</div>
<div id='viewer' style='width: 1024px; height: 600px;'> </div>
<script src="~/WebViewer/lib/webviewer.min.js"> </script>
<script>
const input = document.getElementById('file_upload');
WebViewer({
path: 'WebViewer/lib', // path to the PDFTron 'lib' folder on your server
licenseKey: 'Insert commercial license key here after purchase',
initialDoc: 'files/sample.pdf', // You can also use documents on your server
}, document.getElementById('viewer'))
.then(instance => {
const docViewer = instance.docViewer;
const annotManager = instance.annotManager;
// const Annotations = instance.Annotations;
input.addEventListener('change', () => {
debugger;
// Get the file from the input
const file = input.files[0];
instance.loadDocument(file, { filename: file.name });
});
docViewer.on('documentLoaded', () => {
// call methods relating to the loaded document
});
});
Working fine when running through node js server, screenshot as follows,
Looking for assistance to provide solution in .net core.