IE11 DOMParser syntax error when loading annotations

701 views
Skip to first unread message

Juri Rosenkilde

unread,
Mar 9, 2016, 1:48:48 PM3/9/16
to PDFTron WebViewer
I am getting a syntax error when attempting to load annotations in IE11 (using version 2.0 of webviewer). I do not get the problem in Chrome, which loads the annotations just fine.

The line that gives me the syntax error is the following in CoreControls.js:
return "string" === typeof a ? (new DOMParser).parseFromString(a, "text/xml") : a

I did a bit of searching around on google, and it appears that there might be a problem with the DOMParser and IE11. I tried replacing the code in CoreControls.js with the following:

if ("string" === typeof a){
var xmlDoc;
try {
var parser = new DOMParser;
xmlDoc = parser.parseFromString(a, "text/xml")
} catch (err) {
if (a.indexOf("<?") == 0)xmlDocStr = a.substr(a.indexOf("?>") + 2);
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xmlDoc.loadXML(a)
}
return xmlDoc;
} else {
return a;
}

which worked!

I dont really feel comfortable editting the CoreControls.js, since I dont really have much of a clue as to what exactly is going on in it. So I just wanted to get your opinion on this strange error. Are you aware of the problem, or am I the first one to report it?

Anatoly Kudrevatukh

unread,
Mar 9, 2016, 3:37:03 PM3/9/16
to PDFTron WebViewer
Thank you for reporting this issue. 

Could you provide us steps to reproduce it?

Juri Rosenkilde

unread,
Mar 10, 2016, 2:19:20 PM3/10/16
to PDFTron WebViewer
Basically I have done nothing except enabling annotations and then attempt to load them from my server. I am, however, using a custom setInternalAnnotationsTransform but the only thing I have changed from the example in the devolper guide, is the format of the query url. 

I have attached my custom config file, so you can see for yourself.

My WebViewer script on my page looks like this

var myWebViewer = new PDFTron.WebViewer({
type: 'html5',
html5Path: 'lib/html5/ReaderControl.html',
config: 'pdftron.config.js',
initialDoc: '../proxy/resource/terms/xod/6650-4',
documentId: '6650-4',
enableAnnotations: true,
streaming: false
}, viewerElement);
pdftron.config.js

Anatoly Kudrevatukh

unread,
Mar 10, 2016, 2:27:35 PM3/10/16
to PDFTron WebViewer
Thank you for sharing this code.

Would you be also able to send us the xfdf string returned from the server? We would like to evaluate it to see if it's valid and we should actually have this fallback.

Juri Rosenkilde

unread,
Mar 14, 2016, 12:42:58 PM3/14/16
to PDFTron WebViewer
Sure. I have attached an example of one of the annotation xfdf-strings that our server returns. It fails on all the strings.

Incidentally, I am perfectly able to save new annotations in IE11, it is only when I attempt to load them subsequently that it fails.
annotations.txt

Matt Bojey

unread,
Mar 15, 2016, 2:16:28 PM3/15/16
to PDFTron WebViewer
Your proposed solution looks like it would just hide the problem.  This will make IE behave like Chrome or FF where it will parse the XML up to the error but still fail, just silently.  Why are you doing data.firstChild.textContent in your setInternalAnnotationsTransform function?  When you debug it what is data.firstChild.textContent at that point?  It should just be the XML string but when we do it we do not see that.   

Matt

Juri Rosenkilde

unread,
Mar 16, 2016, 12:33:26 PM3/16/16
to PDFTron WebViewer
To be honest I did not really know what I was doing in the config. I found the code-snippet somewhere and just I assumed i needed the following part to make the annotationsLoaded event fire properly or whatever.

readerControl.docViewer.getAnnotationManager().importAnnotationsAsync(data.firstChild.textContent, function (annotations) {
 readerControl
.fireEvent('annotationsLoaded');
});

It appears that this is what is causing the problem. If I remove those lines it works and I dont need my"fix" in CoreControls.js – which as you say only hides the problem anyway.

Thanks for the help.



Message has been deleted

Justin Jung

unread,
Oct 10, 2017, 6:57:45 PM10/10/17
to PDFTron WebViewer
To clarify, what is the "io_png_overview" received with version draw2d_GPL_6.1.66?
Is this a sample that you received from WebViewer or PDFNet package?

Justin Jung
Software Developer
PDFTron Systems Inc.

Talia Oliel

unread,
Oct 11, 2017, 2:53:39 PM10/11/17
to PDFTron WebViewer on behalf of Justin Jung
It is one of the examples received with the package version 6.1.66 and also can be found in the following link

Thanks
Talis

--
You received this message because you are subscribed to a topic in the Google Groups "PDFTron WebViewer" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pdfnet-webviewer/26IjbIyRhSw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pdfnet-webviewer+unsubscribe@googlegroups.com.
To post to this group, send email to pdfnet-webviewer@googlegroups.com.
Visit this group at https://groups.google.com/group/pdfnet-webviewer.
For more options, visit https://groups.google.com/d/optout.

Talia Oliel

unread,
Oct 11, 2017, 2:53:41 PM10/11/17
to PDFTron WebViewer on behalf of Justin Jung
I think this question belong to a different group :), sorry

On Wed, Oct 11, 2017 at 6:19 AM, Talia Oliel <talia...@gmail.com> wrote:
It is one of the examples received with the package version 6.1.66 and also can be found in the following link

Thanks
Talis
Reply all
Reply to author
Forward
0 new messages