PDFJS inside NAV Page
Eboy82
Member Posts: 25
Hi,
Was wondering if anyone else has tried and succeeded in making a javascript addon for Dynamics NAV 2013+ that can embed a PDF file into a NAV page.
I have done a dotnet DLL (Browser) based solution in the past before - but too many issues with this, and no support on all clients anymore.
I think I am close, but probably far far away
I am looking a lot at how this one was done - a signature image box in NAV. https://code.msdn.microsoft.com/windowsdesktop/Extensibility-for-the-7600738d
I'm just trying to use the simple example from here to begin with
https://github.com/mozilla/pdf.js/blob/master/examples/learning/helloworld64.html
If I get it to work, I will post it here ! Shame it's not part of the standard NAV addins
Sorry, I am not javascript wizz'
Update 1: Below is what I managed to do - it works quite basic, with some issues, but at least more stable than a Adobe browser addin solution.
Beyond my skills to enable text-selection and zoom capabilities, but next/prev. page works. I transfer a base64 bigtext to the Javascript function PutPDF.

Was wondering if anyone else has tried and succeeded in making a javascript addon for Dynamics NAV 2013+ that can embed a PDF file into a NAV page.
I have done a dotnet DLL (Browser) based solution in the past before - but too many issues with this, and no support on all clients anymore.
I think I am close, but probably far far away
I am looking a lot at how this one was done - a signature image box in NAV. https://code.msdn.microsoft.com/windowsdesktop/Extensibility-for-the-7600738d
I'm just trying to use the simple example from here to begin with
https://github.com/mozilla/pdf.js/blob/master/examples/learning/helloworld64.html
If I get it to work, I will post it here ! Shame it's not part of the standard NAV addins
Sorry, I am not javascript wizz'
Update 1: Below is what I managed to do - it works quite basic, with some issues, but at least more stable than a Adobe browser addin solution.
Beyond my skills to enable text-selection and zoom capabilities, but next/prev. page works. I transfer a base64 bigtext to the Javascript function PutPDF.
var PDF;
var pdfdata;
function initpdf() {
PDF = new ns.PDFControl();
PDF.init();
RaiseAddInReady();
}
// Event will be fired when the control add-in is ready for communication through its API.
function RaiseAddInReady() {
Microsoft.Dynamics.NAV.InvokeExtensibilityMethod('AddInReady');
}
// Event raised when the update PDF has been called.
function RaiseUpdatePDF() {
Microsoft.Dynamics.NAV.InvokeExtensibilityMethod('UpdatePDF');
}
function PutPDF(PDFData,pageno) {
PDF.updatePDF(PDFData,pageno);
}
(function (ns) {
ns.PDFControl = function () {
var canvas,
context;
function init() {
createControlElements();
context = canvas.getContext("2d");
}
function createControlElements() {
var PDFArea = document.createElement("div");
var canvasDiv = document.createElement("div");
canvas = document.createElement("canvas"),
canvas.id = "pdfCanvas";
canvas.clientWidth = 700;
canvas.clientHeight = 1000;
canvas.width = canvas.clientWidth ;
canvas.height = canvas.clientHeight;
canvas.className = "pdfCanvas";
canvasDiv.appendChild(canvas);
PDFArea.className = "PDFArea";
PDFArea.appendChild(canvasDiv);
document.getElementById("controlAddIn").appendChild(PDFArea);
}
function updatePDF(PDFData,pageno) {
pdfData = atob(PDFData);
// PDFJS.workerSrc = 'http://www.example.dk/tmp/pdf.worker.js';
PDFJS.getDocument({data: pdfData}).then(function DisplayPDFNAV(pdf) {
pdf.getPage(pageno).then(function DisplayPDFNAV(page) {
var scale = 2.0;
var viewport = page.getViewport(scale);
// Prepare canvas using PDF page dimensions.
canvas.height = viewport.height;
canvas.width = viewport.width;
//Render PDF page into canvas context.
var renderContext = {
canvasContext: context,
viewport: viewport
};
page.render(renderContext);
});
RaiseUpdatePDF();
});
PDFArea.appendChild(canvasDiv);
pdfData = "";
}
return {
init: init,
updatePDF: updatePDF,
};
};
})(this.ns = this.ns || {});

0
Answers
-
Some progress now, I can display the PDF inside NAV . I will update code here later, if anyone interested0
-
Yes, I,' interested!1
-
I hope you will interest this as well. https://youtube.com/watch?v=VQVPJNIR-ag&feature=youtu.beMake Simple & Easy0
-
Hi did You finished this soultion? Can You share with created objects?0
-
Did you get this working? Very interested!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 329 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions