Hyperlinks not working in XOD, converted from PDF

382 views
Skip to first unread message

David Compton

unread,
Jan 22, 2018, 5:43:15 PM1/22/18
to PDFTron WebViewer
Please refer to attached documents.  The original document is a simple one page PDF with 3 hyperlinks in it which work when clicked in Adobe Acrobat Pro (subject to responding positively to the Security Warning that pops up).   However the links do not work in the converted document (XOD) file.   Can you please advise why this is the case?

Kind regards,

David Compton
converted_document.xod
original_document.pdf

Matt Parizeau

unread,
Jan 23, 2018, 2:34:42 PM1/23/18
to PDFTron WebViewer
Hi David,

Thanks for sending the documents. It looks like the links aren't actual link annotations and Acrobat is detecting them at viewing time. You can do this at XOD conversion time by adding the option --url_links (or equivalent for PDFNet) which will detect and add link annotations for WebViewer. I confirmed that converting your file with that option will add the links in the XOD file.

Matt Parizeau
Software Developer
PDFTron Systems Inc.

David Compton

unread,
Jan 29, 2018, 4:28:06 PM1/29/18
to PDFTron WebViewer on behalf of Matt Parizeau
Hi Matt,

I've changed our conversion code to the following:

var xodOutputOptions = new pdftron.PDF.Convert.XODOutputOptions();
xodOutputOptions.GenerateURLLinks(true); // plain text URL's that are not link annotations will be converted into link annotations
.....
pdftron.PDF.Convert.ToXod(targetFullPathPdf, targetFullPathXod, xodOutputOptions);

But the links still are not clickable.  See attached reconverted file.

Is there something wrong with my code?

Thanks,

David

--
You received this message because you are subscribed to the Google Groups "PDFTron WebViewer" group.
To unsubscribe from this group and stop receiving emails from it, 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.

ltpworkshopagendajanuary_a53b6f0c-e994-4ac3-bbb7-472557703c40.xps

Matt Parizeau

unread,
Jan 29, 2018, 6:36:03 PM1/29/18
to PDFTron WebViewer
Hi David,

The attached file contains link annotations in the internal XFDF and I'm able to click the links without any issues. Are you able to reproduce the issue in an uncustomized WebViewer? If not would you be able to provide a sample project that reproduces the issue, or a link to your website where we can see the issue occurring?

Matt Parizeau
Software Developer
PDFTron Systems Inc.

On Monday, January 29, 2018 at 1:28:06 PM UTC-8, David Compton wrote:
Hi Matt,

I've changed our conversion code to the following:

var xodOutputOptions = new pdftron.PDF.Convert.XODOutputOptions();
xodOutputOptions.GenerateURLLinks(true); // plain text URL's that are not link annotations will be converted into link annotations
.....
pdftron.PDF.Convert.ToXod(targetFullPathPdf, targetFullPathXod, xodOutputOptions);

But the links still are not clickable.  See attached reconverted file.

Is there something wrong with my code?

Thanks,

David

David Compton

unread,
Jan 30, 2018, 2:16:09 PM1/30/18
to PDFTron WebViewer on behalf of Matt Parizeau, Michael Craig
Hi Matt,

I've investigated further and the links do indeed work from the web platform version of our app.  However the links do not work in the same document on our iPad app.  Both apps are produced from the same code base using Ionic.  You can verify both platforms as follows:

Web App:  go to app.docsontap.com.au and select the trial option (twice). 
iOS App: install Docs On Tap V2 from the app store - select the trial option (twice) when the app opens for the first time

For both apps:
1.  Open the navigation sidebar by tapping the "hamburger" icon in the top left.
2.  Tap the "home" button
3.  Navigate to Docs On Tap Demo | Sample Files | Folder 1 | Board Papers | Old Papers
4.  Select the "Test URL Links" document

I've also tried our Windows app (using Ionic and Electron) and our Android app - the links work OK in both of those.  Finally I checked using the web app in Safari on the iPad and the link worked fine.

Do you have any suggestions on why the links don't work in the iOS version?

Kind regards,

David



On 30 January 2018 at 10:36, Matt Parizeau via PDFTron WebViewer <pdfnet-webviewer+APn2wQfzwjN3K1P...@googlegroups.com> wrote:
Hi David,

The attached file contains link annotations in the internal XFDF and I'm able to click the links without any issues. Are you able to reproduce the issue in an uncustomized WebViewer? If not would you be able to provide a sample project that reproduces the issue, or a link to your website where we can see the issue occurring?

Matt Parizeau
Software Developer
PDFTron Systems Inc.

On Monday, January 29, 2018 at 1:28:06 PM UTC-8, David Compton wrote:
Hi Matt,

I've changed our conversion code to the following:

var xodOutputOptions = new pdftron.PDF.Convert.XODOutputOptions();
xodOutputOptions.GenerateURLLinks(true); // plain text URL's that are not link annotations will be converted into link annotations
.....
pdftron.PDF.Convert.ToXod(targetFullPathPdf, targetFullPathXod, xodOutputOptions);

But the links still are not clickable.  See attached reconverted file.

Is there something wrong with my code?

Thanks,

David

On 24 January 2018 at 06:34, Matt Parizeau via PDFTron WebViewer <pdfnet-webviewer+APn2wQfzwjN3K1PXhwB2EpteOBUOrXzBt3Iu_yTiKO...@googlegroups.com> wrote:
Hi David,

Thanks for sending the documents. It looks like the links aren't actual link annotations and Acrobat is detecting them at viewing time. You can do this at XOD conversion time by adding the option --url_links (or equivalent for PDFNet) which will detect and add link annotations for WebViewer. I confirmed that converting your file with that option will add the links in the XOD file.

Matt Parizeau
Software Developer
PDFTron Systems Inc.


On Monday, January 22, 2018 at 2:43:15 PM UTC-8, David Compton wrote:
Please refer to attached documents.  The original document is a simple one page PDF with 3 hyperlinks in it which work when clicked in Adobe Acrobat Pro (subject to responding positively to the Security Warning that pops up).   However the links do not work in the converted document (XOD) file.   Can you please advise why this is the case?

Kind regards,

David Compton

--
You received this message because you are subscribed to the Google Groups "PDFTron WebViewer" group.
To unsubscribe from this group and stop receiving emails from it, 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.

Matt Parizeau

unread,
Jan 30, 2018, 6:50:31 PM1/30/18
to PDFTron WebViewer
Hi David,

I have a suspicion about what might be the problem. It looks like in the past we had some problems on iOS devices with mouseup actions on widget annotations. We made it switch to use touchend in this case but it looks like we didn't apply that change for links.

You could try adding the following code to your config file which will basically turn the touchend into a mouseup and may fix the issue for you. If this works then we can fix that inside WebViewer so that it isn't a problem in future versions.

var createInnerElement = Annotations.Link.prototype.createInnerElement;
Annotations.Link.prototype.createInnerElement = function() {
 
var ele = createInnerElement.apply(this, arguments);
 
if (window.utils.mouseUpEventBug) {
   
var me = this;
    ele
.on('touchend', function() {
      me
.trigger('mouseup');
   
});
 
}
 
return ele;
};

Matt Parizeau
Software Developer
PDFTron Systems Inc.

On Tuesday, January 30, 2018 at 11:16:09 AM UTC-8, David Compton wrote:
Hi Matt,


On 24 January 2018 at 06:34, Matt Parizeau via PDFTron WebViewer <pdfnet-webviewer+APn2wQfzwjN3K1PXhwB2EpteOBUOrXzBt3Iu_yTiKOGMlKG@googlegroups.com> wrote:
Hi David,

Thanks for sending the documents. It looks like the links aren't actual link annotations and Acrobat is detecting them at viewing time. You can do this at XOD conversion time by adding the option --url_links (or equivalent for PDFNet) which will detect and add link annotations for WebViewer. I confirmed that converting your file with that option will add the links in the XOD file.

Matt Parizeau
Software Developer
PDFTron Systems Inc.


On Monday, January 22, 2018 at 2:43:15 PM UTC-8, David Compton wrote:
Please refer to attached documents.  The original document is a simple one page PDF with 3 hyperlinks in it which work when clicked in Adobe Acrobat Pro (subject to responding positively to the Security Warning that pops up).   However the links do not work in the converted document (XOD) file.   Can you please advise why this is the case?

Kind regards,

David Compton

--
You received this message because you are subscribed to the Google Groups "PDFTron WebViewer" group.
To unsubscribe from this group and stop receiving emails from it, 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.

David Compton

unread,
Feb 1, 2018, 12:47:44 PM2/1/18
to PDFTron WebViewer on behalf of Matt Parizeau
Hi Matt,

I tried that, but unfortunately it did not fix the problem.  Any other suggestions?

Kind regards,

David

Matt Parizeau

unread,
Feb 1, 2018, 8:04:01 PM2/1/18
to PDFTron WebViewer
Hi David,

Can you try this build to see if it resolves the problem. http://www.pdftron.com/ID-zJWLuhTffd3c/WebViewer/WebViewer_3.1.0.63783.zip
If not then we'll be able to look more closely at the problem either tomorrow or early next week.

Matt Parizeau
Software Developer
PDFTron Systems Inc.

On Thursday, February 1, 2018 at 9:47:44 AM UTC-8, David Compton wrote:
Hi Matt,

I tried that, but unfortunately it did not fix the problem.  Any other suggestions?

Kind regards,

David

David Compton

unread,
Feb 5, 2018, 12:47:16 PM2/5/18
to PDFTron WebViewer on behalf of Matt Parizeau
Hi Matt,

Thanks for the build.  I tried it and unfortunately it still does not work.  When I tap on the links the only thing that happens is that the bottom and top toolbar display.  If I long press then the same "toolbar" appears as if I long press on any other piece of text within the document.  Just in case it makes any difference here are the manual changes that I make to customise the web viewer for our app:

# Add the following to MobileReaderControl.css
/* Start HS Modifications */
span.comment-text {
white-space: pre-wrap;
}
/* End HS Modifications */

# Make the following modification to src\assets\pdftron\html5\CoreControls.js
Replace "Insert Text Here" with ""

# Make the following modification to src\assets\pdftron\html5\MobileReaderControl.js
1. Comment out ondoubletap code except for the last line: evt.stopImmediatePropagation();

2. Modify setCurrentToMinZoom as follows:

setCurrentToMinZoom: function() {
var me = this;

me.forEachPageInWrapper(me.currentPageIndex, function(i) {
/* Start HS modifications */
me.docViewer.setPageZoom(i, me.minZooms[i], true);
/* End HS modifications */
});
},

And here is the contents of my "readerControlConfigCustom.js file:

(function () {
$.extend(ReaderControl.config, {
// customScript : 'defaultScriptExtension.js',
// customStyle : 'defaultStyleExtension.css',
serverURL: null, // We set this to null as we handle the saving and loading to PouchDb separately
});

// Hide the Save Annotations button from the web viewer settings page
$('#saveAnnotationsBtn').parent().hide();
// Hide the Annotations / Bookmarks toggle buttons
$('.annotBookmarkToggleGroup').remove();
//Change the icon for the button that shows the web viewer settings
$('#optionsButton span').removeClass('show_lines');
$('#optionsButton span').addClass('adjust_alt');
//Initially hide the printButton - we then conditionally show it from the file-viewer
$('#printButton').hide();

$(document).on('viewerLoaded', function () {
readerControl.docViewer.on('mouseLeftUp', function () {
setTimeout(function () {
if (typeof readerControl.showAnnotationEditPopup === 'function') {
readerControl.showAnnotationEditPopup();
}
}, 0)
});
});

// zoomChanged event is not available in mobile viewer so we create our own
var setPageZoom = CoreControls.DocumentViewer.prototype.setPageZoom;
CoreControls.DocumentViewer.prototype.setPageZoom = function (pageIndex, zoom, isResettingZoom) {
setPageZoom.apply(this, arguments);
readerControl.fireEvent('zoomChanged', [zoom, {
pageIndex: pageIndex,
isResettingZoom: isResettingZoom
}]);
};

if (window.utils.getCanvasMultiplier() > 2) {
window.utils.setCanvasMultiplier(2);
}

})();


Regards,

David

On 2 February 2018 at 12:04, Matt Parizeau via PDFTron WebViewer <pdfnet-webviewer+APn2wQfzwjN3K1P...@googlegroups.com> wrote:
Hi David,

Can you try this build to see if it resolves the problem. http://www.pdftron.com/ID-zJWLuhTffd3c/WebViewer/WebViewer_3.1.0.63783.zip
If not then we'll be able to look more closely at the problem either tomorrow or early next week.

Matt Parizeau
Software Developer
PDFTron Systems Inc.

On Thursday, February 1, 2018 at 9:47:44 AM UTC-8, David Compton wrote:
Hi Matt,

I tried that, but unfortunately it did not fix the problem.  Any other suggestions?

Kind regards,

David

Matt Parizeau

unread,
Feb 6, 2018, 7:38:32 PM2/6/18
to PDFTron WebViewer
Hi David,

I've done some more digging and it appears that the link is actually being triggered without any custom code necessary, but because it's inside a native app it doesn't know what to do with the window.open call. This question led me to the solution https://stackoverflow.com/questions/43928676/window-open-is-not-working-in-ionic-for-ios.

Basically you need to add the "In App Browser" plugin to your project and make a small tweak to your config file:
window.open = function(target) {
  window
.parent.open(target, '_system');
};

This sets the iframe's window.open to the parent page which has the Cordova plugin enabled. After doing this in a sample ionic app the links were working for me.

Matt Parizeau
Software Developer
PDFTron Systems Inc.


On Monday, February 5, 2018 at 9:47:16 AM UTC-8, David Compton wrote:
Hi Matt,

On 2 February 2018 at 12:04, Matt Parizeau via PDFTron WebViewer <pdfnet-webviewer+APn2wQfzwjN3K1PXhwB2EpteOBUOrXzBt3Iu_yTiKOGMlKG@googlegroups.com> wrote:
Hi David,

Can you try this build to see if it resolves the problem. http://www.pdftron.com/ID-zJWLuhTffd3c/WebViewer/WebViewer_3.1.0.63783.zip
If not then we'll be able to look more closely at the problem either tomorrow or early next week.

Matt Parizeau
Software Developer
PDFTron Systems Inc.

On Thursday, February 1, 2018 at 9:47:44 AM UTC-8, David Compton wrote:
Hi Matt,

I tried that, but unfortunately it did not fix the problem.  Any other suggestions?

Kind regards,

David

David Compton

unread,
Feb 14, 2018, 12:49:33 PM2/14/18
to PDFTron WebViewer on behalf of Matt Parizeau
Hi Matt,

I installed the plugin and added the specified code to my readerControlConfigCustom file.  But it does not seem to make any difference.  Did I add the code in the wrong place?

Kind regards,

David

PDFTron Systems Inc.

Matt Parizeau

unread,
Feb 15, 2018, 2:30:48 PM2/15/18
to PDFTron WebViewer
Hi David,

I based it on your sample project here https://github.com/daveywc/pdftron-ionic, and here are the steps I took.

1. Ran the two commands listed here to install the plugin: https://ionicframework.com/docs/native/in-app-browser/
ionic cordova plugin add cordova-plugin-inappbrowser
npm install
--save @ionic-native/in-app-browser

2. Changed home.ts to point to the XOD file with links that you shared.

3. Changed home.ts to add a config option.

4. Added a config file with the code:
window.open = function(target) {
  window
.parent.open(target, '_system');
};

Then I ran the project on the iPhone X 11.2 simulator and I was able to click the links and have them open in the browser.

You might want to confirm that the config file is actually being loaded successfully by adding an alert inside of it and making sure you see the alert popup when running the project. Note that the config path should be relative to the index.html file, not the home.ts file.

Matt Parizeau
Software Developer
PDFTron Systems Inc.

On Wednesday, February 14, 2018 at 9:49:33 AM UTC-8, David Compton wrote:
Hi Matt,

I installed the plugin and added the specified code to my readerControlConfigCustom file.  But it does not seem to make any difference.  Did I add the code in the wrong place?

Kind regards,

David
PDFTron Systems Inc.

David Compton

unread,
Feb 19, 2018, 12:53:13 PM2/19/18
to PDFTron WebViewer on behalf of Matt Parizeau
Hi Matt,

I'm feeling really stupid on this.... but can you show me what the code for step 3 " Changed home.ts to add a config option" looks like?

Thanks,

David

On 16 February 2018 at 06:30, Matt Parizeau via PDFTron WebViewer <pdfnet-webviewer+APn2wQfzwjN3K1P...@googlegroups.com> wrote:
Hi David,

I based it on your sample project here https://github.com/daveywc/pdftron-ionic, and here are the steps I took.

1. Ran the two commands listed here to install the plugin: https://ionicframework.com/docs/native/in-app-browser/
ionic cordova plugin add cordova-plugin-inappbrowser
npm install
--save @ionic-native/in-app-browser

2. Changed home.ts to point to the XOD file with links that you shared.

3. Changed home.ts to add a config option.

4. Added a config file with the code:
window.open = function(target) {
  window
.parent.open(target, '_system');
};

Then I ran the project on the iPhone X 11.2 simulator and I was able to click the links and have them open in the browser.

You might want to confirm that the config file is actually being loaded successfully by adding an alert inside of it and making sure you see the alert popup when running the project. Note that the config path should be relative to the index.html file, not the home.ts file.

Matt Parizeau
Software Developer
PDFTron Systems Inc.

On Wednesday, February 14, 2018 at 9:49:33 AM UTC-8, David Compton wrote:
Hi Matt,

I installed the plugin and added the specified code to my readerControlConfigCustom file.  But it does not seem to make any difference.  Did I add the code in the wrong place?

Kind regards,

David

Matt Parizeau

unread,
Feb 19, 2018, 7:21:08 PM2/19/18
to PDFTron WebViewer
Hi David,

For step 3 all you need to do is add config: 'path/to/config/file.js' and then create a file at that path with the specified code. You can read more about config files here https://www.pdftron.com/webviewer/demo/tutorials/getting-started-config-files.html

Matt Parizeau
Software Developer
PDFTron Systems Inc.

On Monday, February 19, 2018 at 9:53:13 AM UTC-8, David Compton wrote:
Hi Matt,

I'm feeling really stupid on this.... but can you show me what the code for step 3 " Changed home.ts to add a config option" looks like?

Thanks,

David
On 16 February 2018 at 06:30, Matt Parizeau via PDFTron WebViewer <pdfnet-webviewer+APn2wQfzwjN3K1PXhwB2EpteOBUOrXzBt3Iu_yTiKOGMlKG@googlegroups.com> wrote:
Hi David,

I based it on your sample project here https://github.com/daveywc/pdftron-ionic, and here are the steps I took.

1. Ran the two commands listed here to install the plugin: https://ionicframework.com/docs/native/in-app-browser/
ionic cordova plugin add cordova-plugin-inappbrowser
npm install
--save @ionic-native/in-app-browser

2. Changed home.ts to point to the XOD file with links that you shared.

3. Changed home.ts to add a config option.

4. Added a config file with the code:
window.open = function(target) {
  window
.parent.open(target, '_system');
};

Then I ran the project on the iPhone X 11.2 simulator and I was able to click the links and have them open in the browser.

You might want to confirm that the config file is actually being loaded successfully by adding an alert inside of it and making sure you see the alert popup when running the project. Note that the config path should be relative to the index.html file, not the home.ts file.

Matt Parizeau
Software Developer
PDFTron Systems Inc.

On Wednesday, February 14, 2018 at 9:49:33 AM UTC-8, David Compton wrote:
Hi Matt,

I installed the plugin and added the specified code to my readerControlConfigCustom file.  But it does not seem to make any difference.  Did I add the code in the wrong place?

Kind regards,

David

David Compton

unread,
Mar 8, 2018, 1:08:03 PM3/8/18
to PDFTron WebViewer on behalf of Matt Parizeau
Hi Matt,

Just wanted to let you know that I finally got this to work for me.  It took a while though.... The problem was nothing to do with my config file setup - that was all OK.   

I discovered that the links worked in the sample app that I had provided you (once I installed the in-app-browser plugins), but still did not work in my production app.  Hours of eliminating all differences between the two projects later, I finally worked out that the reason was that I was still using the custom build that you had provided early on  in this thread  (WebViewer_3.1.0.63783).  When I reverted to the standard version 3.1 all worked again.  How I wish that I'd worked that out a couple of weeks ago.  Anyway all is now working.  I'm hoping that whatever changes were in that custom build do not make it into the next production release.

Anyway thanks for your help - I'm just happy to finally have the issue resolved.

Kind regards,

David

On 20 February 2018 at 11:21, Matt Parizeau via PDFTron WebViewer <pdfnet-webviewer+APn2wQfzwjN3K1P...@googlegroups.com> wrote:
Hi David,

For step 3 all you need to do is add config: 'path/to/config/file.js' and then create a file at that path with the specified code. You can read more about config files here https://www.pdftron.com/webviewer/demo/tutorials/getting-started-config-files.html

Matt Parizeau
Software Developer
PDFTron Systems Inc.

On Monday, February 19, 2018 at 9:53:13 AM UTC-8, David Compton wrote:
Hi Matt,

I'm feeling really stupid on this.... but can you show me what the code for step 3 " Changed home.ts to add a config option" looks like?

Thanks,

David

Matt Parizeau

unread,
Mar 8, 2018, 1:31:00 PM3/8/18
to PDFTron WebViewer
Hi David,

Glad you were able to get it working and sorry I wasn't clear earlier that the build I had sent was a one-off build to test a potential fix. After you reported that it didn't work for you we did not go ahead with merging it to our stable builds so it shouldn't be a problem in any future releases.

Matt Parizeau
Software Developer
PDFTron Systems Inc.


On Thursday, March 8, 2018 at 10:08:03 AM UTC-8, David Compton wrote:
Hi Matt,

Just wanted to let you know that I finally got this to work for me.  It took a while though.... The problem was nothing to do with my config file setup - that was all OK.   

I discovered that the links worked in the sample app that I had provided you (once I installed the in-app-browser plugins), but still did not work in my production app.  Hours of eliminating all differences between the two projects later, I finally worked out that the reason was that I was still using the custom build that you had provided early on  in this thread  (WebViewer_3.1.0.63783).  When I reverted to the standard version 3.1 all worked again.  How I wish that I'd worked that out a couple of weeks ago.  Anyway all is now working.  I'm hoping that whatever changes were in that custom build do not make it into the next production release.

Anyway thanks for your help - I'm just happy to finally have the issue resolved.

Kind regards,

David
On 20 February 2018 at 11:21, Matt Parizeau via PDFTron WebViewer <pdfnet-webviewer+APn2wQfzwjN3K1PXhwB2EpteOBUOrXzBt3Iu_yTiKOGMlKG@googlegroups.com> wrote:
Hi David,

For step 3 all you need to do is add config: 'path/to/config/file.js' and then create a file at that path with the specified code. You can read more about config files here https://www.pdftron.com/webviewer/demo/tutorials/getting-started-config-files.html

Matt Parizeau
Software Developer
PDFTron Systems Inc.

On Monday, February 19, 2018 at 9:53:13 AM UTC-8, David Compton wrote:
Hi Matt,

I'm feeling really stupid on this.... but can you show me what the code for step 3 " Changed home.ts to add a config option" looks like?

Thanks,

David
Reply all
Reply to author
Forward
0 new messages