pdfjs

How to get pdf title using pdf.js? [duplicate]

馋奶兔 提交于 2019-12-11 10:53:54
问题 This question already has answers here : JavaScript closures. Access in loop to current i, j variables [duplicate] (5 answers) Closed 4 years ago . The question is: How can I get the name of the pdf file using pdf.js? I'm running a variation of a pdf.js example from node, and I was wondering if it's at all possible to get it. I've been searching through pdf.js's docs/source, but couldn't find anything obvious. I'm using this code, which (so far) shows the number of pages of each file found on

PDFJS: Text layer rendering twice

有些话、适合烂在心里 提交于 2019-12-11 08:12:01
问题 Here's the context: pdfjs-dist: v2.2.228 angualar/core: 8.2.0 (hybrid Env with an AngularJs 1.5.X) Objective : to upgrade pdfjs-dist to the latest versions (2.3.200 or at least 2.2.X) I upgraded from pdfjs-dist 2.0.4xx, and here's what is being rendered: So basically, instead of having the PDF rendered correctly, with highlightable text and so on, there's like a duplicate of the text: one version of the text is rendered correctly (graphically), the other version seems to work OK for text

Displaying Pdf in Javafx using PDFJS library in Webview

≡放荡痞女 提交于 2019-12-11 07:53:31
问题 My goal is to display pdf documents in my JavaFX application. After researching I came across Mozilla's PDFJS library and found it pretty useful. What I'm doing is reading PDF file as a byte array from JAVA and calling the js code in Web view. Here is the code. JAVA CODE byte[] data = Files.readAllBytes(Paths.get("D:\\test\\test.pdf")); String base64 = Base64.getEncoder().encodeToString(data); btn.setOnMouseClicked(e -> { String js = "openFileFromBase64('" + base64 + "')"; engine

How to give pdf.js worker in Angular CLI application

喜你入骨 提交于 2019-12-11 07:37:49
问题 I used pdf.js directly in angular app for some pdf purposes. It works fine. I imported the pdfjs from the pdfjs-dist and my package.json includes pdfjs-dist. My pdf is working fine, but in the console, I get the below error. pdf.js:9067 GET http://localhost:4300/main.bundle.worker.js 404 (Not Found) pdf.js:351 Warning: Setting up fake worker. How to set up the worker properly in angular CLI application? 回答1: I solved this issue with some days of fighting. First time I win with StackBlitz

View pdf instead of download using PDF js

对着背影说爱祢 提交于 2019-12-10 11:02:15
问题 In my page, I'm trying to display a thumbnails of my pdf using PDF JS and it works on local, but when I upload my code in my webserver the pdf file is auto download. In my local : Code : $(function() { var filePath = "http://example.com/public/uploads/docs/Document_One_1.pdf"; function Num(num) { var num = num; return function () { return num; } }; function renderPDF(url, canvasContainer, options) { var options = options || { scale: 1.1 }, func, pdfDoc, def = $.Deferred(), promise = $

How do I retrieve text from user selection in pdf.js?

末鹿安然 提交于 2019-12-09 18:49:15
问题 This question is specific to pdf.js, a javascript based pdf renderer. I'm building a custom version where I need to extract the text that I select inside the pdf. There are other posts where you can fetch the text from one page or the whole pdf document such as the one here , but I'm looking to grab a specific text that the user selects and perhaps alert it or print it in the console. 回答1: What you are looking for is window.getSelection() method. This method returns a specific Selection

PDF attached with Paperclip - get document properties (like page count)

六月ゝ 毕业季﹏ 提交于 2019-12-08 06:09:10
问题 In my app to learn RoR, I want to see how to handle attachments. Got paperclip to work and want to get document properties. So, how can I get document properties (PDF info) from pdf files (attached using Paperclip)? One way is to use command line, yet how to get it the file (here @annotation.file - or for other object @document.file )? Actually, I would need to download the file to a temp folder to do this and do a file delete to clean up. How can I get the details without download? So

View pdf instead of download using PDF js

北战南征 提交于 2019-12-06 08:01:18
In my page, I'm trying to display a thumbnails of my pdf using PDF JS and it works on local, but when I upload my code in my webserver the pdf file is auto download. In my local : Code : $(function() { var filePath = "http://example.com/public/uploads/docs/Document_One_1.pdf"; function Num(num) { var num = num; return function () { return num; } }; function renderPDF(url, canvasContainer, options) { var options = options || { scale: 1.1 }, func, pdfDoc, def = $.Deferred(), promise = $.Deferred().resolve().promise(), width, height, makeRunner = function(func, args) { return function() { return

Vue: use a custom libary (pdf.js) in a component

允我心安 提交于 2019-12-04 19:38:17
How can I use a vendor libary (specifically I want to use PDF.js) in a Vue component? (I only want to load it for this specific component as they are rather larger files) I'm building an editor that needs to load a pdf. So I placed the pdf.js and pdf.worker.js in /src/assets/vendor/pdfjs Then I load both in the template-editor-page.hbs that also loads the component: <div class="content"> <div class="row fill"> <div class="col-md-2 fill br pt30"> </div> <div class="col-md-10 fill pt30 pl30 pr30"> <div id="template-editor" class="template-editor"> <template-editor template-src="{{template.src}}"

flask render_template with url parameter

风格不统一 提交于 2019-12-04 12:41:54
I use pdf.js to render pdf in web. The format of the target url like this: http://www.example.com/book?file=abc.pdf My problem is: I use flask template to generate page using: return render_template('book.html', paraKey=paraValue) But how to attach url parameter "file=abc.pdf" to url? The parameter will be read by viewer.js(included in book.html) that uses it to read file for rendering pdf. I'm new to flask, hoping guys giving me some help! You could use redirect function, which can redirect you whatever you want: @app.route('/book') def hello(): file = request.args.get('file') if not file: