Readme should have `npm install pdf.js` on how to use... And a better tutorial. (I've added a suggestion on how could be improved)
See original GitHub issueI think is a big oversight forgetting to add this, I had to open package.json to figure out if was even on npm… I haven’t seen a readme without npm install ...
for long time. and this seem like a big project.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:11
- Comments:15 (2 by maintainers)
Top Results From Across the Web
ngx-extended-pdf-viewer - npm
Embedding PDF files in your Angular application. Highly configurable viewer including the toolbar, sidebar, and all the features you're used to.
Read more >Suggest improvement to npm installation in README.txt
1. Install Node.js and npm, the Node.js package manager. Detailed instructions are available on the "npm quick start guide": https://github.com/ ...
Read more >Essential Sections for Better Documentation of a README ...
Most of my days, I read documents—software sources—then ...
Read more >Creating Server-side Rendered Vue.js Apps Using Nuxt.js
install vue-cli globally npm install -g vue-cli # create a project using a ... However, there are some cases where you may need...
Read more >Writing the Perfect Readme for Your Node Library
And use code blocks, most Markdown templates for places where your library will be published will accept language suggestions, so add them ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Tutorial could be so much better. I’m talking about https://mozilla.github.io/pdf.js/examples/index.html#interactive-examples . When I first read I feel like I’m in 2010 using jquery…
How to actually use it with yarn/npm
Installation
Install:
yarn add pdfjs-dist @types/pdfjs-dist
(replaceyarn add
fornpm install
if you use npm. Also remove@types/pdfjs-dist
if you don’t use typescript. (anyone still uses npm or vanilla js??)Setup
Webpack specific code (if you use yarn, you most likely use webpack or a bundler) so I think this example makes more sense than using the cdn
Usage
Add a
<canvas id="pdf-canvas"/>
to your HTML.Then in a js file put:
This is what I’d expect from a tutorial TBH. Yes, I complain about it, but I also give you a way to improve.
Why I think this is better?
Minor details in guides
All these small details gives me the impression of a poorly written library. (even if it might not be)
Why in the world would you switch width, height order to height, width? Just wasted time to fix bug where I expected width and height ordering.
Promises async await
Mentions await in many places, but tutorial is
loadingTask.promise.then
… let’s write some nice code withasync
await
Still on es5?
var
s, no arrow functions…Naming
const loadingTask = pdfjsLib.getDocument(props.url)
, loadingTask is weirdthe-canvas
… come on…I know this is closed, but I have to also agree with @stevemarksd. Despite being very popular, there is a lot of room for improvement in this library’s docs. Googling this library and how to use it almost always lands on the mozilla.github.io page, which does not have anything anywhere about using yarn or npm. Steve’s answer gave me enough information about how to solve it for my own use. Only after coming here did I find out it was buried in the FAQ under a question completely unrelated to using a package manager. And even then, it only tells me something I already knew, which was to install the
pdfjs-dist
library, but nothing about how to get it to actually work after installing.You don’t have to include an example for every webpack config possible, you just need any example of importing the lib and using it manually without knowing the inner workings of the core, and most people can figure it out from there.
Ideally, like most modern frameworks, it’s desirable to be as simple as this:
That is good enough and covers most use cases without going into specifics of webpack configs etc. However, I’m assuming due to the inner workings of the core, it requires setting up stuff with the worker manually. But as long as you can show one example of importing/requiring the pieces and putting them together to make a working pdfjsLib, people can figure out the specifics for their dev environment and then follow the examples from there.