Reputation: 384
I have a question. I have a url for Phantomjs which generates a PDF. But I want to generate the PDF on Serverside.
<script> $("#generatePDF").click(function(){
var fullLink = "<? echo $link ?>"
$.ajax({
type: "POST",
url: "/php/ajax/generatepdf.php?",
data: {link : fullLink}
}).done( function(data){
window.open(data);
} );
}); </script>
This is where I send the data to the generatepdf.php
The link generates a PDF with Phantom.JS
Now I do the following in the generatepdf.php
$link = $_POST['link'];
CurlConnect = curl_init();
curl_setopt($CurlConnect, CURLOPT_URL, $link);
curl_setopt($CurlConnect, CURLOPT_POST, 1);
curl_setopt($CurlConnect, CURLOPT_RETURNTRANSFER, 0 );
$Result = curl_exec($CurlConnect);
echo $Result;
My question: How can I open a PDF in a new tab with the stuff from the phantom.js result?
I hope you understand my question.
Best Regards.
Upvotes: 3
Views: 1157
Reputation: 384
Ok i got another solution. I just linked to the php page and the PHP page got the PDF content. Plus I had to change the header to application pdf
Upvotes: 2
Reputation: 1488
Instead using CURL and all that stuff simply hit the $link
of php file in new tab.. (If the file is actually generating PDF)
window.open('Link which generates the PDF');
Upvotes: 0