Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rotate file pdf and all image kinds

I have a html page that display PDF and all kinds image. I'm looking for a way to rotate the file that i display with jQuery.

I tried:

  • add css class - not working.

Example of the code:

.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'm pretty sure it's not the right way

  • function in JavaScript - not working.

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

like image 704
tal Avatar asked Nov 07 '22 13:11

tal


1 Answers

Why dont u just use PDF.js from Mozilla. https://mozilla.github.io/pdf.js/

It can rotate the document and even save it like that, if thats what you want.

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

Note: the last time I used pdf.js it supported image files like jpg and png too so no problem there

like image 199
Kickass Avatar answered Nov 14 '22 23:11

Kickass