简体   繁体   中英

how to convert part of html page into pdf using wkhtmltopdf or something else

Iam using wkhtmltopdf for html to pdf conversion of an html page using C# code and it is working absolutely perfect but i want to convert a particular part of html page to pdf like by specifying div id of that part or any similar method.How can i do this?

Please help

You can just create a new HTML page with just your div as a body:

<html>
  <head><title>...</title></head>
  <body>
      <!-- PLACE YOUR DIV HERE -->
  </body>
</html>

Since you already know how to produce a PDF from an HTML file, you know know how to produce a PDF from a DIV ;)

BUT : Of course the CSS is going to be all wonky, since the selectors won't match anymore etc. This is a problem for the general case, but I'm guessing in your specific case, you can make that work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM