Example #1
0
File: base.php Project: bmdevel/ezc
 /**
  * Test rendering of a full document
  *
  * Test the rendering of a given full document with an
  * additional set of user configured styles.
  *
  * @param string $file 
  * @param string $fileName 
  * @param array $styles 
  * @return void
  */
 protected function renderFullDocument($file, $fileName, array $styles = array())
 {
     $docbook = new ezcDocumentDocbook();
     $docbook->loadFile($file);
     $style = new ezcDocumentPcssStyleInferencer();
     $style->appendStyleDirectives(array(new ezcDocumentPcssLayoutDirective(array('article'), array('font-family' => 'serif', 'line-height' => '1')), new ezcDocumentPcssLayoutDirective(array('title'), array('font-family' => 'sans-serif'))));
     $style->appendStyleDirectives($styles);
     $renderer = new ezcDocumentPdfMainRenderer(new ezcDocumentPdfSvgDriver(), $style, new ezcDocumentPdfOptions());
     $pdf = $renderer->render($docbook, new ezcDocumentPdfDefaultHyphenator());
     file_put_contents($this->tempDir . $fileName, $pdf);
     $this->assertXmlFileEqualsXmlFile($this->basePath . 'renderer/' . $fileName, $this->tempDir . $fileName);
 }
 public function setUp()
 {
     parent::setUp();
     $style = new ezcDocumentPcssStyleInferencer();
     $style->appendStyleDirectives(array(new ezcDocumentPcssLayoutDirective(array('article'), array('font-family' => 'serif', 'text-columns' => '2', 'font-size' => '10pt', 'line-height' => '1')), new ezcDocumentPcssLayoutDirective(array('title'), array('font-family' => 'sans-serif', 'text-columns' => '2')), new ezcDocumentPcssLayoutDirective(array('page'), array('page-size' => 'A5'))));
     $this->docbook = new ezcDocumentDocbook();
     $this->docbook->loadFile(dirname(__FILE__) . '/../files/pdf/long_text.xml');
     $this->renderer = new ezcDocumentPdfMainRenderer(new ezcDocumentPdfSvgDriver(), $style);
 }
Example #3
0
 /**
  * Adds a PCSS stylesheet from the given file.
  *
  * Reads the given PCSS $file and adds the contained stylesheets to the 
  * styler.
  * 
  * @param string $file 
  */
 public function addStylesheetFile($file)
 {
     $parser = $this->createStyleParser();
     if (!file_exists($file)) {
         throw new ezcBaseFileNotFoundException($file, 'PCSS');
     }
     if (!is_readable($file)) {
         throw new ezcBaseFilePermissionException($file, ezcBaseFileException::READ);
     }
     $this->styleInferencer->appendStyleDirectives($parser->parseFile($file));
 }
Example #4
0
 public function testDefinitionExtraction2()
 {
     $inferencer = new ezcDocumentPcssStyleInferencer(false);
     $inferencer->appendStyleDirectives(array($d1 = new ezcDocumentPcssDeclarationDirective('@font-FACE', array('font-size' => '10')), new ezcDocumentPcssDeclarationDirective('@unknown', array('font-size' => '10'))));
     $this->assertEquals(array($d1), $inferencer->getDefinitions('font-face'));
 }
Example #5
0
 /**
  * Load style definition file
  *
  * Parse and load a PCSS file and use the resulting style definitions for
  * rendering.
  *
  * @param string $file
  * @return void
  */
 public function loadStyles($file)
 {
     $parser = new ezcDocumentPcssParser();
     $this->styles->appendStyleDirectives($parser->parseFile($file));
 }
Example #6
0
 public function testRenderCustomFont()
 {
     $docbook = new ezcDocumentDocbook();
     $docbook->loadFile(dirname(__FILE__) . '/../files/pdf/wrapping.xml');
     $style = new ezcDocumentPcssStyleInferencer();
     $style->appendStyleDirectives(array(new ezcDocumentPcssLayoutDirective(array('article'), array('font-family' => 'my-font')), new ezcDocumentPcssDeclarationDirective('@font-face', array('font-family' => 'my-font', 'src' => 'url( ' . dirname(__FILE__) . '/../files/fonts/font.ttf )'))));
     $renderer = new ezcDocumentPdfMainRenderer(new ezcDocumentPdfSvgDriver(), $style);
     $pdf = $renderer->render($docbook, new ezcDocumentPdfDefaultHyphenator());
     $this->assertPdfDocumentsSimilar($pdf, __CLASS__ . '_' . __FUNCTION__);
 }