I use html2pdf to generate pdf from a wordpress post (inside a multi site install), it's working great I have the following setup:
on my homepage I have a link
<a target="_blank" id="downloadPDF" href="<?php echo get_template_directory_uri(); ?>/pdf_processor.php?blogid=<?php echo get_current_blog_id(); ?> ">download</a>
and on my pdf_processor.php the pdf is generated as espected and i use `
$html2pdf->Output('exemple.pdf', 'D');
using 'D' allow to download the pdf directly which is what i want.
now I would like to generate the pdf whith an ajax call (so i can display a loading icone while waiting), I already tryed setting up an ajax call with jquery that posts the get_current_blog_id();
to pdf_processor.php
, i don't know how to handle the response so that when the ajax call is a success $html2pdf->Output('exemple.pdf', 'D');
is triggered, on my atempt i tried
echo $html2pdf->Output('exemple.pdf', 'D');
but that just returns a strange string.