Hello,
We’re investigating some problems with PDF.js (both cosmetic issues involving the toolbar collapsing badly in small embed situations, and problems with certain PDFs rendering incorrectly). The first thing I’d like to try is simply upgrading to the latest version. However, I wasn’t sure if we had a standard way of achieving this. The files created by building PDF.js don’t seem to exactly match up with those included with UV (for example, UV has .min versions that don’t seem to be built by default, and the build includes public resources that I’m not finding in an obvious place in UV).
What’s the best procedure for upgrading PDF.js? Is this something that could be automated with Bower? (I’m not that familiar with Bower, so apologies if this is out of scope). Any advice?
thanks,
Demian
--
You received this message because you are subscribed to the Google Groups "Universal Viewer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to universalview...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Thanks! I’ll play around a little bit and see if I can figure out a way to automate this. If nothing else, it will be a good excuse to learn more about Bower, Grunt, etc.
- Demian
I’m making some progress on loading PDF.js using Bower. You can see my work so far here:
I haven’t opened a pull request yet as I’m still trying to reconcile our viewer.js with PDF.js’s pdf_viewer.js and sort out the CSS side of things. Hopefully I’ll get that done tomorrow when I have a bit more time… but in the meantime, if you see anything glaringly wrong with my approach so far, please let me know!
- Demian
From: Edward Silverton [mailto:e.sil...@gmail.com]
Sent: Tuesday, July 21, 2015 1:18 PM
To: Demian Katz
Cc: univers...@googlegroups.com
Subject: Re: Upgrading PDF.js
These are the google closure compiler commands for minifying the files:
I’ve spent some more time on this, though I’m a bit frustrated with the pdfjs-dist repository, as it does not include the full viewer example that forms the basis of the PDF extension. Thus, I can only get so far with Bower alone.
Thanks for the tip about sync:bowerComponents – I was trying to use that yesterday but didn’t realize it was triggered by bower; I was just scratching my head over why it wasn’t being triggered by grunt build. Now that I understand, I’ve moved the copy command back.
Regarding the extension-specific commands, I’ll give that some more thought once I’ve actually got everything working to my satisfaction.
Regarding dev builds vs. release builds, how do I test each type? I always do “grunt build ; grunt serve” – is there a different way to get the dev version? In any case, I made the change to PDFCenterPanel.ts to eliminate the conditional clause around the location of pdf.worker.min.js because that file will now always be in the lib directory due to loading from Bower. The previous code loaded the minified version regardless of mode, it just loaded it from different directories. If the goal of development mode is to load a non-minified version, then we need a different conditional there.
My biggest step forward today is to update the viewer.js file to a newer version. However, because of the limitations of pdfjs-dist mentioned earlier, I had to checkout the main pdf.js repo and build it in order to get the latest file. This revealed to me that the previous viewer.js had been slightly customized inside UV. I’ve made some changes here to eliminate those customizations so we can upgrade in future with drop-in replacement:
Using the DEFAULT_URL global isn’t pretty, but I think it’s more maintainable long term. If we want a better approach, maybe we can open a pdf.js pull request to add a better mechanism for overriding this value.
My next step is to update the viewer.html and related CSS/image files. This is going to be trickier, I suspect, because the pdf.js viewer.html has a complete <body> tag, and the UV version needs to strip off that stuff. It would be nice to have a way to automatically update this, but there may not be an adequate solution.
I also thought about the possibility of trying to load the regular pdf.js repo through Bower, then compile it and move the pieces into position… but I couldn’t get that to work, so maybe this just needs to remain a manual process for now. If you agree, we should at least write up some documentation on the steps – I’m happy to do that, either as a README.md in the PDF extension or as a wiki page. Let me know your thoughts!
thanks,