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:
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
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With