Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mozilla PdfJs Operations

Tags:

pdf

pdf.js

given a PDF that is rendered in the browser using pdfjs, are there functions to do the following basic view operations:

  • rotate
  • flip
  • zoom

If not, what are the best strategies I can use to do the operations above?

like image 701
developarvin Avatar asked Aug 23 '12 06:08

developarvin


People also ask

How does PDFjs work?

PDF. js leverages Asynchronous JavaScript and XML (AJAX) to download the PDF file from a web server and parse its contents. Once prepared, content is then rendered onto an HTML5 <canvas> element using canvas drawing commands.

How does PDF rendering work?

A PDF library first needs to decompress the binary PDF file and parse its contents. Next, the PDF rendering engine converts parsed PDF file contents into drawing operations. Most often, the graphics in a PDF document will be encoded as one of two types of data: raster or vector.

Does Firefox use PDF JS?

PDF. js is part of Firefox since version 19. The extension is mostly used by developers and for bringing a newer version of the PDF. js library to an older Firefox version.


1 Answers

You can set rotation when you getting viewport form PdfPage object:

var viewport = pdfPage.getViewport(scale, rotation);

If you want to immediately set all the parameters, you can clone viewport, created with scale = 1:

var defaultViewport = pdfPage.getViewport(1);
var neededViewport = defaultViewport.clone({scale: needScale, rotation: needRotation, dontFlip: true});
like image 167
Roman Zhukov Avatar answered Sep 29 '22 09:09

Roman Zhukov