0

I am trying to use jsPDF.umd.js in SharePoint to create some pdfs in an enterprise environment. Sadly I have to rely on IE11 in this environment.

I am loading the jsPDF with script tags

<script type="text/javascript" src="/sites/xxxx/polyfills.umd.js"></script>
<script type="text/javascript" src="/sites/xxxx/jsPDF.umd.js"></script>

and try to create an object with new jspdf.jsPDF();

This works in Firefox and Edge, but Internet Explorer seems to not load the jsPDF.umd.js at all.

The error seems to be

SCRIPT1047: In strict mode, function declarations cannot be nested inside a statement or block. They may only appear at the top level or directly inside a function body.
File: jsPDF.umd.js, Line: 744, Column: 5

I am at a loss, because this works in ff and edge, but not in IE. The sample (http://raw.githack.com/MrRio/jsPDF/master/#) site works with all browsers.

Is there a way to disable strict mode?

I never had problems with use strict before - though I do not know if and where it is activated.

I am not JavaScript developer - so maybe there is a completely different issue at work here.

edit: the issue seems to be IE with javascript. I commented the lines with error from jspdf.umd.js out, and now I am getting a syntax error at line 847

let protection = 192;

maybe IE is using a pre ECMAscript 5 engine?

edit2: navigator.userAgent outputs "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; Zoom 3.6.0)"

so I think I am in compatibility view - switching Document Mode seems to fix the issues - I don't know how to proceed from here yet, because this cannot be a general solution for all users.

edit3: so the page contains

<meta http-equiv="X-UA-Compatible" content="IE=10">

so I will need to change that I guess. Maybe these articles will help: https://www.dannyjessee.com/blog/index.php/2020/03/rendering-a-single-sharepoint-page-in-ie-using-edge-mode/ https://paultavares.wordpress.com/2015/01/20/how-to-render-a-sharepoint-page-in-ie-using-edge-mode-without-changing-the-master-page/

Ulgar80
  • 1
  • 1
  • Can you please inform us of the status of the issue? does your issue solve with the answer I provided you on this thread? If yes, I suggest you mark the helpful suggestion as an answer. Thanks for your understanding. [See here](https://stackoverflow.com/help/someone-answers). – Deepak-MSFT Feb 10 '21 at 07:05
  • I was able to ignore IE11 for now and can use Edge/FF. If I can revisit the issue with IE, I will probably put the page into a new frame, to not have it loaded in compatibility view. – Ulgar80 Mar 11 '21 at 11:24

1 Answers1

0

From the description, I understand that JSPDF can work with the IE 11 or Edge document mode. But Sharepoint site contains the meta tag that loads the site in the IE 10 document mode. That breaks the JSPDF functionality.

To fix the issue, you need to load the site in the IE=edge mode.

You simply need to update your SharePoint's master page to target the latest version of IE, to update your master page, follow these simple steps.

Step 1: Download master page file.

  • Go to Site Settings.
  • Then to master pages and page layouts.
  • Look for the HTML version of your master page. If you are using Seattle as a master page for the site, look for the seattle.html file. If you're using the Oslo master page, then look for the oslo.html file.

Step 2: Update the master page code.

  • Open the downloaded file into a text editor of your choice, and look for the following meta-tag.

<meta http-equiv="X-UA-Compatible" content="IE=10" />

  • Update the value of the content attribute to have:

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

  • Now Save the file.

Note: The meta tag might be placed multiple times in your master page file, make sure to update them all.

Step 3: Upload master page file.

  • On the Master pages and page layouts click the ribbon bar, and click Upload Document button.

  • Now Choose the file you have just edited by clicking the Choose File button, then click OK to upload.

  • Another dialog will appear asking you to enter some information about the master page. Don't type anything, just click Check In button.

  • One last step you need to do is to make your changes available to all of your site visitors, which is to publish this master page.

  • To do that, Select your master page, and click the Publish button from the ribbon bar.

  • To proceed with publishing click OK on the next dialog.

Reference:

IE Compatibility with SharePoint and Office 365

Deepak-MSFT
  • 10,379
  • 1
  • 12
  • 19