i'm looking way convert content in body of html webpage pdf when button/image (link) clicked.
i looked jspdf , mpdf, solutions aren't quite producing want.
i'd entire contents between body tags user can save s pdf - preferably of styling (or as possible) preserved.
shouldn't simple code produces screen shot of page (although might include unnecessary things such url bar, etc., , render pdf unsearchable in whatever storage set user saves (but isn't priority right now)?
summing up, i'm looking have code (preferably simple js) achieve goal of capturing content in body tags, , saving pdf @ user's command.
thanks attention , insight :-)
try using dompdf, can download here. if error,
- create dompdf/lib/php-font-lib/classes/ directory
- download this files
- in zip file, take contents of src/fontlib/ folder , paste dompdf/lib/php-font-lib/classes/ folder
usage
require_once 'dompdf/dompdf_config.inc.php'; $html = "<html><body>html code </body></html>"; $pdf = new dompdf(); $pdf->load_html($html); $pdf->render(); $output = $pdf->output(); file_put_contents('output folder/file name.pdf', $output); $pdf->stream('file name.pdf', array('attachment' => 0));
Comments
Post a Comment