Trying to get the javascript errors using selectpdf - selectpdf

Using selectPDF in C# to convert URLs to PDF. It's obvious there are some javascript errors. Is there a way to get the errors when the conversion happens so I can see what's going on?

I had the same problem and added the following code to the top of my page to figure out the error. In my case the error was "SyntaxError: Unexpected token 'const'" -- whatever browser that SelectPDF uses behind the scenes apparently doesn't support ES6.
<script>
window.onerror = function (msg, url, lineNo, columnNo, error) {
document.write('<p>Message: ' + msg + '</p>');
document.write('<p>Script Url: ' + url + '</p>');
document.write('<p>Line: ' + lineNo + '</p>');
};
</script>

Disclaimer: I work for SelectPdf.
Sorry for the late reply. Maybe it could help other people in the future.
To get the console log after conversion check converter.ConversionResult.ConsoleLog.
SelectPdf supports several rendering engines. The default WebKit rendering engine can render ES5 javascript. Blink engine can render ES6.

An additional approach is to use an old WebKit ES5 browser to view the page that is having problems - this allows interactive debugging and can help narrow down problems quickly.
I had success recently using Opera 15.0. Archived versions of Opera are currently available for download at: https://get.geo.opera.com/pub/opera/desktop/

Related

Basic create-react-app setup throwing error for react-stripe-elements

I've tried this locally as well and gotten the same error, but as you can see in from this basic code snippet in code sand box instance I'm getting this error:
Please load Stripe.js (https://js.stripe.com/v3/) on this page to use react-stripe-elements. If Stripe.js isn't available yet (it's loading asynchronously, or you're using server-side rendering), see https://github.com/stripe/react-stripe-elements#advanced-integrations
This is happening even though I'm simply including the StripeProvider with a key at root. I see that this is clearly not a problem in the jsfiddle example from the docs, which doesn't use create-react-app. Has anyone else run into this issue and found a solution?
You should just need to add a script tag to your index.html:
<script src="https://js.stripe.com/v3/"/>

Templates are not loading in IE11

My ui-router and custom directive templates are not loading in Internet Explorer 11. This is the error for each one:
[$compile:tpload] Failed to load template: blah/blah.html (HTTP status: undefined undefined)
Everything is working fine in Chrome, Firefox and Edge.
Any pointers or guesses of why this maybe happening would be greatly appreciated.
For JavaScript, In Internet Explorer, there is normally an issue because of 'use-strict' mode. If your application appears to somewhere have an object with two properties of the same name, 'use-strict' will cause it to crash.
For HTML, there must be a missing closing or an opening tag which is not rendering the pages
OK, this is fixed. There was an ES6 endsWith() method being used which is unsupported in IE11. There was no error regarding this in the console - I found the issue by ensuring "Break on all exceptions" was select in the IE dev tools debugger. The fix was to simply add a polyfill https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith

PHPStorm plugin query

I have the following line of code in an AngularJS project
$scope.listOfServices = ([].concat(...arrayOfResults.map(item =>item.data.trainServices))).filter(item => item);
This code works perfectly, however PHPStorm is kicking off saying its full of errors and it expects a new line and so on. This means on the rare occasion I reformat my code as I had a late night coding and got messy, PHPStorm moves the code around and breaks it.
I have AngularJS plugins, JavaScript plugins etc. What plugin can I install to STOP PHPStorm thinking the above line is broken.
You are right!!!
myFunction(...iterableObj); = Spread-Operator - This should be supported by PHPStorm JavaScript syntax validator.
You may going to create a bug issue over here: youtrack.jetbrains.com. PHPStorm supports JavaScript highlight / syntax autfill / validations so there should be no need for a third party plugin.

Angular application works on Chrome but not Safari

My website works fine on Chrome but is broken on Apple Mobile Safari.
I have troubleshot the situation and have found that it is the below line of code placed in side of my angular controller that is causing the problem. With out this code everything works fine.
The code takes all images on the page and puts them inside of an array. Anything I can do differently to ensure proper compatibility? Thank you!
$scope.load_picture_cotent = function () {
$scope.pictures = Array.from(
document.querySelectorAll
('div.album [style^="background-image"]')).map
(el=>el.style.backgroundImage.replace(/url\((.*)\)/,'$1')
.replace(/"/g,'')
.replace(/thumbnails/,'highresolution'));
console.log($scope.pictures);
}
You can also view the website here.
Please let me know if you need any more information or would like me to expand my post to include more information.
you are using ECMA 2015 lambda notation, try to wrap this with babel and try it again, did you check the browsers compatibility status with ECMA Script 2015?
Thank you bretanac93.
He was right, I was using a newer version of Javascript than is currently supported by browsers.
He recommended I use Babel which is a compiler that converts new Javascript to a compatible Javascript.
I used babel to compile the compatibility javascript and it works like a charm.

getting 'using the in-browser JSX transformer. Be sure to precompile your JSX for production' when using reactjs

getting "You are using the in-browser JSX transformer. Be sure to precompile your JSX for production - http://facebook.github.io/react/docs/tooling-integration.html#jsx" Error in browser console but application working fine using reactjs. how to remove this error?
Well the issue is that rather than pre-compiling your JSX, you are having react parse it in the browser (hence the error message). The reason this is bad is that it is quite slow. To get rid of the error message I would look into the tooling it suggests in the link (I would recommend Babel) to compile your JSX in advance so the browser doesn't have to do it every single time. This will increase the performance of your page.

Resources