How to rotate a pdf file and all kinds of images

I have an html page displaying a PDF image and all kinds. I am looking for a way to rotate the file that I am showing with jQuery.

I tried:

  • add css class - not working.

Code example:

.rotate90 { webkit-transform: rotate(90deg); moz-transform: rotate(90deg); o-transform: rotate(90deg); ms-transform: rotate(90deg); transform: rotate(90deg); } $("buttonId").click(function(){ $( "objectPdfId" ).addClass( "rotate90" ); }); 

I am sure this is not the right way.

  • in JavaScript - does not work.

code:

  var html = '<object id="objectPdfId" data="' + pathFile + '" type="application/pdf" on click="+rotateMe(this)+"'><embed id="embedPdfId" src="' + pathFile + '" type="application/pdf"></embed></object>'; $("body").append($(html)); var rotate_factor = 0; function rotateMe(e) { rotate_factor += 1; var rotate_angle = (180 * rotate_factor) % 360; $(e).rotate({angle:rotate_angle}); } 

Thanks,

Tal

+5
source share
2 answers

Why don't you just use PDF.js from Mozilla. https://mozilla.imtqy.com/pdf.js/

It can rotate a document and even save it that way if that is what you want.

If you are dead in your css solution, it should work with the conversion, so open your favorite browser debugger (F12 - Chrome and Firefox) and see if your document is typing css and element rules. Take it from there.

Note: the last time I used pdf.js, it supported image files such as jpg and png, so there was no problem.

+1
source

try adding a class to the object container

 <div class=" rotate90"> <object > </object> </div> 
0
source

Source: https://habr.com/ru/post/1273889/


All Articles