pdf.js

How do I determine the size of a pdf with pdf.js so I can scale to the screen size?

≡放荡痞女 提交于 2019-12-06 02:36:59
问题 I need to scale a pdf so it fills the height of the screen, but all I've found is the function scale() . How do i know how much to scale it? 回答1: To determine the width/height of a page, you need to do the following: Get the page In a "promise" function (the page can only be retrieved asynchronously): a. Retrieve the viewport with a scale of 1 b. Call the width property of the viewport The Code: //Get the page with your callback pdf.getPage(1).then( function(page) { //We need to pass it a

Load pdf on foreign url with pdf.js

橙三吉。 提交于 2019-12-06 00:14:28
问题 I am trying to load pdf from another server to the viewer of pdf.js in my server.I got error "PDF.js v1.4.20 (build: b15f335) Message: file origin does not match viewer's" I already checked many answer, many of them said that pass the pdf url through a proxy like:- link After searching a lot i found that they release a new patch in which they have lock down any CDR request, correct me if i am wrong:-Here is the link but in their user manual they specified that it is possible here is the link

Task edit document preview component Alfresco

血红的双手。 提交于 2019-12-05 21:02:50
First question: I want to implement a preview of the document in the form of the task-edit of the workflows... How can I do this? I try to adapt the document-details.xml and document-details.ftl to workflow-details.xml and workflow-details.ftl but not works. I tried to copy the components that have web-preview of the document-details files to workflow-details. Any hint to make this? I have this in workflow-details.ftl : <#include "include/alfresco-template.ftl" /> <@templateHeader> <@script type="text/javascript" src="${url.context}/res/modules/documentlibrary/doclib-actions.js" group=

PDF.js How do you print a multi-page pdf?

霸气de小男生 提交于 2019-12-05 06:55:17
I'm trying to add print functionality to a multi-page PDF embedded in a web page that is using the PDF.js library. It's problematic because I only have one page rendered at a time when a user is viewing it and the page is really rendered as an image in a canvas element. This question does not help in this case because it is for a single page PDF where printing the current contents of the canvas are acceptable. Same with this question . I also want to avoid just opening the PDF in another tab/window and telling the user to print it themselves, which defeats the purpose of embedding it into the

how to improve the print quality with pdf.js to print pdf document?

两盒软妹~` 提交于 2019-12-05 05:24:24
The Issue: When I use pdf.js to print PDF documents, the text on paper is not very clear like print PDF directly. How to resolve it? PDF.js renders the PDF to a HTML canvas and then sends the rendered image to the printer. To improve the quality of the image being sent to the printer, you need to increase the DPI or resolution of the image. There have been several bugs raised about the issue: https://github.com/mozilla/pdf.js/issues/7094 https://github.com/mozilla/pdf.js/issues/7041 https://github.com/mozilla/pdf.js/issues/6498 https://github.com/mozilla/pdf.js/issues/6241 Here is the Pull

Pdf image quality is bad using pdf.js

烈酒焚心 提交于 2019-12-04 19:23:11
问题 I am using pdf.js. But, image quality of PDF is low quality. Please tell me solution method. var TARGET_PAGE = 1; var PAGE_SCALE = 1; function viewPDF(targetPage,pageScale){ PDFJS.getDocument(targetPath).then(function (pdf) { return pdf.getPage(targetPage); }).then(function (page) { var scale = pageScale; var viewport = page.getViewport(scale); var canvas = document.createElement('canvas'); var context = canvas.getContext('2d'); canvas.height = viewport.height; canvas.width = viewport.width;

pdf.js with local pdf file

喜夏-厌秋 提交于 2019-12-04 18:05:10
问题 I'm trying out the pdf.js library and just want to display a local pdf file on my server instead of the pdf file provided by the example. <html> <body> <canvas id="the-canvas" style="border:1px solid black"></canvas> <!-- Use latest PDF.js build from Github --> <script type="text/javascript" src="https://raw.github.com/mozilla/pdf.js/gh-pages/build/pdf.js"></script> <script type="text/javascript"> // // NOTE: // Modifying the URL below to another server will likely *NOT* work. Because of

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:

Displaying PDF on website using pdf.js

倖福魔咒の 提交于 2019-12-04 08:45:50
I want to put a file sample.pdf on my website, and want it to be displayed using pdf.js . What I want is to display my own file like the demo , with a toolbar, zooming in/out, etc. So far I can't do that yet. I did check out the helloworld example , but it simply shows the file like an image, without toolbar, zooming in/out, etc. When I put another file with many pages instead of helloworld.pdf , it just shows the first page. I am not quite sure what you are looking for but I was able to get this working exactly like the demo. Although you may not want to use that example viewer for your

pdf.js failing on getDocument

狂风中的少年 提交于 2019-12-04 04:49:23
browser: Chrome environment: grails app localhost I'm running a grails app on local host (which i know there's an issue with pdf.js and local file system) and instead of using a file: url which i know would fail i'm passing in a typed javascript array and it's still failing. To be correct it's not telling me anything but "Warning: Setting up fake worker." and then it does nothing. this.base64ToBinary = function(dataURI) { var BASE64_MARKER = ';base64,'; var base64Index = dataURI.indexOf(BASE64_MARKER) + BASE64_MARKER.length; var base64 = dataURI.substring(base64Index); var raw = window.atob