0

I am new in angularjs and I'm trying to save my html modal into a PDF in angularjs. But it is saving only the current page on screen, it does not save the whole modal which is quite large.

I have tried on of the following code

<head>
    <script src="angular.min.js"></script>
    <script src="Angular/angular-animate.min.js"></script>
    <script src="Angular/angular-aria.min.js"></script>
    <script src="Angular/angular-material.min.js"></script>
    <script src="Angular/angular-messages.min.js"></script>
    <script src="jquery.min.js"></script>
    <script src="moment.js"></script>
    <script src="ui-bootstrap-tpls-0.10.0.js"></script>
    <script src="AccordianController.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.22/pdfmake.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script>
    <script src="script.js"></script>
</head>

<body>
it contains the modal which is not shown here
</body>

Controller
$scope.pdf = function () {
          html2canvas(document.getElementById('exportthis'), {
              onrendered: function (canvas) {
                  var data = canvas.toDataURL();
                  var docDefinition = {
                      content: [{
                          image: data,
                          width: 500,
                      }]
                  };
                  pdfMake.createPdf(docDefinition).download("test.pdf");
              }
          });
      }

My modal is large it will take almost 3 page, but here by this code I'm able to save only the screen which is shown.

Please suggest me any solution or which I can follow to achieve my requirement. Thanks In advence.

Amrit
  • 137
  • 2
  • 2
  • 13
  • Why is the modal taking up nearly 3 full screens! If you need this much information from a modal it should probably be a page. – phuzi Jan 14 '19 at 10:49
  • My Modal contains 20 fields and also it contains audit log so when I scroll my modal it is around 3 full screen page. Ad this piece of code I think can only convert the screen it is not applying for the whole modal – Amrit Jan 14 '19 at 12:18

1 Answers1

0

It may comes from html2canvas which only take into account what is "visible" on your screen.

You should try the workaround from this post and see if you manage to print your whole modal : HTML2Canvas converting overflowed content to image

Aweuzegaga
  • 196
  • 2
  • 11