How may I use wkhtmltopdf to transform a whole .html into just one page .pdf?

87 views
Skip to first unread message

张勇智

unread,
Apr 9, 2021, 6:13:06 AM4/9/21
to wkhtmltopdf General
How may I use wkhtmltopdf to transform a whole .html (no matter how long or wide) into just one page of  .pdf?

I need  to parse a single page pdf in codes and show off on the screen, how to make it 
possible?

Asking for help~

Waqas Raza

unread,
Apr 9, 2021, 7:56:39 AM4/9/21
to wkhtmltop...@googlegroups.com
C:\Program Files\wkhtmltopdf\bin>wkhtmltopdf.exe --page-width 188mm --page-height 2900mm -L 0 -R 0   "src.html" target.pdf

You can change the page length e.g. in the above code. it will not be cut like that, you can customize the table by inline styling to give it an outer border-style like in the below image. I have a long PDF and I've increased too much of that single page you can adjust the height accordingly.

2screencapture-localhost-bilal-signuser-2021-03-25-00_55_26.png

  You can see more help on this link.  https://wkhtmltopdf.org/usage/wkhtmltopdf.txt  

Solution :::::

$snappy = new Pdf("\"C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe\"");
header('Content-Type: application/pdf');
snappy->setOption('page-width', '188m');
snappy->setOption('page-height', '2900m');  // large height Set what ever suits you
// header('Content-Disposition: attachment; filename="file.pdf"'); // to download pdf
//uncomment if you want download also

echo $snappy->getOutput('http://www.github.com'); ## to get out put directly to the browser from a url
  echo $snappy->getOutputFromHtml($html);    ## to get out put directly to the browser from html

you can also see my solution for codeigniter with snappy library here. that is a wraaper over the wkhtmltopdf.
https://stackoverflow.com/questions/66804179/the-binary-is-not-set-for-in-snappy-wrapper-for-wkhtmltopdf-in-codeigniter/66975652#66975652
her

Thanks,
feel free to ask any questions.
thanks
Waqas Raza
Web developer

On Wednesday, 24 March 2021 at 17:54:42 UTC+5 Ambika Sharma wrote:
Hi,

Text get cut off when pdf has large data and it continue on next page, Is there any valid solution for this? Help will be appreciated .

Thanks

--


--
===================================================
You received this message because you are subscribed to the "wkhtmltopdf General" group.
To post to this group, send email to wkhtmltop...@googlegroups.com
To unsubscribe from this group, send email to wkhtmltopdf-gen...@googlegroups.com
 
For more options, visit this group at
http://groups.google.com/group/wkhtmltopdf-general?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups "wkhtmltopdf General" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wkhtmltopdf-gen...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wkhtmltopdf-general/58f24d90-3657-4254-97bf-f911bd18eea0n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages