/**
  * @dataProvider pageFormatPatternProvider
  */
 function test_basicPageFormats($layout_file, $page_width, $page_height)
 {
     $report = new Thinreports\Report(__DIR__ . "/layouts/{$layout_file}");
     $report->addPage();
     $analyzer = $this->analyzePDF($report->generate());
     $page_size = $analyzer->getSizeOfPage(1);
     $this->assertEquals($page_width, $page_size['width']);
     $this->assertEquals($page_height, $page_size['height']);
 }
 function test_imageRendering()
 {
     $report = new Thinreports\Report(__DIR__ . '/layouts/images.tlf');
     $page = $report->addPage();
     $page('image_jpeg')->setSource(__DIR__ . '/files/image-block-jpeg.jpg');
     $page('image_png')->setSource(__DIR__ . '/files/image-block-png.png');
     $analyzer = $this->analyzePDF($report->generate());
     $this->assertEquals(4, $analyzer->getImageCountInPage(1));
 }
 function test_multipleLayouts()
 {
     $report = new Thinreports\Report(__DIR__ . '/layouts/A4_landscape.tlf');
     foreach (array_keys($this->layout_geometries) as $filename) {
         $report->addPage(__DIR__ . "/layouts/{$filename}.tlf");
         # Insert a blank page
         $report->addBlankPage();
     }
     # Finally, insert a page without specifing layout
     $report->addPage();
     $analyzer = $this->analyzePDF($report->generate());
     $expected_page_formats = array(array('size' => $this->layout_geometries['A3_portrait'], 'is_blank' => false), array('size' => $this->layout_geometries['A3_portrait'], 'is_blank' => true), array('size' => $this->layout_geometries['A4_portrait'], 'is_blank' => false), array('size' => $this->layout_geometries['A4_portrait'], 'is_blank' => true), array('size' => $this->layout_geometries['A4_landscape'], 'is_blank' => false), array('size' => $this->layout_geometries['A4_landscape'], 'is_blank' => true), array('size' => $this->layout_geometries['user_400x400'], 'is_blank' => false), array('size' => $this->layout_geometries['user_400x400'], 'is_blank' => true), array('size' => $this->layout_geometries['A4_landscape'], 'is_blank' => false));
     foreach ($expected_page_formats as $index => $expected_page_format) {
         $page_no = $index + 1;
         $expected_page_size = $expected_page_format['size'];
         $expected_page_is_blank = $expected_page_format['is_blank'];
         $actual_page_size = $analyzer->getSizeOfPage($page_no);
         $actual_page_is_blank = $analyzer->isEmptyPage($page_no);
         $subject = "At page {$page_no}";
         $this->assertEquals($expected_page_size['width'], $actual_page_size['width'], $subject);
         $this->assertEquals($expected_page_size['height'], $actual_page_size['height'], $subject);
         $this->assertEquals($expected_page_is_blank, $actual_page_is_blank, $subject);
     }
 }
 public function createPDF()
 {
     // ==================================
     // $data = $this->EntryInfo->getList();
     $event_id = $this->Session->read('event_info_id');
     $entry_ids = $this->request->data['check'];
     // ==================================
     $eventInfo = $this->EventInfo->find('all', array('conditions' => array('EventInfo.id' => $event_id)));
     if (count($eventInfo) == 0) {
         $this->Session->setFlash(__('イベントデータがありません'));
         return;
     }
     $entryInfo = $this->EntryInfo->find('all', array('conditions' => array('EntryInfo.event_info_id' => $event_id, 'EntryInfo.id' => $entry_ids)));
     if (count($entryInfo) == 0) {
         $this->Session->setFlash(__('参加者情報がありません'));
         return;
     }
     $eventData = $eventInfo[0]['EventInfo'];
     $eventTime = date('Y年n月j日  G時i分 ~ ', strtotime($eventData['event_date']));
     $eventTime = $eventTime . date('G時i分', strtotime($eventData['event_end_date']));
     $publishedTime = date('Y年n月j日', strtotime($eventData['published_date']));
     foreach ($entryInfo as $k => $v) {
         $userName = str_replace(' ', '', $v['EntryInfo']['name']);
         $userName = str_replace(' ', '', $userName);
         $baseFileName = 'ENTRY_ID' . $v['EntryInfo']['id'] . '_' . trim($v['EntryInfo']['medical_instition']) . '_' . trim($userName) . '様.pdf';
         $fileName = mb_convert_encoding($baseFileName, 'sjis-win', 'UTF-8');
         $barcode_id = str_pad($v['EntryInfo']['id'], 12, 0, STR_PAD_LEFT);
         $barcode_file = 'BC_' . $barcode_id . 'png';
         // バーコード作成
         $this->__createBarcord($barcode_id, $barcode_file);
         $report = new Thinreports\Report(FILE_TEMPLATE . 'event_guid_ja.tlf');
         // イベント情報
         $page = $report->addPage();
         $page->item('published_date')->setValue($publishedTime);
         $page->item('event_title')->setValue($eventData['title']);
         $page->item('main_text')->setValue($eventData['main_text']);
         $page->item('event_date')->setValue($eventTime);
         $page->item('event_place')->setValue($eventData['event_place']);
         $page->item('footer_main')->setValue($eventData['footer_main']);
         // 来場者情報
         $page->item('medical_instition')->setValue($v['EntryInfo']['medical_instition']);
         $page->item('department')->setValue($v['EntryInfo']['department']);
         $page->item('name')->setValue($v['EntryInfo']['name']);
         $page->item('tel_no1')->setValue($v['EntryInfo']['tel_no1']);
         $page->item('fax')->setValue($v['EntryInfo']['fax']);
         $page->item('mail_address')->setValue($v['EntryInfo']['mail_address']);
         $page->item('barcord')->setValue(FILE_BARCORD . $barcode_file);
         $report->generate(FILE_PDF . $fileName);
     }
 }