123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778 |
- <?php
- /**
- * ezcDocumentPdfDriverHaruTests
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- * @package Document
- * @version //autogen//
- * @subpackage Tests
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- */
- require_once 'base.php';
- /**
- * Test suite for class.
- *
- * @package Document
- * @subpackage Tests
- */
- abstract class ezcDocumentPdfDriverTests extends ezcDocumentPdfTestCase
- {
- /**
- * Expected font widths for calculateWordWidth tests
- *
- * @var array
- */
- protected $expectedWidths = array(
- 'testEstimateDefaultWordWidthWithoutPageCreation' => null,
- 'testEstimateDefaultWordWidth' => null,
- 'testEstimateWordWidthDifferentSize' => null,
- 'testEstimateWordWidthDifferentSizeAndUnit' => null,
- 'testEstimateBoldWordWidth' => null,
- 'testEstimateMonospaceWordWidth' => null,
- 'testFontStyleFallback' => null,
- 'testUtf8FontWidth' => null,
- 'testCustomFontWidthEstimation' => null,
- );
- /**
- * Get driver to test
- *
- * @return ezcDocumentPdfDriver
- */
- abstract protected function getDriver();
- public function testEstimateDefaultWordWidthWithoutPageCreation()
- {
- $driver = $this->getDriver();
- $this->assertEquals(
- $this->expectedWidths[__FUNCTION__],
- $driver->calculateWordWidth( 'Hello' ),
- 'Wrong word width estimation', .1
- );
- }
- public function testEstimateDefaultWordWidth()
- {
- $driver = $this->getDriver();
- $driver->createPage( 210, 297 );
- $this->assertEquals(
- $this->expectedWidths[__FUNCTION__],
- $driver->calculateWordWidth( 'Hello' ),
- 'Wrong word width estimation', .1
- );
- }
- public function testEstimateWordWidthDifferentSize()
- {
- $driver = $this->getDriver();
- $driver->createPage( 210, 297 );
- $driver->setTextFormatting( 'font-size', '14' );
- $this->assertEquals(
- $this->expectedWidths[__FUNCTION__],
- $driver->calculateWordWidth( 'Hello' ),
- 'Wrong word width estimation', .1
- );
- }
- public function testEstimateWordWidthDifferentSizeAndUnit()
- {
- $driver = $this->getDriver();
- $driver->createPage( 210, 297 );
- $driver->setTextFormatting( 'font-size', '14pt' );
- $this->assertEquals(
- $this->expectedWidths[__FUNCTION__],
- $driver->calculateWordWidth( 'Hello' ),
- 'Wrong word width estimation', .1
- );
- }
- public function testEstimateBoldWordWidth()
- {
- $driver = $this->getDriver();
- $driver->createPage( 210, 297 );
- $driver->setTextFormatting( 'font-weight', 'bold' );
- $this->assertEquals(
- $this->expectedWidths[__FUNCTION__],
- $driver->calculateWordWidth( 'Hello' ),
- 'Wrong word width estimation', .1
- );
- }
- public function testEstimateMonospaceWordWidth()
- {
- $driver = $this->getDriver();
- $driver->createPage( 210, 297 );
- $driver->setTextFormatting( 'font-family', 'monospace' );
- $driver->setTextFormatting( 'font-size', '12' );
- $this->assertEquals(
- $this->expectedWidths[__FUNCTION__],
- $driver->calculateWordWidth( 'Hello' ),
- 'Wrong word width estimation', .1
- );
- }
- public function testFontStyleFallback()
- {
- $driver = $this->getDriver();
- $driver->createPage( 210, 297 );
- $driver->setTextFormatting( 'font-family', 'ZapfDingbats' );
- $driver->setTextFormatting( 'font-weight', 'bold' );
- $driver->setTextFormatting( 'font-style', 'italic' );
- $this->assertEquals(
- $this->expectedWidths[__FUNCTION__],
- $driver->calculateWordWidth( 'Hello' ),
- 'Wrong word width estimation', .1
- );
- }
- public function testUtf8FontWidth()
- {
- $driver = $this->getDriver();
- $driver->createPage( 210, 297 );
- $this->assertEquals(
- $this->expectedWidths[__FUNCTION__],
- $driver->calculateWordWidth( 'ℋℇℒℒΩ' ),
- 'Wrong word width estimation', .1
- );
- }
- public function testCustomFontWidthEstimation()
- {
- $driver = $this->getDriver();
- try {
- $driver->registerFont(
- 'my_font',
- ezcDocumentPdfDriver::FONT_PLAIN,
- array(
- dirname( __FILE__ ) . '/../files/fonts/fdb_font.fdb',
- dirname( __FILE__ ) . '/../files/fonts/ps_font.pfb',
- dirname( __FILE__ ) . '/../files/fonts/font.ttf',
- )
- );
- } catch ( ezcBaseFunctionalityNotSupportedException $e )
- {
- $this->markTestSkipped( 'Fonts are not supported.' );
- }
- $driver->createPage( 210, 297 );
- $driver->setTextFormatting( 'font-family', 'my_font' );
- $driver->setTextFormatting( 'font-size', '10' );
- $driver->setTextFormatting( 'font-weight', 'bold' );
- $this->assertEquals(
- $this->expectedWidths[__FUNCTION__],
- $driver->calculateWordWidth( 'Hello world.' ),
- 'Wrong word width estimation', .1
- );
- }
- public function testRenderHelloWorld()
- {
- $driver = $this->getDriver();
- $driver->createPage( 210, 297 );
- $driver->setTextFormatting( 'font-family', 'sans-serif' );
- $driver->setTextFormatting( 'font-size', '10' );
- $driver->drawWord( 0, 10, 'The quick brown fox jumps over the lazy dog' );
- $driver->drawWord( 0, 297, 'The quick brown fox jumps over the lazy dog' );
- $pdf = $driver->save();
- $this->assertPdfDocumentsSimilar( $pdf, get_class( $driver ) . '_' . __FUNCTION__ );
- }
- public function testRenderHelloWorldSmallFont()
- {
- $driver = $this->getDriver();
- $driver->createPage( 210, 297 );
- $driver->setTextFormatting( 'font-family', 'sans-serif' );
- $driver->setTextFormatting( 'font-size', '4' );
- $driver->drawWord( 0, 4, 'The quick brown fox jumps over the lazy dog' );
- $driver->drawWord( 0, 297, 'The quick brown fox jumps over the lazy dog' );
- $pdf = $driver->save();
- $this->assertPdfDocumentsSimilar( $pdf, get_class( $driver ) . '_' . __FUNCTION__ );
- }
- public function testRenderSwitchingFontStates()
- {
- $driver = $this->getDriver();
- $driver->createPage( 210, 297 );
- $driver->setTextFormatting( 'font-size', '8' );
- $driver->drawWord( 0, 8, 'The quick brown fox jumps over the lazy dog' );
- $driver->setTextFormatting( 'font-weight', 'bold' );
- $driver->setTextFormatting( 'font-style', 'italic' );
- $driver->drawWord( 0, 18, 'The quick brown fox jumps over the lazy dog' );
- $driver->setTextFormatting( 'font-style', 'normal' );
- $driver->drawWord( 0, 28, 'The quick brown fox jumps over the lazy dog' );
- $driver->setTextFormatting( 'font-weight', 'normal' );
- $driver->drawWord( 0, 38, 'The quick brown fox jumps over the lazy dog' );
- $driver->setTextFormatting( 'font-weight', 'bold' );
- $driver->drawWord( 0, 48, 'The quick brown fox jumps over the lazy dog' );
- $driver->setTextFormatting( 'font-family', 'serif' );
- $driver->drawWord( 0, 58, 'The quick brown fox jumps over the lazy dog' );
- $driver->setTextFormatting( 'font-weight', 'normal' );
- $driver->drawWord( 0, 68, 'The quick brown fox jumps over the lazy dog' );
- $driver->setTextFormatting( 'font-family', 'Symbol' );
- $driver->drawWord( 0, 78, 'The quick brown fox jumps over the lazy dog' );
- $driver->setTextFormatting( 'font-weight', 'bold' );
- $driver->drawWord( 0, 88, 'The quick brown fox jumps over the lazy dog' );
- $driver->setTextFormatting( 'font-style', 'italic' );
- $driver->drawWord( 0, 98, 'The quick brown fox jumps over the lazy dog' );
- $driver->setTextFormatting( 'font-family', 'monospace' );
- $driver->drawWord( 0, 108, 'The quick brown fox jumps over the lazy dog' );
- $driver->setTextFormatting( 'font-weight', 'bold' );
- $driver->setTextFormatting( 'font-style', 'italic' );
- $driver->drawWord( 0, 118, 'The quick brown fox jumps over the lazy dog' );
- $pdf = $driver->save();
- $this->assertPdfDocumentsSimilar( $pdf, get_class( $driver ) . '_' . __FUNCTION__ );
- }
- public function testRenderUtf8Text()
- {
- $driver = $this->getDriver();
- $driver->createPage( 210, 297 );
- $driver->drawWord( 10, 10, 'ℋℇℒℒΩ' );
- $pdf = $driver->save();
- $this->assertPdfDocumentsSimilar( $pdf, get_class( $driver ) . '_' . __FUNCTION__ );
- }
- public function testRenderPngImage()
- {
- $driver = $this->getDriver();
- $driver->createPage( 210, 297 );
- $driver->drawImage(
- dirname( __FILE__ ) . '/../files/pdf/images/logo-white.png', 'image/png',
- 50, 50,
- ezcDocumentPcssMeasure::create( '113px' )->get(),
- ezcDocumentPcssMeasure::create( '57px' )->get()
- );
- $pdf = $driver->save();
- $this->assertPdfDocumentsSimilar( $pdf, get_class( $driver ) . '_' . __FUNCTION__ );
- }
- public function testRenderResizedJpegImage()
- {
- $driver = $this->getDriver();
- $driver->createPage( 210, 297 );
- $driver->drawImage(
- dirname( __FILE__ ) . '/../files/pdf/images/large.jpeg', 'image/jpeg',
- 50, 50,
- 110, 100
- );
- $pdf = $driver->save();
- $this->assertPdfDocumentsSimilar( $pdf, get_class( $driver ) . '_' . __FUNCTION__ );
- }
- public function testRenderColoredText()
- {
- $driver = $this->getDriver();
- $driver->createPage( 210, 297 );
- $driver->setTextFormatting( 'font-family', 'sans-serif' );
- $driver->setTextFormatting( 'font-size', '4' );
- $color = new ezcDocumentPcssStyleColorValue();
- $color->parse( '#204a87' );
- $driver->setTextFormatting( 'color', $color->value );
- $driver->drawWord( 10, 10, 'The quick brown fox jumps over the lazy dog.' );
- $pdf = $driver->save();
- $this->assertPdfDocumentsSimilar( $pdf, get_class( $driver ) . '_' . __FUNCTION__ );
- }
- public function testRenderPolygon()
- {
- $driver = $this->getDriver();
- $driver->createPage( 210, 297 );
- $color = new ezcDocumentPcssStyleColorValue();
- $color->parse( '#204a87' );
- $driver->drawPolygon(
- array(
- array( 10, 10 ),
- array( 200, 10 ),
- array( 105, 287 ),
- ),
- $color->value
- );
- $pdf = $driver->save();
- $this->assertPdfDocumentsSimilar( $pdf, get_class( $driver ) . '_' . __FUNCTION__ );
- }
- public function testRenderPolylineClosed()
- {
- $driver = $this->getDriver();
- $driver->createPage( 210, 297 );
- $color = new ezcDocumentPcssStyleColorValue();
- $color->parse( '#204a87' );
- $driver->drawPolyline(
- array(
- array( 10, 10 ),
- array( 200, 10 ),
- array( 105, 287 ),
- ),
- $color->value,
- 1
- );
- $pdf = $driver->save();
- $this->assertPdfDocumentsSimilar( $pdf, get_class( $driver ) . '_' . __FUNCTION__ );
- }
- public function testRenderPolylineOpen()
- {
- $driver = $this->getDriver();
- $driver->createPage( 210, 297 );
- $color = new ezcDocumentPcssStyleColorValue();
- $color->parse( '#204a87' );
- $driver->drawPolyline(
- array(
- array( 200, 10 ),
- array( 105, 287 ),
- array( 10, 10 ),
- ),
- $color->value,
- ezcDocumentPcssMeasure::create( '1pt' )->get(),
- false
- );
- $pdf = $driver->save();
- $this->assertPdfDocumentsSimilar( $pdf, get_class( $driver ) . '_' . __FUNCTION__ );
- }
- public function testRenderLayeredPolygons()
- {
- $driver = $this->getDriver();
- $driver->createPage( 210, 297 );
- $color = new ezcDocumentPcssStyleColorValue();
- $color->parse( '#204a87' );
- $driver->drawPolygon(
- array(
- array( 10, 10 ),
- array( 200, 10 ),
- array( 105, 287 ),
- ),
- $color->value
- );
- $color = new ezcDocumentPcssStyleColorValue();
- $color->parse( '#2e3436' );
- $driver->drawPolyline(
- array(
- array( 200, 287 ),
- array( 105, 10 ),
- array( 10, 287 ),
- ),
- $color->value,
- 1,
- false
- );
- $pdf = $driver->save();
- $this->assertPdfDocumentsSimilar( $pdf, get_class( $driver ) . '_' . __FUNCTION__ );
- }
- public function testAddExternalLink()
- {
- $driver = $this->getDriver();
- if ( $driver instanceof ezcDocumentPdfSvgDriver )
- {
- $this->markTestSkipped( 'Not supported by the SVG driver.' );
- }
- $driver->createPage( 100, 100 );
- $driver->addExternalLink( 0, 0, 100, 100, 'http://ezcomponents.org/' );
- $pdf = $driver->save();
- $this->assertPdfDocumentsSimilar( $pdf, get_class( $driver ) . '_' . __FUNCTION__ );
- }
- public function testAddInternalLinkWithoutTarget()
- {
- $driver = $this->getDriver();
- if ( $driver instanceof ezcDocumentPdfSvgDriver )
- {
- $this->markTestSkipped( 'Not supported by the SVG driver.' );
- }
- $driver->createPage( 100, 100 );
- $driver->addInternalLink( 0, 0, 100, 50, 'my_target' );
- $pdf = $driver->save();
- $this->assertPdfDocumentsSimilar( $pdf, get_class( $driver ) . '_' . __FUNCTION__ );
- }
- public function testAddInternalLinkAndTarget()
- {
- $driver = $this->getDriver();
- if ( $driver instanceof ezcDocumentPdfSvgDriver )
- {
- $this->markTestSkipped( 'Not supported by the SVG driver.' );
- }
- $driver->createPage( 100, 100 );
- $driver->addInternalLink( 0, 0, 100, 50, 'my_target' );
- $driver->addInternalLinkTarget( 'my_target' );
- $pdf = $driver->save();
- $this->assertPdfDocumentsSimilar( $pdf, get_class( $driver ) . '_' . __FUNCTION__ );
- }
- public function testAddInternalLinkAndTargetOnNextPage()
- {
- $driver = $this->getDriver();
- if ( $driver instanceof ezcDocumentPdfSvgDriver )
- {
- $this->markTestSkipped( 'Not supported by the SVG driver.' );
- }
- $driver->createPage( 100, 100 );
- $driver->addInternalLink( 0, 0, 100, 50, 'my_target' );
- $driver->createPage( 100, 100 );
- $driver->addInternalLinkTarget( 'my_target' );
- $pdf = $driver->save();
- $this->assertPdfDocumentsSimilar( $pdf, get_class( $driver ) . '_' . __FUNCTION__ );
- }
- public function testRenderUnknownFont()
- {
- $driver = $this->getDriver();
- if ( $driver instanceof ezcDocumentPdfSvgDriver )
- {
- $this->markTestSkipped( 'Not supported by the SVG driver.' );
- }
- try {
- $driver->createPage( 250, 100 );
- $driver->setTextFormatting( 'font-family', 'my_font' );
- $this->fail( 'Expected ezcDocumentInvalidFontException.' );
- } catch ( ezcDocumentInvalidFontException $e )
- { /* Expected */ }
- }
- public function testRenderPlainTTFFont()
- {
- $driver = $this->getDriver();
- try {
- $driver->registerFont(
- 'my_font',
- ezcDocumentPdfDriver::FONT_PLAIN,
- array(
- dirname( __FILE__ ) . '/../files/fonts/font.ttf',
- )
- );
- } catch ( ezcBaseFunctionalityNotSupportedException $e )
- {
- $this->markTestSkipped( 'Fonts are not supported.' );
- }
- $driver->createPage( 250, 100 );
- $driver->setTextFormatting( 'font-family', 'my_font' );
- $driver->setTextFormatting( 'font-size', '10' );
- $driver->drawWord( 0, 10, 'The quick brown fox jumps over the lazy dog' );
- $pdf = $driver->save();
- $this->assertPdfDocumentsSimilar( $pdf, get_class( $driver ) . '_' . __FUNCTION__ );
- }
- public function testRenderUnregisteredBoldTTFFont()
- {
- $driver = $this->getDriver();
- try {
- $driver->registerFont(
- 'my_font',
- ezcDocumentPdfDriver::FONT_PLAIN,
- array(
- dirname( __FILE__ ) . '/../files/fonts/font.ttf',
- )
- );
- } catch ( ezcBaseFunctionalityNotSupportedException $e )
- {
- $this->markTestSkipped( 'Fonts are not supported.' );
- }
- $driver->createPage( 250, 100 );
- $driver->setTextFormatting( 'font-family', 'my_font' );
- $driver->setTextFormatting( 'font-size', '10' );
- $driver->setTextFormatting( 'font-weight', 'bold' );
- $driver->drawWord( 0, 10, 'The quick brown fox jumps over the lazy dog' );
- $pdf = $driver->save();
- $this->assertPdfDocumentsSimilar( $pdf, get_class( $driver ) . '_' . __FUNCTION__ );
- }
- public function testRenderRegisteredBoldTTFFont()
- {
- $driver = $this->getDriver();
- try {
- $driver->registerFont(
- 'my_font',
- ezcDocumentPdfDriver::FONT_PLAIN,
- array(
- dirname( __FILE__ ) . '/../files/fonts/font.ttf',
- )
- );
- $driver->registerFont(
- 'my_font',
- ezcDocumentPdfDriver::FONT_BOLD,
- array(
- dirname( __FILE__ ) . '/../files/fonts/font2.ttf',
- )
- );
- } catch ( ezcBaseFunctionalityNotSupportedException $e )
- {
- $this->markTestSkipped( 'Fonts are not supported.' );
- }
- $driver->createPage( 250, 100 );
- $driver->setTextFormatting( 'font-family', 'my_font' );
- $driver->setTextFormatting( 'font-size', '10' );
- $driver->setTextFormatting( 'font-weight', 'bold' );
- $driver->drawWord( 0, 10, 'The quick brown fox jumps over the lazy dog' );
- $pdf = $driver->save();
- $this->assertPdfDocumentsSimilar( $pdf, get_class( $driver ) . '_' . __FUNCTION__ );
- }
- public function testRenderMultipleAlternativeFonts()
- {
- $driver = $this->getDriver();
- try {
- $driver->registerFont(
- 'my_font',
- ezcDocumentPdfDriver::FONT_PLAIN,
- array(
- dirname( __FILE__ ) . '/../files/fonts/fdb_font.fdb',
- dirname( __FILE__ ) . '/../files/fonts/ps_font.pfb',
- dirname( __FILE__ ) . '/../files/fonts/font.ttf',
- )
- );
- } catch ( ezcBaseFunctionalityNotSupportedException $e )
- {
- $this->markTestSkipped( 'Fonts are not supported.' );
- }
- $driver->createPage( 250, 100 );
- $driver->setTextFormatting( 'font-family', 'my_font' );
- $driver->setTextFormatting( 'font-size', '10' );
- $driver->drawWord( 0, 10, 'The quick brown fox jumps over the lazy dog' );
- $pdf = $driver->save();
- $this->assertPdfDocumentsSimilar( $pdf, get_class( $driver ) . '_' . __FUNCTION__ );
- }
- public function testSetDocumentMetaDataTitle()
- {
- $driver = $this->getDriver();
- $driver->createPage( 100, 100 );
- $driver->setTextFormatting( 'font-size', '10' );
- $driver->drawWord( 0, 10, 'Document metadata test.' );
- $driver->setMetaData( 'title', 'Test document title' );
- $pdf = $driver->save();
- $this->assertPdfDocumentsSimilar( $pdf, get_class( $driver ) . '_' . __FUNCTION__ );
- }
- public function testSetDocumentMetaDataAuthor()
- {
- $driver = $this->getDriver();
- $driver->createPage( 100, 100 );
- $driver->setTextFormatting( 'font-size', '10' );
- $driver->drawWord( 0, 10, 'Document metadata test.' );
- $driver->setMetaData( 'author', 'Kore Nordmann' );
- $pdf = $driver->save();
- $this->assertPdfDocumentsSimilar( $pdf, get_class( $driver ) . '_' . __FUNCTION__ );
- }
- public function testSetDocumentMetaDataSubject()
- {
- $driver = $this->getDriver();
- $driver->createPage( 100, 100 );
- $driver->setTextFormatting( 'font-size', '10' );
- $driver->drawWord( 0, 10, 'Document metadata test.' );
- $driver->setMetaData( 'subject', 'Test document subject' );
- $pdf = $driver->save();
- $this->assertPdfDocumentsSimilar( $pdf, get_class( $driver ) . '_' . __FUNCTION__ );
- }
- public function testSetDocumentMetaDataCreated()
- {
- $driver = $this->getDriver();
- $driver->createPage( 100, 100 );
- $driver->setTextFormatting( 'font-size', '10' );
- $driver->drawWord( 0, 10, 'Document metadata test.' );
- $driver->setMetaData( 'created', date( 'r', 12345678 ) );
- $pdf = $driver->save();
- $this->assertPdfDocumentsSimilar( $pdf, get_class( $driver ) . '_' . __FUNCTION__ );
- }
- public function testSetDocumentMetaDataModified()
- {
- $driver = $this->getDriver();
- $driver->createPage( 100, 100 );
- $driver->setTextFormatting( 'font-size', '10' );
- $driver->drawWord( 0, 10, 'Document metadata test.' );
- $driver->setMetaData( 'modified', date( 'r', 12345678 ) );
- $pdf = $driver->save();
- $this->assertPdfDocumentsSimilar( $pdf, get_class( $driver ) . '_' . __FUNCTION__ );
- }
- public function testGenerateCompressedPdf()
- {
- $driver = $this->getDriver();
- if ( $driver instanceof ezcDocumentPdfSvgDriver )
- {
- $this->markTestSkipped( 'Not supported by the SVG driver.' );
- }
- $options = new ezcDocumentPdfOptions();
- $options->compress = true;
- $driver->setOptions( $options );
- $driver->createPage( 100, 100 );
- $driver->setTextFormatting( 'font-size', '10' );
- $driver->drawWord( 0, 10, 'Document compression test.' );
- $pdf = $driver->save();
- $this->assertPdfDocumentsSimilar( $pdf, get_class( $driver ) . '_' . __FUNCTION__ );
- }
- public function testGeneratePdfWithOwnerPassword()
- {
- $driver = $this->getDriver();
- if ( $driver instanceof ezcDocumentPdfSvgDriver )
- {
- $this->markTestSkipped( 'Not supported by the SVG driver.' );
- }
- $options = new ezcDocumentPdfOptions();
- $options->ownerPassword = 'foobar23';
- $driver->setOptions( $options );
- $driver->createPage( 100, 100 );
- $driver->setTextFormatting( 'font-size', '10' );
- $driver->drawWord( 0, 10, 'Document compression test.' );
- $pdf = $driver->save();
- // We cannot make any proper asserstions here, since the PDF contents
- // change with each regeneration because of the encryption
- $this->assertFalse( empty( $pdf ) );
- }
- public function testGenerateEncryptedPdf()
- {
- $driver = $this->getDriver();
- if ( $driver instanceof ezcDocumentPdfSvgDriver )
- {
- $this->markTestSkipped( 'Not supported by the SVG driver.' );
- }
- $options = new ezcDocumentPdfOptions();
- $options->ownerPassword = 'foobar23';
- $options->userPassword = 'foobar';
- $driver->setOptions( $options );
- $driver->createPage( 100, 100 );
- $driver->setTextFormatting( 'font-size', '10' );
- $driver->drawWord( 0, 10, 'Document compression test.' );
- $pdf = $driver->save();
- // We cannot make any proper asserstions here, since the PDF contents
- // change with each regeneration because of the encryption
- $this->assertFalse( empty( $pdf ) );
- }
- public function testGenerateEncryptedProtectedPdf()
- {
- $driver = $this->getDriver();
- if ( $driver instanceof ezcDocumentPdfSvgDriver )
- {
- $this->markTestSkipped( 'Not supported by the SVG driver.' );
- }
- $options = new ezcDocumentPdfOptions();
- $options->permissions = 0;
- $options->ownerPassword = 'foobar23';
- $options->userPassword = 'foobar';
- $driver->setOptions( $options );
- $driver->createPage( 100, 100 );
- $driver->setTextFormatting( 'font-size', '10' );
- $driver->drawWord( 0, 10, 'Document compression test.' );
- $pdf = $driver->save();
- // We cannot make any proper asserstions here, since the PDF contents
- // change with each regeneration because of the encryption
- $this->assertFalse( empty( $pdf ) );
- }
- }
- ?>
|