Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue of generated pdf file #46

Closed
khayyak opened this issue May 11, 2020 · 1 comment
Closed

issue of generated pdf file #46

khayyak opened this issue May 11, 2020 · 1 comment

Comments

@khayyak
Copy link

khayyak commented May 11, 2020

$objPdf = new Fpdf;
$objPdf->AddPage();
$objPdf->SetFont('Arial', '', 10);
$objPdf->SetTitle("Title");
$objPdf->SetAuthor('Author');
$objPdf->Cell(50, 25, 'Hello World!');
$objPdf->AliasNbPages();
$objPdf->Output("","i");
ob_get_clean();

this is my code but generated pdf file not display on browser , but when I replace $objPdf->Output("","i"); by $objPdf->Output("","f"); it works good and save file on server . so what is the problem here and thanks

@khayyak
Copy link
Author

khayyak commented May 13, 2020

I found a solution , the issue was because of using axios so I need to add this code to have a possibility to download PDF file .
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
link.click();
});

@khayyak khayyak closed this as completed May 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant