V
V
Vladimir2020-01-06 22:10:44
JavaScript
Vladimir, 2020-01-06 22:10:44

How to create a .pdf document from a page's html block?

Good evening. Please tell me if this is possible, if so, how? Maybe a whole page? I need the results of the survey in a .pdf document to glue and give the opportunity to download. Another option with Google Spreadsheets, if there is some method to upload data using api by id, for example, it would be great.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir, 2020-01-07
@HistoryART

Here guys, the finished script exports the page with styles, but it's crooked, look for the next question)

<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.debug.js" integrity="sha384-NaWTHo/8YCBYJ59830LTz/P4aQZK1sS0SneOgAvhsIl3zBu8r9RevNg5lHCHAuQ/" crossorigin="anonymous"></script>
  <script src="https://html2canvas.hertzen.com/dist/html2canvas.js"></script>
  <script>

    window.html2canvas = html2canvas
    
    function genPDF() {
      var pdf = new jsPDF()
      pdf.html(document.querySelector('body'), {
      	'width': 1920,
      	'height': 1080,
        callback: function (pdf) {
          pdf.save('cv-a4.pdf');
        }
      })
    }
  </script>

G
great_77, 2020-01-07
@great_77

Use another library to generate pdf. Essentially importing a table into pdf

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question