Monday 15 July 2013

javascript - pdf download using php and onclick function -



javascript - pdf download using php and onclick function -

i have next code.

<div onclick="registerationform.pdf">something</div> <?php header('content-disposition: attachment; filename=registerationform.pdf'); header('content-type: application/pdf'); readfile('registerationform.pdf');

this code straight downloads output if page loaded. need pdf downloaded if something button clicked.help me

php code executed before page content shown or javascript executed, , not sequentially see in example.

what want create php page downloadpdf.php includes headers specified, , redirect user page through link:

link.php:

<a href="downloadpdf.php" target="_blank"> download pdf </a>

note: target="_blank" added here actual page not redirected instead new page opened in new tab-> browser downloads file , closes tab, "feeling" it's immediate download current page on.

downloadpdf.php

<?php header('content-disposition: attachment; filename=registerationform.pdf'); header('content-type: application/pdf'); readfile('registerationform.pdf');

javascript php download dompdf html-to-pdf

No comments:

Post a Comment