search

Home  >  Q&A  >  body text

javascript - A problem with the code for saving web page printing pages as pdf

This is what the printed page says

<button type="submit" class="btn btn-default navbar-btn " onclick="window.print();">打印</button>

When you print it out, you also need to select the target as Save as PDF to save it as a PDF.

Can I just click the button to download the pdf?

The project is for ASP.NET webform. Can it be implemented using js or C#?

黄舟黄舟2727 days ago1060

reply all(2)I'll reply

  • 迷茫

    迷茫2017-07-05 10:45:30

    To provide an idea, if you want to download PDF files directly, you may need to change the JS method to directly download the URL request, and return the Response in the background to directly return to the PDF file stream.

    reply
    0
  • 習慣沉默

    習慣沉默2017-07-05 10:45:30

    The back-end uses phatomjs for rendering. After rendering the web page, a pdf file is generated, and then the front-end downloads the file directly.

    reply
    0
  • Cancelreply