|
|
@@ -186,11 +186,14 @@ class Zend_Pdf_DrawingTest extends PHPUnit_Framework_TestCase
|
|
|
->drawImage($stampImagePNG, 275, 450, 375, 550)
|
|
|
->restoreGS();
|
|
|
|
|
|
+ $jpegSupported = false;
|
|
|
if (function_exists('gd_info')) {
|
|
|
$info = gd_info();
|
|
|
- $jpegSupported = $info['JPG Support'];
|
|
|
- } else {
|
|
|
- $jpegSupported = false;
|
|
|
+ if (isset($info['JPG Support'])) {
|
|
|
+ $jpegSupported = $info['JPG Support'];
|
|
|
+ } elseif (isset($info['JPEG Support'])) {
|
|
|
+ $jpegSupported = $info['JPEG Support'];
|
|
|
+ }
|
|
|
}
|
|
|
if ($jpegSupported) {
|
|
|
$stampImageJPG = Zend_Pdf_Image::imageWithPath(dirname(__FILE__) . '/_files/stamp.jpg');
|
|
|
@@ -416,137 +419,137 @@ class Zend_Pdf_DrawingTest extends PHPUnit_Framework_TestCase
|
|
|
|
|
|
unlink(dirname(__FILE__) . '/_files/output.pdf');
|
|
|
}
|
|
|
-
|
|
|
- public function testFontExtracting()
|
|
|
+
|
|
|
+ public function testFontExtracting()
|
|
|
{
|
|
|
if (PHP_OS == 'AIX') {
|
|
|
$this->markTestSkipped('Not supported on AIX');
|
|
|
}
|
|
|
-
|
|
|
- $pdf = new Zend_Pdf();
|
|
|
-
|
|
|
- $fontsList = array(Zend_Pdf_Font::FONT_COURIER,
|
|
|
- Zend_Pdf_Font::FONT_HELVETICA_BOLD,
|
|
|
- Zend_Pdf_Font::FONT_TIMES_BOLD_ITALIC);
|
|
|
-
|
|
|
- foreach ($fontsList as $fontName) {
|
|
|
- // Add new page generated by Zend_Pdf object (page is attached to the specified the document)
|
|
|
- $pdf->pages[] = ($page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4_LANDSCAPE));
|
|
|
-
|
|
|
- $font = Zend_Pdf_Font::fontWithName($fontName);
|
|
|
- $page->setFont($font, 10)
|
|
|
+
|
|
|
+ $pdf = new Zend_Pdf();
|
|
|
+
|
|
|
+ $fontsList = array(Zend_Pdf_Font::FONT_COURIER,
|
|
|
+ Zend_Pdf_Font::FONT_HELVETICA_BOLD,
|
|
|
+ Zend_Pdf_Font::FONT_TIMES_BOLD_ITALIC);
|
|
|
+
|
|
|
+ foreach ($fontsList as $fontName) {
|
|
|
+ // Add new page generated by Zend_Pdf object (page is attached to the specified the document)
|
|
|
+ $pdf->pages[] = ($page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4_LANDSCAPE));
|
|
|
+
|
|
|
+ $font = Zend_Pdf_Font::fontWithName($fontName);
|
|
|
+ $page->setFont($font, 10)
|
|
|
->drawText($font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en') . ':', 100, 400);
|
|
|
- $page->setFont($font, 20)
|
|
|
- ->drawText("'The quick brown fox jumps over the lazy dog'", 100, 360);
|
|
|
-
|
|
|
- $type = $font->getFontType();
|
|
|
- }
|
|
|
-
|
|
|
- $TTFFontsList = array('VeraBd.ttf',
|
|
|
- 'VeraBI.ttf',
|
|
|
- 'VeraIt.ttf',
|
|
|
- 'VeraMoBd.ttf',
|
|
|
- 'VeraMoBI.ttf',
|
|
|
- 'VeraMoIt.ttf',
|
|
|
- 'VeraMono.ttf',
|
|
|
- 'VeraSeBd.ttf',
|
|
|
- 'VeraSe.ttf',
|
|
|
- 'Vera.ttf');
|
|
|
-
|
|
|
- foreach ($TTFFontsList as $fontName) {
|
|
|
- // Add new page generated by Zend_Pdf object (page is attached to the specified the document)
|
|
|
- $pdf->pages[] = ($page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4_LANDSCAPE));
|
|
|
-
|
|
|
- $font = Zend_Pdf_Font::fontWithPath(dirname(__FILE__) . '/_fonts/' . $fontName);
|
|
|
- $page->setFont($font, 10)
|
|
|
- ->drawText($font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en', 'CP1252') . ':', 100, 400);
|
|
|
- $page->setFont($font, 20)
|
|
|
- ->drawText("'The quick brown fox jumps over the lazy dog'", 100, 360);
|
|
|
- $type = $font->getFontType();
|
|
|
- }
|
|
|
-
|
|
|
- $pdf->save(dirname(__FILE__) . '/_files/output.pdf');
|
|
|
- unset($pdf);
|
|
|
-
|
|
|
- $pdf1 = Zend_Pdf::load(dirname(__FILE__) . '/_files/output.pdf');
|
|
|
-
|
|
|
- $newPages = array();
|
|
|
-
|
|
|
- $fontList = array();
|
|
|
- $fontNames = array();
|
|
|
- foreach ($pdf1->pages as $page) {
|
|
|
- $pageFonts = $page->extractFonts();
|
|
|
- foreach ($pageFonts as $font) {
|
|
|
- $fontList[] = $font;
|
|
|
- $fontNames[] = $font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en', 'UTF-8');
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $this->assertEquals(array(Zend_Pdf_Font::FONT_COURIER,
|
|
|
- Zend_Pdf_Font::FONT_HELVETICA_BOLD,
|
|
|
- Zend_Pdf_Font::FONT_TIMES_BOLD_ITALIC,
|
|
|
- 'BitstreamVeraSans-Bold',
|
|
|
- 'BitstreamVeraSans-BoldOblique',
|
|
|
- 'BitstreamVeraSans-Oblique',
|
|
|
- 'BitstreamVeraSansMono-Bold',
|
|
|
- 'BitstreamVeraSansMono-BoldOb',
|
|
|
- 'BitstreamVeraSansMono-Oblique',
|
|
|
- 'BitstreamVeraSansMono-Roman',
|
|
|
- 'BitstreamVeraSerif-Bold',
|
|
|
- 'BitstreamVeraSerif-Roman',
|
|
|
- 'BitstreamVeraSans-Roman'),
|
|
|
- $fontNames);
|
|
|
-
|
|
|
- $pdf1->pages[] = ($page = $pdf1->newPage(Zend_Pdf_Page::SIZE_A4));
|
|
|
- $yPosition = 700;
|
|
|
- foreach ($fontList as $font) {
|
|
|
- $page->setFont($font, 15)
|
|
|
- ->drawText("The quick brown fox jumps over the lazy dog", 100, $yPosition);
|
|
|
- $yPosition -= 30;
|
|
|
- }
|
|
|
-
|
|
|
- $fontNames1 = array();
|
|
|
- foreach ($pdf1->extractFonts() as $font) {
|
|
|
- $fontNames1[] = $font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en', 'UTF-8');
|
|
|
- }
|
|
|
- $this->assertEquals(array(Zend_Pdf_Font::FONT_COURIER,
|
|
|
- Zend_Pdf_Font::FONT_HELVETICA_BOLD,
|
|
|
- Zend_Pdf_Font::FONT_TIMES_BOLD_ITALIC,
|
|
|
- 'BitstreamVeraSans-Bold',
|
|
|
- 'BitstreamVeraSans-BoldOblique',
|
|
|
- 'BitstreamVeraSans-Oblique',
|
|
|
- 'BitstreamVeraSansMono-Bold',
|
|
|
- 'BitstreamVeraSansMono-BoldOb',
|
|
|
- 'BitstreamVeraSansMono-Oblique',
|
|
|
- 'BitstreamVeraSansMono-Roman',
|
|
|
- 'BitstreamVeraSerif-Bold',
|
|
|
- 'BitstreamVeraSerif-Roman',
|
|
|
- 'BitstreamVeraSans-Roman'),
|
|
|
- $fontNames1);
|
|
|
-
|
|
|
- $page = reset($pdf1->pages);
|
|
|
- $font = $page->extractFont(Zend_Pdf_Font::FONT_COURIER);
|
|
|
- $this->assertTrue($font instanceof Zend_Pdf_Resource_Font_Extracted);
|
|
|
-
|
|
|
- $font = $page->extractFont(Zend_Pdf_Font::FONT_TIMES_BOLD_ITALIC);
|
|
|
- $this->assertNull($font);
|
|
|
-
|
|
|
-
|
|
|
- $font = $pdf1->extractFont(Zend_Pdf_Font::FONT_TIMES_BOLD_ITALIC);
|
|
|
- $this->assertTrue($font instanceof Zend_Pdf_Resource_Font_Extracted);
|
|
|
-
|
|
|
- $font = $pdf1->extractFont(Zend_Pdf_Font::FONT_TIMES_ROMAN);
|
|
|
- $this->assertNull($font);
|
|
|
-
|
|
|
- $pdf1->save(dirname(__FILE__) . '/_files/output1.pdf');
|
|
|
- unset($pdf1);
|
|
|
-
|
|
|
-
|
|
|
- $pdf2 = Zend_Pdf::load(dirname(__FILE__) . '/_files/output1.pdf');
|
|
|
- $this->assertTrue($pdf2 instanceof Zend_Pdf);
|
|
|
- unset($pdf2);
|
|
|
-
|
|
|
- unlink(dirname(__FILE__) . '/_files/output.pdf');
|
|
|
- unlink(dirname(__FILE__) . '/_files/output1.pdf');
|
|
|
- }
|
|
|
+ $page->setFont($font, 20)
|
|
|
+ ->drawText("'The quick brown fox jumps over the lazy dog'", 100, 360);
|
|
|
+
|
|
|
+ $type = $font->getFontType();
|
|
|
+ }
|
|
|
+
|
|
|
+ $TTFFontsList = array('VeraBd.ttf',
|
|
|
+ 'VeraBI.ttf',
|
|
|
+ 'VeraIt.ttf',
|
|
|
+ 'VeraMoBd.ttf',
|
|
|
+ 'VeraMoBI.ttf',
|
|
|
+ 'VeraMoIt.ttf',
|
|
|
+ 'VeraMono.ttf',
|
|
|
+ 'VeraSeBd.ttf',
|
|
|
+ 'VeraSe.ttf',
|
|
|
+ 'Vera.ttf');
|
|
|
+
|
|
|
+ foreach ($TTFFontsList as $fontName) {
|
|
|
+ // Add new page generated by Zend_Pdf object (page is attached to the specified the document)
|
|
|
+ $pdf->pages[] = ($page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4_LANDSCAPE));
|
|
|
+
|
|
|
+ $font = Zend_Pdf_Font::fontWithPath(dirname(__FILE__) . '/_fonts/' . $fontName);
|
|
|
+ $page->setFont($font, 10)
|
|
|
+ ->drawText($font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en', 'CP1252') . ':', 100, 400);
|
|
|
+ $page->setFont($font, 20)
|
|
|
+ ->drawText("'The quick brown fox jumps over the lazy dog'", 100, 360);
|
|
|
+ $type = $font->getFontType();
|
|
|
+ }
|
|
|
+
|
|
|
+ $pdf->save(dirname(__FILE__) . '/_files/output.pdf');
|
|
|
+ unset($pdf);
|
|
|
+
|
|
|
+ $pdf1 = Zend_Pdf::load(dirname(__FILE__) . '/_files/output.pdf');
|
|
|
+
|
|
|
+ $newPages = array();
|
|
|
+
|
|
|
+ $fontList = array();
|
|
|
+ $fontNames = array();
|
|
|
+ foreach ($pdf1->pages as $page) {
|
|
|
+ $pageFonts = $page->extractFonts();
|
|
|
+ foreach ($pageFonts as $font) {
|
|
|
+ $fontList[] = $font;
|
|
|
+ $fontNames[] = $font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en', 'UTF-8');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->assertEquals(array(Zend_Pdf_Font::FONT_COURIER,
|
|
|
+ Zend_Pdf_Font::FONT_HELVETICA_BOLD,
|
|
|
+ Zend_Pdf_Font::FONT_TIMES_BOLD_ITALIC,
|
|
|
+ 'BitstreamVeraSans-Bold',
|
|
|
+ 'BitstreamVeraSans-BoldOblique',
|
|
|
+ 'BitstreamVeraSans-Oblique',
|
|
|
+ 'BitstreamVeraSansMono-Bold',
|
|
|
+ 'BitstreamVeraSansMono-BoldOb',
|
|
|
+ 'BitstreamVeraSansMono-Oblique',
|
|
|
+ 'BitstreamVeraSansMono-Roman',
|
|
|
+ 'BitstreamVeraSerif-Bold',
|
|
|
+ 'BitstreamVeraSerif-Roman',
|
|
|
+ 'BitstreamVeraSans-Roman'),
|
|
|
+ $fontNames);
|
|
|
+
|
|
|
+ $pdf1->pages[] = ($page = $pdf1->newPage(Zend_Pdf_Page::SIZE_A4));
|
|
|
+ $yPosition = 700;
|
|
|
+ foreach ($fontList as $font) {
|
|
|
+ $page->setFont($font, 15)
|
|
|
+ ->drawText("The quick brown fox jumps over the lazy dog", 100, $yPosition);
|
|
|
+ $yPosition -= 30;
|
|
|
+ }
|
|
|
+
|
|
|
+ $fontNames1 = array();
|
|
|
+ foreach ($pdf1->extractFonts() as $font) {
|
|
|
+ $fontNames1[] = $font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en', 'UTF-8');
|
|
|
+ }
|
|
|
+ $this->assertEquals(array(Zend_Pdf_Font::FONT_COURIER,
|
|
|
+ Zend_Pdf_Font::FONT_HELVETICA_BOLD,
|
|
|
+ Zend_Pdf_Font::FONT_TIMES_BOLD_ITALIC,
|
|
|
+ 'BitstreamVeraSans-Bold',
|
|
|
+ 'BitstreamVeraSans-BoldOblique',
|
|
|
+ 'BitstreamVeraSans-Oblique',
|
|
|
+ 'BitstreamVeraSansMono-Bold',
|
|
|
+ 'BitstreamVeraSansMono-BoldOb',
|
|
|
+ 'BitstreamVeraSansMono-Oblique',
|
|
|
+ 'BitstreamVeraSansMono-Roman',
|
|
|
+ 'BitstreamVeraSerif-Bold',
|
|
|
+ 'BitstreamVeraSerif-Roman',
|
|
|
+ 'BitstreamVeraSans-Roman'),
|
|
|
+ $fontNames1);
|
|
|
+
|
|
|
+ $page = reset($pdf1->pages);
|
|
|
+ $font = $page->extractFont(Zend_Pdf_Font::FONT_COURIER);
|
|
|
+ $this->assertTrue($font instanceof Zend_Pdf_Resource_Font_Extracted);
|
|
|
+
|
|
|
+ $font = $page->extractFont(Zend_Pdf_Font::FONT_TIMES_BOLD_ITALIC);
|
|
|
+ $this->assertNull($font);
|
|
|
+
|
|
|
+
|
|
|
+ $font = $pdf1->extractFont(Zend_Pdf_Font::FONT_TIMES_BOLD_ITALIC);
|
|
|
+ $this->assertTrue($font instanceof Zend_Pdf_Resource_Font_Extracted);
|
|
|
+
|
|
|
+ $font = $pdf1->extractFont(Zend_Pdf_Font::FONT_TIMES_ROMAN);
|
|
|
+ $this->assertNull($font);
|
|
|
+
|
|
|
+ $pdf1->save(dirname(__FILE__) . '/_files/output1.pdf');
|
|
|
+ unset($pdf1);
|
|
|
+
|
|
|
+
|
|
|
+ $pdf2 = Zend_Pdf::load(dirname(__FILE__) . '/_files/output1.pdf');
|
|
|
+ $this->assertTrue($pdf2 instanceof Zend_Pdf);
|
|
|
+ unset($pdf2);
|
|
|
+
|
|
|
+ unlink(dirname(__FILE__) . '/_files/output.pdf');
|
|
|
+ unlink(dirname(__FILE__) . '/_files/output1.pdf');
|
|
|
+ }
|
|
|
}
|