Rotate Object Tag (PDF) in Javascript

I am trying to rotate the tag of an object that contains a PDF file viewed by the Acrobat plugin through AcroPdf.dll.

I already saw this solution, but I don’t turn the PDF itself on> = IE9 (works on chrome)

I am using jQuery 1.11.3 and PDFObject 1.2, and I cannot change the version of jQuery.

The effect is as follows: after clicking

I want to: pdf also rotates in chrome

Any help would be appreciated. Relationship

My simple code is:

<!DOCTYPE html>
<html>
<head>
<style>
.rotate-90 {
  -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.00000000, M12=-1.00000000, M21=1.00000000, M22=0.00000000,sizingMethod='auto expand')";
   filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.00000000, M12=-1.00000000, M21=1.00000000, M22=0.00000000,sizingMethod='auto expand');
  transform: rotate(90deg);
  -o-transform: rotate(90deg);
  -ms-transform: rotate(90deg);
  -webkit-transform: rotate(90deg);
  -moz-transform: rotate(90deg);
}
</style>
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="http://miorepository.altervista.org/pdfobject.js"></script>
</head>

<body>
<button onclick="rotatePdf();">Rotate 90 degree</button>
<div id="boxPdf"></div>

<script type='text/javascript'>
            $(function(){

                var pdfPath = './doc1.pdf';

                var customParameter = {
                    page : '1',
                    view : 'FitH,0',
                    pagemode : 'none',
                    scrollbars : '0',
                    toolbar : '0',
                    statusbar : '0',
                    messages : '0',
                    navpanes : '0'
                };

                var myPDF = new PDFObject({
                                    url : pdfPath,
                                    pdfOpenParams : customParameter,
                                    cid : 'objectBoxPdf'
                                }).embed('boxPdf');
            });

            function rotatePdf(){
                $('#objectBoxPdf').toggleClass('rotate-90');
            }
</script>
</body>
</html>
+6
source share
1 answer

Try this code:

$('#button').click(function() {
  $('#example').addClass('rotate-90');
});
.rotate-90 {
  transform: rotate(90deg);
  -webkit-transform: rotate(90deg);
  -ms-transform: rotate(90deg);
}

#example {
  width: 400px;
  height: 400px;
  border: 1px solid #000;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>
<div id="example">
  <object width="400px" height="400px" data="pdf.pdf"></object>
</div>
<button id="button">Rotate 90 degrees</button>
Run codeHide result

Note: replace "pdf.pdf" with the name of your pdf.

, , , "rotate-90" . CSS , "rotate-90" 90 . , 90 .

, !

0

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


All Articles