Reputation: 6820
I'm trying to save a simple pdf with one page but it doesn't work. This is what I do:
try {
// create PDF
$pdf = new Zend_Pdf();
// create A4 page
$page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
// define font resource
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
// set font for page
// write text to page
$page->setFont($font, 24)
->drawText('That which we call a rose,', 72, 720)
->drawText('By any other name would smell as sweet.', 72, 620);
// add page to document
$pdf->pages[] = $page;
// save as file
$pdf->save("/test.pdf");
echo 'SUCCESS: Document saved!';
} catch (Zend_Pdf_Exception $e) {
die ('PDF error: ' . $e->getMessage());
} catch (Exception $e) {
die ('Application error: ' . $e->getMessage());
}
I always get this error:
PDF error: Can not open '/test.pdf' file for writing.
I've found this stackoverflow topic but I didn't help me much. They say to change the save path, but change it to what? Let's say for example I want to download it to my Downloads folder, how can I do this?
My Downloads folder on mac is : /Users/myname/Downloads
Upvotes: 0
Views: 1444
Reputation: 1770
Ensure that you have write permissions on the folder with ls -ld. If you do not have write permission in the folder use chmod to give it to yourself.
Upvotes: 0
Reputation: 930
try for save in Zend app directory
$pdf->save("test.pdf");
or for save in Downloads
$pdf->save("/Users/myname/Downloads/test.pdf");
Upvotes: 4