Example #1
1
function exportWord($text, $font, $size, $bold)
{
    $phpWord = new \PhpOffice\PhpWord\PhpWord();
    $section = $phpWord->addSection();
    //
    //    $section->addText($text);
    //
    //    $section->addText('Hello world! I am formatted.',
    //        array('name'=>'Tahoma', 'size'=>16, 'bold'=>true));
    //    $phpWord->addFontStyle('myOwnStyle',
    //        array('name'=>'Verdana', 'size'=>14, 'color'=>'1B2232'));
    //    $section->addText('Hello world! I am formatted by a user defined style',
    //        'myOwnStyle');
    $fontStyle = new \PhpOffice\PhpWord\Style\Font();
    $fontStyle->setBold($bold);
    $fontStyle->setName($font);
    $fontStyle->setSize($size);
    $myTextElement = $section->addText($text);
    $myTextElement->setFontStyle($fontStyle);
    $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
    $objWriter->save('helloWorld.docx');
}
Example #2
1
 public function vytvorZiadostHlasovaniePostouNonSR($obec, $n2k)
 {
     $phpWord = new \PhpOffice\PhpWord\PhpWord();
     /* Note: any element you append to a document must reside inside of a Section. */
     $phpWord->addParagraphStyle('pStylel', array('spacing' => 5));
     $phpWord->addParagraphStyle('pStylec', array('spacing' => 5, 'align' => 'center'));
     $phpWord->addParagraphStyle('pStyler', array('spacing' => 5, 'align' => 'right'));
     $section = $phpWord->addSection();
     $textrun = $section->addTextRun('pStyler');
     $textrun->addText(htmlspecialchars("ŽIADOSŤ VYPLŇTE VEĽKÝMI PÍSMENAMI."), array('bold' => true));
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun = $section->addTextRun('pStylec');
     $textrun->addText(htmlspecialchars("Žiadosť\to voľbu poštou"), array("size" => "14"));
     $textrun->addTextBreak();
     $textrun->addText(htmlspecialchars("pre voľby do Národnej rady Slovenskej republiky v roku 2016"), array("size" => "14"));
     $textrun = $section->addTextRun('pStylel');
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $this->spracujAdresuPrijemcu($textrun, $obec, $n2k);
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addText(htmlspecialchars("Podľa   § 59 ods. 1   zákona   č. 180/2014 Z. z. o podmienkach výkonu volebného práva a o zmene a doplnení niektorých zákonov žiadam o voľbu poštou pre voľby do Národnej rady Slovenskej republiky v roku 2016 a o zaslanie hlasovacích lístkov a obálok na adresu:"));
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addText(htmlspecialchars("Meno:\t\t\t\t"));
     $textrun->addText(htmlspecialchars("MENO"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW));
     $textrun->addTextBreak();
     $textrun->addText(htmlspecialchars("Priezvisko:\t\t\t"));
     $textrun->addText(htmlspecialchars("PRIEZVISKO"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW));
     $textrun->addTextBreak();
     $textrun->addText(htmlspecialchars("Rodné priezvisko:\t\t"));
     $textrun->addText(htmlspecialchars("RODNÉ PRIEZVISKO"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW));
     $textrun->addTextBreak();
     $textrun->addText(htmlspecialchars("Rodné číslo:\t\t\t"));
     $textrun->addText(htmlspecialchars("RODNÉ ČÍSLO"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW));
     $textrun->addTextBreak();
     $textrun->addText(htmlspecialchars("Ulica:\t\t\t\t"));
     $textrun->addText(htmlspecialchars("ULICA"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW));
     $textrun->addTextBreak();
     $textrun->addText(htmlspecialchars("Číslo domu:\t\t\t"));
     $textrun->addText(htmlspecialchars("ČÍSLO DOMU"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW));
     $textrun->addTextBreak();
     $textrun->addText(htmlspecialchars("Obec:\t\t\t\t"));
     $textrun->addText(htmlspecialchars("OBEC"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW));
     $textrun->addTextBreak();
     $textrun->addText(htmlspecialchars("PSČ:\t\t\t\t"));
     $textrun->addText(htmlspecialchars("PSČ"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW));
     $textrun->addTextBreak();
     $textrun->addText(htmlspecialchars("Štát:\t\t\t\t"));
     $textrun->addText(htmlspecialchars("ŠTÁT"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW));
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addText(htmlspecialchars("Prílohy:"));
     $textrun->addTextBreak();
     $textrun->addText(htmlspecialchars("- čestné vyhlásenie voliča, že nemá trvalý pobyt na území Slovenskej republiky."));
     $textrun->addTextBreak();
     $textrun->addText(htmlspecialchars("- fotokópia časti cestovného dokladu Slovenskej republiky s osobnými údajmi voliča alebo fotokópia osvedčenia o štátnom občianstve Slovenskej republiky voliča."));
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addText(htmlspecialchars("V "));
     $textrun->addText(htmlspecialchars("MIESTO KDE SA NACHÁDZATE"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW));
     $textrun->addText(htmlspecialchars(", dňa "));
     $textrun->addText(htmlspecialchars("DNEŠNÝ DÁTUM"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW));
     $textrun->addTextBreak();
     $textrun = $section->addTextRun('pStyler');
     $textrun->addText(htmlspecialchars("MENO ALEBO PODPIS"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW));
     $section = $phpWord->addSection();
     $textrun = $section->addTextRun('pStylec');
     $textrun->addText(htmlspecialchars("meno, priezvisko, rodné číslo alebo dátum narodenia, adresa trvalého pobytu v cudzine"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW));
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addText(htmlspecialchars("ČESTNÉ VYHLÁSENIE"), array('size' => 20));
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addText(htmlspecialchars("Na účely voľby poštou do Národnej rady Slovenskej republiky v roku 2016"), array('size' => 12));
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addText(htmlspecialchars("čestne vyhlasujem,"), array('size' => 12, 'bold' => true));
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addText(htmlspecialchars("že nemám trvalý pobyt na území Slovenskej republiky."), array('size' => 12));
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun->addTextBreak();
     $textrun = $section->addTextRun('pStylel');
     $textrun->addText(htmlspecialchars("V "));
     $textrun->addText(htmlspecialchars("MIESTO KDE SA NACHÁDZATE"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW));
     $textrun->addText(htmlspecialchars(", dňa "));
     $textrun->addText(htmlspecialchars("DNEŠNÝ DÁTUM"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW));
     $textrun->addTextBreak();
     $textrun = $section->addTextRun('pStyler');
     $textrun->addText(htmlspecialchars("MENO ALEBO PODPIS"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW));
     $section = $phpWord->addSection();
     $textrun = $section->addTextRun('pStylec');
     $textrun->addText(htmlspecialchars("fotokópia časti cestovného dokladu Slovenskej republiky s osobnými údajmi voliča alebo fotokópia osvedčenia o štátnom občianstve Slovenskej republiky voliča"), array('size' => '30', 'bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW));
     return $phpWord;
 }
Example #3
0
 /**
  * Test write styles
  */
 public function testFontRTL()
 {
     $phpWord = new \PhpOffice\PhpWord\PhpWord();
     $section = $phpWord->addSection();
     $textrun = $section->addTextRun();
     $textrun->addText(htmlspecialchars('سلام این یک پاراگراف راست به چپ است', ENT_COMPAT, 'UTF-8'), array('rtl' => true));
     $doc = TestHelperDOCX::getDocument($phpWord, 'Word2007');
     $file = 'word/document.xml';
     $path = '/w:document/w:body/w:p/w:r/w:rPr/w:rtl';
     $this->assertTrue($doc->elementExists($path, $file));
 }
Example #4
0
 function write($fileName)
 {
     $phpWord = new \PhpOffice\PhpWord\PhpWord();
     $document = $phpWord->loadTemplate(dirname(__FILE__) . '/template_carta_adj.docx');
     setlocale(LC_ALL, "es_ES@euro", "es_ES", "esp");
     $document->setValue('NUMOC', $this->getDataSource()->getParameter('num_tramite'));
     // On section/content
     $document->setValue('PROVEEDOR', $this->getDataSource()->getParameter('desc_proveedor'));
     // On section/content
     $document->setValue('OBJETIVO', $this->getDataSource()->getParameter('objeto'));
     // On section/content
     $document->setValue('FECHAOC', strftime("%d de %B de %Y", strtotime($this->getDataSource()->getParameter('fecha_oc'))));
     // On section/content
     $document->saveAs($fileName);
 }
Example #5
0
 /**
  * @param array $pages
  * @param string $fileName
  * @param array|int $format
  */
 public static function html2doc($pages, $fileName, $format = array())
 {
     if (is_array($format)) {
         // PDF Page Format parameters passed in - merge with defaults
         $format += CRM_Core_BAO_PdfFormat::getDefaultValues();
     } else {
         // PDF Page Format ID passed in
         $format = CRM_Core_BAO_PdfFormat::getById($format);
     }
     $paperSize = CRM_Core_BAO_PaperSize::getByName($format['paper_size']);
     $metric = CRM_Core_BAO_PdfFormat::getValue('metric', $format);
     $pageStyle = array('orientation' => CRM_Core_BAO_PdfFormat::getValue('orientation', $format), 'pageSizeW' => self::toTwip($paperSize['width'], $paperSize['metric']), 'pageSizeH' => self::toTwip($paperSize['height'], $paperSize['metric']), 'marginTop' => self::toTwip(CRM_Core_BAO_PdfFormat::getValue('margin_top', $format), $metric), 'marginRight' => self::toTwip(CRM_Core_BAO_PdfFormat::getValue('margin_right', $format), $metric), 'marginBottom' => self::toTwip(CRM_Core_BAO_PdfFormat::getValue('margin_bottom', $format), $metric), 'marginLeft' => self::toTwip(CRM_Core_BAO_PdfFormat::getValue('margin_left', $format), $metric));
     $ext = pathinfo($fileName, PATHINFO_EXTENSION);
     $phpWord = new \PhpOffice\PhpWord\PhpWord();
     $phpWord->getDocInfo()->setCreator(CRM_Core_DAO::getFieldValue('CRM_Contact_BAO_Contact', CRM_Core_Session::getLoggedInContactID(), 'display_name'));
     foreach ((array) $pages as $page => $html) {
         $section = $phpWord->addSection($pageStyle + array('breakType' => 'nextPage'));
         \PhpOffice\PhpWord\Shared\Html::addHtml($section, $html);
     }
     self::printDoc($phpWord, $ext, $fileName);
 }
<?php

include_once 'Sample_Header.php';
// New Word Document
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
// New portrait section
$section = $phpWord->addSection(array('borderColor' => '00FF00', 'borderSize' => 12));
$section->addText('I am placed on a default section.');
// New landscape section
$section = $phpWord->addSection(array('orientation' => 'landscape'));
$section->addText('I am placed on a landscape section. Every page starting from this section will be landscape style.');
$section->addPageBreak();
$section->addPageBreak();
// New portrait section
$section = $phpWord->addSection(array('paperSize' => 'Folio', 'marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600));
$section->addText('This section uses other margins with folio papersize.');
// New portrait section with Header & Footer
$section = $phpWord->addSection(array('marginLeft' => 200, 'marginRight' => 200, 'marginTop' => 200, 'marginBottom' => 200, 'headerHeight' => 50, 'footerHeight' => 50));
$section->addText('This section and we play with header/footer height.');
$section->addHeader()->addText('Header');
$section->addFooter()->addText('Footer');
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
    include_once 'Sample_Footer.php';
}
<?php

include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s'), " Create new PhpWord object", EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$phpWord->setDefaultParagraphStyle(array('align' => 'both', 'spaceAfter' => \PhpOffice\PhpWord\Shared\Font::pointSizeToTwips(12), 'spacing' => 120));
// Sample
$section = $phpWord->addSection();
$section->addText('Below are the samples on how to control your paragraph ' . 'pagination. See "Line and Page Break" tab on paragraph properties ' . 'window to see the attribute set by these controls.', array('bold' => true), array('space' => array('before' => 360, 'after' => 480)));
$section->addText('Paragraph with widowControl = false (default: true). ' . 'A "widow" is the last line of a paragraph printed by itself at the top ' . 'of a page. An "orphan" is the first line of a paragraph printed by ' . 'itself at the bottom of a page. Set this option to "false" if you want ' . 'to disable this automatic control.', null, array('widowControl' => false, 'indentation' => array('left' => 240, 'right' => 120)));
$section->addText('Paragraph with keepNext = true (default: false). ' . '"Keep with next" is used to prevent Word from inserting automatic page ' . 'breaks between paragraphs. Set this option to "true" if you do not want ' . 'your paragraph to be separated with the next paragraph.', null, array('keepNext' => true, 'indentation' => array('firstLine' => 240)));
$section->addText('Paragraph with keepLines = true (default: false). ' . '"Keep lines together" will prevent Word from inserting an automatic page ' . 'break within a paragraph. Set this option to "true" if you do not want ' . 'all lines of your paragraph to be in the same page.', null, array('keepLines' => true, 'indentation' => array('left' => 240, 'hanging' => 240)));
$section->addText('Keep scrolling. More below.');
$section->addText('Paragraph with pageBreakBefore = true (default: false). ' . 'Different with all other control above, "page break before" separates ' . 'your paragraph into the next page. This option is most useful for ' . 'heading styles.', null, array('pageBreakBefore' => true));
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
    include_once 'Sample_Footer.php';
}
if (!is_null($starting_date)) {
    $starting_date = strtotime($starting_date);
    $starting_date = date('Y-m-d', $starting_date);
}
if (!is_null($ending_date)) {
    $ending_date = strtotime($ending_date);
    $ending_date = date('Y-m-d', $ending_date);
}
$postal_name = $dataobject->postal_name;
$postal_address = $dataobject->postal_address;
$document_holder = $dataobject->document_holder;
$document_holder_address = $dataobject->document_holder_address;
/*****************************************************************************
CREATING THE DOCUMENT TEMPLATE
*****************************************************************************/
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
/*****************************************************************************
FONTS
*****************************************************************************/
$baseFont = 'baseText';
$phpWord->addFontStyle($baseFont, array('name' => 'Times New Roman', 'size' => 13, 'color' => '000000', 'bold' => false));
$titleFont = 'titleText';
$phpWord->addFontStyle($titleFont, array('name' => 'Times New Roman', 'size' => 15, 'color' => '000000', 'bold' => true));
/*****************************************************************************
CONTENT OF COVER
*****************************************************************************/
$section->addText(htmlspecialchars('ADATOK' . "\n" . "\n"), $titleFont);
$section->addText(htmlspecialchars('CÉG NEVE: ' . $company_name . "\n" . 'VEZETŐ NEVE: ' . $manager_name . "\n" . 'VEZETŐ CÍME: ' . $manager_address . "\n" . 'TELEFON: ' . $company_phone . "\n" . 'EMAIL: ' . $company_email . "\n" . 'DÁTUM: ' . $starting_date . ' - ' . $ending_date . "\n" . 'POSTANÉV: ' . $postal_name . "\n" . 'POSTACÍM: ' . $postal_address . "\n" . "IRATŐRZŐ NEVE: " . $document_holder . "\n" . "IRATŐRZŐ CÍME: " . $document_holder_address), $baseFont);
/*****************************************************************************
CREATING THE WORD DOCUMENT
}
if ($rowsPerPage == 3) {
    $lineWidth = 220;
    $sectionStyle = array('pageSizeW' => 12240, 'pageSizeH' => 15840, 'marginLeft' => 360, 'marginRight' => 360, 'marginTop' => 360, 'marginBottom' => 360, 'headerHeight' => 0, 'footerHeight' => 0, 'colsNum' => 3, 'colsSpace' => 690, 'breakType' => 'continuous');
}
$labelManager->setCollid($collid);
$isEditor = 0;
if ($symbUid) {
    if ($isAdmin || array_key_exists("CollAdmin", $userRights) && in_array($collid, $userRights["CollAdmin"]) || array_key_exists("CollEditor", $userRights) && in_array($collid, $userRights["CollEditor"])) {
        $isEditor = 1;
    }
}
if ($isEditor && $action) {
    $labelArr = $labelManager->getLabelArray($_POST['occid'], $speciesAuthors);
}
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$phpWord->addParagraphStyle('firstLine', array('lineHeight' => 0.1, 'spaceAfter' => 0, 'keepNext' => true, 'keepLines' => true));
$phpWord->addParagraphStyle('lastLine', array('spaceAfter' => 300, 'lineHeight' => 0.1));
$phpWord->addFontStyle('dividerFont', array('size' => 1));
$phpWord->addParagraphStyle('barcodeonly', array('align' => 'center', 'lineHeight' => 1.0, 'spaceAfter' => 300, 'keepNext' => true, 'keepLines' => true));
$phpWord->addParagraphStyle('lheader', array('align' => 'center', 'lineHeight' => 1.0, 'spaceAfter' => 150, 'keepNext' => true, 'keepLines' => true));
$phpWord->addFontStyle('lheaderFont', array('bold' => true, 'size' => 14, 'name' => 'Arial'));
$phpWord->addParagraphStyle('family', array('align' => 'right', 'lineHeight' => 1.0, 'spaceAfter' => 0, 'keepNext' => true, 'keepLines' => true));
$phpWord->addFontStyle('familyFont', array('size' => 10, 'name' => 'Arial'));
$phpWord->addParagraphStyle('scientificname', array('align' => 'left', 'lineHeight' => 1.0, 'spaceAfter' => 0, 'keepNext' => true, 'keepLines' => true));
$phpWord->addFontStyle('scientificnameFont', array('bold' => true, 'italic' => true, 'size' => 11, 'name' => 'Arial'));
$phpWord->addFontStyle('scientificnameinterFont', array('bold' => true, 'size' => 11, 'name' => 'Arial'));
$phpWord->addFontStyle('scientificnameauthFont', array('size' => 11, 'name' => 'Arial'));
$phpWord->addParagraphStyle('identified', array('align' => 'left', 'lineHeight' => 1.0, 'spaceAfter' => 0, 'indent' => 0.3125, 'keepNext' => true, 'keepLines' => true));
$phpWord->addFontStyle('identifiedFont', array('size' => 10, 'name' => 'Arial'));
$phpWord->addParagraphStyle('loc1', array('spaceBefore' => 150, 'lineHeight' => 1.0, 'spaceAfter' => 0, 'align' => 'left', 'keepNext' => true, 'keepLines' => true));
<?php

include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
// Define styles
$linkFontStyleName = 'myOwnLinStyle';
$phpWord->addLinkStyle($linkFontStyleName, array('bold' => true, 'color' => '808000'));
// New section
$section = $phpWord->addSection();
// Add hyperlink elements
$section->addLink('https://github.com/PHPOffice/PHPWord', 'PHPWord on GitHub', array('color' => '0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE));
$section->addTextBreak(2);
$section->addLink('http://www.bing.com', null, $linkFontStyleName);
$section->addLink('http://www.yahoo.com', null, $linkFontStyleName);
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
    include_once 'Sample_Footer.php';
}
<?php

include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
// Define styles
$fontStyle24 = array('size' => 24);
$paragraphStyle24 = array('spacing' => 240, 'size' => 24);
$fontStyleName = 'fontStyle';
$phpWord->addFontStyle($fontStyleName, array('size' => 9));
$paragraphStyleName = 'paragraphStyle';
$phpWord->addParagraphStyle($paragraphStyleName, array('spacing' => 480));
// New section
$section = $phpWord->addSection();
$section->addText('Text break with no style:');
$section->addTextBreak();
$section->addText('Text break with defined font style:');
$section->addTextBreak(1, $fontStyleName);
$section->addText('Text break with defined paragraph style:');
$section->addTextBreak(1, null, $paragraphStyleName);
$section->addText('Text break with inline font style:');
$section->addTextBreak(1, $fontStyle24);
$section->addText('Text break with inline paragraph style:');
$section->addTextBreak(1, null, $paragraphStyle24);
$section->addText('Done.');
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
    include_once 'Sample_Footer.php';
}
Example #12
0
<?php

defined('_JEXEC') or die('Restricted access');
require_once 'libraries/PHPWord-master/src/PhpWord/Autoloader.php';
\PhpOffice\PhpWord\Autoloader::register();
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$evrak_id = $this->evrak_id;
$standart_id = $this->standart_id;
$hazirlayan = $this->hazirlayan;
$terim = $this->terim;
$meslekTanitim = $this->meslekTanitim;
$meslekStandart = $this->meslekStandart;
$ekipman = $this->ekipman;
$bilgiBeceri = $this->bilgiBeceri;
$tutumDavranis = $this->tutumDavranis;
$gorevAlan = $this->gorevAlan;
$yonetimKurulu = $this->yonetimKurulu;
$profil = $this->profil;
$tur_id = $this->tur_id;
$cellPadding = 3;
//
$user =& JFactory::getUser();
$isSektorSorumlusu = FormFactory::sektorSorumlusuMu($user);
//
//Bilgiler
$bilgi = $this->bilgi;
$standart_bilgileri = $this->standart_bilgileri;
$data = $this->data;
$std = FormFactory::toUpperCase($data["STANDART_ADI"]);
$seviye = FormFactory::toUpperCase($data["SEVIYE_ADI"]);
$seviyeId = explode(' ', $seviye);
function ciniki_conferences_conferenceScheduleDownload($ciniki)
{
    //
    // Find all the required and optional arguments
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs');
    $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'conference_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Conference')));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $args = $rc['args'];
    //
    // Make sure this module is activated, and
    // check permission to run this function for this business
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'conferences', 'private', 'checkAccess');
    $rc = ciniki_conferences_checkAccess($ciniki, $args['business_id'], 'ciniki.conferences.conferenceScheduleDownload');
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQuery');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryArrayTree');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryIDTree');
    //
    // Load business settings
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'intlSettings');
    $rc = ciniki_businesses_intlSettings($ciniki, $args['business_id']);
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $intl_timezone = $rc['settings']['intl-default-timezone'];
    $intl_currency_fmt = numfmt_create($rc['settings']['intl-default-locale'], NumberFormatter::CURRENCY);
    $intl_currency = $rc['settings']['intl-default-currency'];
    ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'dateFormat');
    ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'timeFormat');
    $date_format = ciniki_users_dateFormat($ciniki, 'php');
    $time_format = ciniki_users_timeFormat($ciniki, 'php');
    $mysql_date_format = ciniki_users_dateFormat($ciniki, 'mysql');
    //
    // Load conference maps
    //
    ciniki_core_loadMethod($ciniki, 'ciniki', 'conferences', 'private', 'maps');
    $rc = ciniki_conferences_maps($ciniki);
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    $maps = $rc['maps'];
    $strsql = "SELECT ciniki_conferences.id, " . "ciniki_conferences.name, " . "ciniki_conferences.permalink, " . "ciniki_conferences.status, " . "ciniki_conferences.status AS status_text, " . "ciniki_conferences.flags, " . "DATE_FORMAT(ciniki_conferences.start_date, '" . ciniki_core_dbQuote($ciniki, $mysql_date_format) . "') AS start_date, " . "DATE_FORMAT(ciniki_conferences.end_date, '" . ciniki_core_dbQuote($ciniki, $mysql_date_format) . "') AS end_date, " . "ciniki_conferences.synopsis, " . "ciniki_conferences.description, " . "ciniki_conferences.imap_mailbox, " . "ciniki_conferences.imap_username, " . "ciniki_conferences.imap_password, " . "ciniki_conferences.imap_subject " . "FROM ciniki_conferences " . "WHERE ciniki_conferences.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences.id = '" . ciniki_core_dbQuote($ciniki, $args['conference_id']) . "' " . "";
    $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.conferences', 'conference');
    if ($rc['stat'] != 'ok') {
        return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3631', 'msg' => 'Conference not found', 'err' => $rc['err']));
    }
    if (!isset($rc['conference'])) {
        return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3632', 'msg' => 'Unable to find Conference'));
    }
    $conference = $rc['conference'];
    if (isset($maps['conference']['status'][$conference['status_text']])) {
        $conference['status_text'] = $maps['conference']['status'][$conference['status_text']];
    }
    $strsql = "SELECT ciniki_conferences_sessions.id, " . "CONCAT_WS('-', ciniki_conferences_sessions.id, ciniki_conferences_presentations.id) AS rowid, " . "ciniki_conferences_sessions.conference_id, " . "ciniki_conferences_sessions.room_id, " . "ciniki_conferences_rooms.name AS room, " . "ciniki_conferences_rooms.sequence, " . "ciniki_conferences_sessions.name, " . "ciniki_conferences_sessions.session_start AS start_time, " . "ciniki_conferences_sessions.session_start AS start_date, " . "ciniki_conferences_sessions.session_end AS end_time, " . "IFNULL(ciniki_conferences_presentations.id, 0) AS presentation_id, " . "IFNULL(ciniki_conferences_presentations.customer_id, 0) AS customer_id, " . "IFNULL(ciniki_conferences_presentations.presentation_number, '') AS presentation_number, " . "IFNULL(ciniki_conferences_presentations.title, '') AS presentation_title, " . "IFNULL(ciniki_conferences_presentations.description, '') AS presentation_description, " . "IFNULL(ciniki_customers.display_name, '') AS display_name, " . "IFNULL(ciniki_conferences_presentations.status, 0) AS status, " . "IFNULL(ciniki_conferences_presentations.status, '') AS status_text, " . "IFNULL(ciniki_conferences_attendees.status, 0) AS registration, " . "IFNULL(ciniki_conferences_attendees.status, 0) AS registration_text " . "FROM ciniki_conferences_sessions " . "INNER JOIN ciniki_conferences_rooms ON (" . "ciniki_conferences_sessions.room_id = ciniki_conferences_rooms.id " . "AND ciniki_conferences_rooms.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "LEFT JOIN ciniki_conferences_presentations ON (" . "ciniki_conferences_sessions.id = ciniki_conferences_presentations.session_id " . "AND ciniki_conferences_presentations.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "LEFT JOIN ciniki_conferences_attendees ON (" . "ciniki_conferences_presentations.customer_id = ciniki_conferences_attendees.customer_id " . "AND ciniki_conferences_presentations.conference_id = ciniki_conferences_attendees.conference_id " . "AND ciniki_conferences_attendees.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "LEFT JOIN ciniki_customers ON (" . "ciniki_conferences_presentations.customer_id = ciniki_customers.id " . "AND ciniki_customers.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "WHERE ciniki_conferences_sessions.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences_sessions.conference_id = '" . ciniki_core_dbQuote($ciniki, $args['conference_id']) . "' " . "ORDER BY ciniki_conferences_sessions.session_start, " . "ciniki_conferences_rooms.name, " . "ciniki_conferences_rooms.sequence, " . "ciniki_conferences_presentations.title " . "";
    ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryArrayTree');
    $rc = ciniki_core_dbHashQueryArrayTree($ciniki, $strsql, 'ciniki.conferences', array(array('container' => 'times', 'fname' => 'start_time', 'fields' => array('start_time', 'start_date', 'end_time'), 'utctotz' => array('start_time' => array('format' => $time_format, 'timezone' => $intl_timezone), 'start_date' => array('format' => $date_format, 'timezone' => $intl_timezone), 'end_time' => array('format' => $time_format, 'timezone' => $intl_timezone))), array('container' => 'rooms', 'fname' => 'room_id', 'fields' => array('id' => 'room_id', 'name' => 'room', 'session_name' => 'name', 'presentation_id')), array('container' => 'presentations', 'fname' => 'presentation_id', 'fields' => array('id', 'conference_id', 'room_id', 'room', 'sequence', 'name', 'start_time', 'start_date', 'end_time', 'presentation_id', 'customer_id', 'presentation_number', 'presentation_title', 'presentation_description', 'display_name', 'status', 'status_text', 'registration', 'registration_text'), 'utctotz' => array('start_time' => array('format' => $time_format, 'timezone' => $intl_timezone), 'start_date' => array('format' => $date_format, 'timezone' => $intl_timezone), 'end_time' => array('format' => $time_format, 'timezone' => $intl_timezone)), 'maps' => array('status_text' => $maps['presentation']['status'], 'registration_text' => $maps['attendee']['status']))));
    if ($rc['stat'] != 'ok') {
        return $rc;
    }
    if (isset($rc['times'])) {
        $timeslots = $rc['times'];
    } else {
        $timeslots = array();
    }
    //
    // Generate the word file
    //
    require_once $ciniki['config']['core']['lib_dir'] . '/PHPWord/src/PhpWord/Autoloader.php';
    \PhpOffice\PhpWord\Autoloader::register();
    require $ciniki['config']['core']['lib_dir'] . '/PHPWord/src/PhpWord/PhpWord.php';
    $PHPWord = new \PhpOffice\PhpWord\PhpWord();
    $PHPWord->addTitleStyle(1, array('bold' => true, 'size' => 18), array('spaceBefore' => 240, 'spaceAfter' => 120));
    $PHPWord->addTitleStyle(2, array('bold' => true, 'size' => 16), array('spaceBefore' => 120, 'spaceAfter' => 120));
    $PHPWord->addTitleStyle(3, array('bold' => false, 'size' => 14), array('spaceBefore' => 120, 'spaceAfter' => 120));
    $style_table = array('cellMargin' => 80, 'borderColor' => 'aaaaaa', 'borderSize' => 6);
    $style_header = array('borderSize' => 6, 'borderColor' => 'aaaaaa', 'bgColor' => 'dddddd', 'valign' => 'center');
    $style_cell = array('borderSize' => 6, 'borderColor' => 'aaaaaa', 'valign' => 'center', 'bgcolor' => 'ffffff');
    $style_header_font = array('bold' => true, 'spaceAfter' => 20);
    $style_cell_font = array();
    $style_header_pleft = array('align' => 'left');
    $style_header_pright = array('align' => 'right');
    $style_cell_pleft = array('align' => 'left');
    $style_cell_pright = array('align' => 'right');
    $section = $PHPWord->addSection();
    $header = $section->addHeader();
    $table = $header->addTable();
    $table->addRow();
    $cell = $table->addCell(9600);
    $cell->addText($conference['name'], array('size' => '16'), array('align' => 'center'));
    //print "<pre>" . print_r($timeslots, true) . "</pre>";
    //exit;
    //
    // Create a table with a row for each time slot
    //
    $cur_date = '';
    $table = $section->addTable($style_table);
    $session_number = 1;
    foreach ($timeslots as $timeslot) {
        //
        // Add the date as a header
        //
        if ($timeslot['start_date'] != $cur_date) {
            $table->addRow();
            $cell = $table->addCell(1500, $style_cell);
            $cell->addText($timeslot['start_date']);
            $cell->setGridSpan(2);
            $cur_date = $timeslot['start_date'];
            //            $session_number = 1;
        }
        //
        // Add the time slot
        //
        $table->addRow();
        $cell = $table->addCell(1500, $style_cell);
        $cell->addText($timeslot['start_time'] . ' - ' . $timeslot['end_time'], $style_cell_font);
        $nonsession_info = array();
        $session_info = array();
        if (isset($timeslot['rooms']) && count($timeslot['rooms']) > 0) {
            foreach ($timeslot['rooms'] as $room) {
                if (!isset($room['presentations']) || $room['presentation_id'] == 0) {
                    if (isset($room['presentations'][0])) {
                        $session = $room['presentations'][0];
                        if ($session['name'] != '') {
                            $nonsession_info[] = $session['name'];
                        }
                    }
                    $nonsession_info[] = "Location: " . $room['name'];
                } else {
                    $session_info[] = $session_number . ". " . $room['session_name'] . ": ";
                    $presentation_number = 1;
                    $presentation_info = '';
                    foreach ($room['presentations'] as $presentation) {
                        if ($presentation_number > 1) {
                            $presentation_info .= "; ";
                        }
                        $presentation_info .= $presentation_number . ") " . $presentation['display_name'];
                        $presentation_number++;
                    }
                    $session_info[] = $presentation_info;
                    $session_info[] = "Location: " . $room['name'];
                    $session_info[] = "";
                    $session_number++;
                }
            }
        }
        $cell = $table->addCell(2500, $style_cell);
        foreach ($nonsession_info as $line) {
            $cell->addText($line, $style_cell_font);
        }
        $cell = $table->addCell(5500, $style_cell);
        foreach ($session_info as $line) {
            $cell->addText($line, $style_cell_font);
        }
    }
    $section = $PHPWord->addSection();
    $header = $section->addHeader();
    $table = $header->addTable();
    $table->addRow();
    $cell = $table->addCell(9600);
    $cell->addText($conference['name'], array('size' => '16'), array('align' => 'center'));
    $session_number = 1;
    foreach ($timeslots as $timeslot) {
        if (isset($timeslot['rooms']) && count($timeslot['rooms']) > 0) {
            foreach ($timeslot['rooms'] as $room) {
                if (!isset($room['presentations']) || $room['presentation_id'] == 0) {
                    continue;
                }
                $section->addTitle($session_number . ". " . $room['session_name'], 1);
                if (isset($room['presentations']) && $room['presentation_id'] != 0) {
                    foreach ($room['presentations'] as $pid => $presentation) {
                        $section->addTitle($presentation['display_name'], 2);
                        $section->addTitle(htmlspecialchars($presentation['presentation_title']), 3);
                        $lines = explode("\n", $presentation['presentation_description']);
                        foreach ($lines as $line) {
                            $section->addText(htmlspecialchars($line), array());
                        }
                        $section->addText('');
                    }
                }
                $session_number++;
            }
        }
    }
    //
    // Output the word file
    //
    header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
    header('Content-Disposition: attachment;filename="' . preg_replace("/[^A-Za-z0-9]/", '', $conference['name']) . '.docx"');
    header('Cache-Control: max-age=0');
    $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, 'Word2007');
    $objWriter->save('php://output');
    return array('stat' => 'exit');
}
     on arrive à le paramétrer correctement.
      ----------------------------------------------
 */
 $result = fetchAllInfoPlanCadre($_SESSION['id_plancadre']);
 $info_plancadre = $result[0];
 $etat = $info_plancadre["Etat"];
 $nom_cours = "Titre du cours : " . $info_plancadre["NomCours"];
 $code_cours = "Numéro du cours : " . $info_plancadre["CodeCours"];
 $nom_programme = $info_plancadre["NomProgramme"];
 $code_programme = $info_plancadre["CodeProgramme"];
 $programme_cours = $nom_programme . "(" . $code_programme . ")";
 $ponderation_cours = "Pondération : " . $info_plancadre["Ponderation"];
 $nombre_unites_cours = "Nombre d'unité(s) : " . $info_plancadre["NombreUnites"];
 $prealable_cours = "Préalable(s) : " . "Aucun";
 $type_enseignement = $info_plancadre['TypeCours'];
 $php_word = new \PhpOffice\PhpWord\PhpWord();
 // ----------------------------------------------
 // ajout des styles au document
 $php_word->addParagraphStyle("style_align_right", $GLOBALS["style_align_right"]);
 $php_word->addParagraphStyle("style_align_center", $GLOBALS["style_align_center"]);
 $php_word->addTableStyle('style_table', $GLOBALS["style_table"]);
 // ----------------------------------------------
 // ----------------------------------------------
 // Section de l'indentification du cours
 $section_template = $php_word->addSection();
 //
 $nom_etablissement = "Collège Lionel-Groulx";
 $section_template->addText($nom_etablissement);
 $section_template->addText($type_enseignement, null, "style_align_right");
 $section_template->addText($programme_cours, null, "style_align_right");
 switch ($info_plancadre["Etat"]) {
Example #15
0
<?php

include_once 'Sample_Header.php';
// New Word Document
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
// Ads styles
$phpWord->addParagraphStyle('multipleTab', array('tabs' => array(new \PhpOffice\PhpWord\Style\Tab('left', 1550), new \PhpOffice\PhpWord\Style\Tab('center', 3200), new \PhpOffice\PhpWord\Style\Tab('right', 5300))));
$phpWord->addParagraphStyle('rightTab', array('tabs' => array(new \PhpOffice\PhpWord\Style\Tab('right', 9090))));
$phpWord->addParagraphStyle('centerTab', array('tabs' => array(new \PhpOffice\PhpWord\Style\Tab('center', 4680))));
// New portrait section
$section = $phpWord->addSection();
// Add listitem elements
$section->addText("Multiple Tabs:\tOne\tTwo\tThree", null, 'multipleTab');
$section->addText("Left Aligned\tRight Aligned", null, 'rightTab');
$section->addText("\tCenter Aligned", null, 'centerTab');
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
    include_once 'Sample_Footer.php';
}
<?php

include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
// New section
$section = $phpWord->addSection();
// Define styles
$fontStyle12 = array('spaceAfter' => 60, 'size' => 12);
$fontStyle10 = array('size' => 10);
$phpWord->addTitleStyle(1, array('size' => 20, 'color' => '333333', 'bold' => true));
$phpWord->addTitleStyle(2, array('size' => 16, 'color' => '666666'));
$phpWord->addTitleStyle(3, array('size' => 14, 'italic' => true));
$phpWord->addTitleStyle(4, array('size' => 12));
// Add text elements
$section->addText('Table of contents 1');
$section->addTextBreak(2);
// Add TOC #1
$toc = $section->addTOC($fontStyle12);
$section->addTextBreak(2);
// Filler
$section->addText('Text between TOC');
$section->addTextBreak(2);
// Add TOC #1
$section->addText('Table of contents 2');
$section->addTextBreak(2);
$toc2 = $section->addTOC($fontStyle10);
$toc2->setMinDepth(2);
$toc2->setMaxDepth(3);
// Add Titles
Example #17
0
    $loanManager->setCollId($collId);
}
$identifier = 0;
if ($loanId) {
    $identifier = $loanId;
} elseif ($exchangeId) {
    $identifier = $exchangeId;
}
if ($institution) {
    $invoiceArr = $loanManager->getToAddress($institution);
} else {
    $invoiceArr = $loanManager->getInvoiceInfo($identifier, $loanType);
}
$addressArr = $loanManager->getFromAddress($collId);
if ($export) {
    $phpWord = new \PhpOffice\PhpWord\PhpWord();
    $phpWord->addParagraphStyle('acctnum', array('align' => 'left', 'indent' => 5.5, 'lineHeight' => 1.0, 'spaceAfter' => 0, 'keepNext' => true, 'keepLines' => true));
    $phpWord->addFontStyle('acctnumFont', array('size' => 8, 'name' => 'Arial'));
    $phpWord->addParagraphStyle('toAddress', array('align' => 'left', 'indent' => 6, 'lineHeight' => 1.0, 'spaceAfter' => 0, 'keepNext' => true, 'keepLines' => true));
    $phpWord->addFontStyle('toAddressFont', array('size' => 12, 'name' => 'Arial'));
    $section = $phpWord->addSection(array('pageSizeW' => 13662.992125984, 'pageSizeH' => 5952.755905512, 'marginLeft' => 360, 'marginRight' => 360, 'marginTop' => 360, 'marginBottom' => 360, 'headerHeight' => 0, 'footerHeight' => 0));
    $section->addTextBreak(5);
    if ($accountNum) {
        $section->addText(htmlspecialchars('Acct. #' . $accountNum), 'acctnumFont', 'acctnum');
    }
    $section->addTextBreak(1);
    $textrun = $section->addTextRun('toAddress');
    $textrun->addText(htmlspecialchars($invoiceArr['contact']), 'toAddressFont');
    $textrun->addTextBreak(1);
    $textrun->addText(htmlspecialchars($invoiceArr['institutionname'] . ' (' . $invoiceArr['institutioncode'] . ')'), 'toAddressFont');
    $textrun->addTextBreak(1);
Example #18
0
<?php

include_once 'Sample_Header.php';
// New Word Document
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
$header = array('size' => 16, 'bold' => true);
// 1. Basic table
$rows = 10;
$cols = 5;
$section->addText(htmlspecialchars('Basic table'), $header);
$table = $section->addTable();
for ($r = 1; $r <= 8; $r++) {
    $table->addRow();
    for ($c = 1; $c <= 5; $c++) {
        $table->addCell(1750)->addText(htmlspecialchars("Row {$r}, Cell {$c}"));
    }
}
// 2. Advanced table
$section->addTextBreak(1);
$section->addText(htmlspecialchars('Fancy table'), $header);
$styleTable = array('borderSize' => 6, 'borderColor' => '006699', 'cellMargin' => 80);
$styleFirstRow = array('borderBottomSize' => 18, 'borderBottomColor' => '0000FF', 'bgColor' => '66BBFF');
$styleCell = array('valign' => 'center');
$styleCellBTLR = array('valign' => 'center', 'textDirection' => \PhpOffice\PhpWord\Style\Cell::TEXT_DIR_BTLR);
$fontStyle = array('bold' => true, 'align' => 'center');
$phpWord->addTableStyle('Fancy Table', $styleTable, $styleFirstRow);
$table = $section->addTable('Fancy Table');
$table->addRow(900);
$table->addCell(2000, $styleCell)->addText(htmlspecialchars('Row 1'), $fontStyle);
Example #19
0
function make_word_doc($doc, $dir)
{
    /**
    * uses the $doc object to create a new word doc whose name is sent back to hte client where an <iframe> downloads it
    *
    * @since 1.0
    *
    * @caller user action
    * @ingroup editor
    *
    * @param object $doc created in js - a big object w all the info needed
    * @param string $dir the directory name to add the .doc
    * @return echos the word doc's name
    */
    // make the a new instance of a phpword
    // you will add all the info to this
    $phpWord = new \PhpOffice\PhpWord\PhpWord();
    $i = 0;
    $l = count($doc) - 1;
    // loop through each page in the doc
    // each page is a 'section'
    for ($i; $i < $l; $i = $i + 1) {
        $Paragraphs = $doc['Page' . $i];
        $ii = 0;
        $ll = count($Paragraphs) - 1;
        ${"page_" . $i} = $phpWord->addSection();
        $Page = ${"page_" . $i};
        // in each page loop through each paragraph
        // style the the paragraph's alignment
        for ($ii; $ii < $ll; $ii = $ii + 1) {
            $Spans = $Paragraphs['Paragraph' . $ii];
            $iii = 0;
            $lll = count($Spans) - 1;
            ${"paragraph_" . $i . '_' . $ii} = $Page->addTextRun(array('align' => $Spans['align']));
            $Paragraph = ${"paragraph_" . $i . '_' . $ii};
            // loop through each text span
            for ($iii; $iii < $lll; $iii = $iii + 1) {
                $Span = $Spans['Span' . $iii];
                // create the style info for the text span
                $Style = array('name' => $Span['Styles']['name'], 'size' => intval($Span['Styles']['size']), 'bold' => filter_var($Span['Styles']['bold'], FILTER_VALIDATE_BOOLEAN), 'italic' => filter_var($Span['Styles']['italic'], FILTER_VALIDATE_BOOLEAN), 'color' => $Span['Styles']['color'], 'fgColor' => $Span['Styles']['fgColor']);
                // add the text span with it's style to the paragraph
                $Paragraph->addText($Span['text'], $Style);
            }
        }
    }
    // assign it as a word doc
    $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
    // create an empty word doc file w. the new file name
    $pathAndFile = $dir . '/' . $doc['title'] . '.docx';
    // save the file with content included
    $objWriter->save($pathAndFile);
    // return the .doc's title so it can be downloaded
    echo $doc['title'] . '.docx';
    die;
}
Example #20
0
 * This source code is free and modifiable under the terms of 
 * GNU General Public License. (http://www.gnu.org/copyleft/gpl.html). See
 * the "license.txt" file for details, or visit the CollectiveAccess web site at
 * http://www.CollectiveAccess.org
 *
 * ----------------------------------------------------------------------
 */
$t_display = $this->getVar('t_display');
$va_display_list = $this->getVar('display_list');
$vo_result = $this->getVar('result');
$vn_items_per_page = $this->getVar('current_items_per_page');
$vs_current_sort = $this->getVar('current_sort');
// For easier calculation
// 1 cm = 1440/2.54 = 566.93 twips
$cmToTwips = 567;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
// Every element you want to append to the word document is placed in a section.
// New portrait section
$sectionStyle = array('orientation' => 'portrait', 'marginTop' => 2 * $cmToTwips, 'marginBottom' => 2 * $cmToTwips, 'marginLeft' => 2 * $cmToTwips, 'marginRight' => 2 * $cmToTwips, 'headerHeight' => 1 * $cmToTwips, 'footerHeight' => 1 * $cmToTwips, 'colsNum' => 1);
$section = $phpWord->addSection($sectionStyle);
// Add header for all pages
$header = $section->addHeader();
//$header->addText("Header");
$headerimage = $this->request->getThemeDirectoryPath() . "/graphics/logos/" . $this->request->config->get('report_img');
if (file_exists($headerimage)) {
    $header->addImage($headerimage, array('height' => 30, 'wrappingStyle' => 'inline'));
}
// Add footer
$footer = $section->addFooter();
$footer->addPreserveText('{PAGE}/{NUMPAGES}', null, array('align' => 'right'));
// Defining font style for headers
    $sectionStyle = array('pageSizeW' => 12240, 'pageSizeH' => 15840, 'marginLeft' => 360, 'marginRight' => 360, 'marginTop' => 360, 'marginBottom' => 360, 'headerHeight' => 0, 'footerHeight' => 0, 'colsNum' => 3, 'colsSpace' => 180, 'breakType' => 'continuous');
}
$labelManager->setCollid($collid);
$isEditor = 0;
if ($symbUid) {
    if ($isAdmin || array_key_exists("CollAdmin", $userRights) && in_array($collid, $userRights["CollAdmin"]) || array_key_exists("CollEditor", $userRights) && in_array($collid, $userRights["CollEditor"])) {
        $isEditor = 1;
    }
}
if ($isEditor && $action) {
    $labelArr = $labelManager->getAnnoArray($_POST['detid'], $speciesAuthors);
    if ($clearQueue) {
        $labelManager->clearAnnoQueue($_POST['detid']);
    }
}
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$phpWord->addParagraphStyle('firstLine', array('lineHeight' => 0.1, 'spaceAfter' => 0, 'keepNext' => true, 'keepLines' => true));
$phpWord->addParagraphStyle('lastLine', array('spaceAfter' => 50, 'lineHeight' => 0.1));
$phpWord->addFontStyle('dividerFont', array('size' => 1));
$phpWord->addParagraphStyle('header', array('align' => 'center', 'lineHeight' => 1.0, 'spaceAfter' => 40, 'keepNext' => true, 'keepLines' => true));
$phpWord->addParagraphStyle('footer', array('align' => 'center', 'lineHeight' => 1.0, 'spaceBefore' => 40, 'spaceAfter' => 0, 'keepNext' => true, 'keepLines' => true));
$phpWord->addFontStyle('headerfooterFont', array('bold' => true, 'size' => 9, 'name' => 'Arial'));
$phpWord->addParagraphStyle('other', array('align' => 'left', 'lineHeight' => 1.0, 'spaceBefore' => 30, 'spaceAfter' => 0, 'keepNext' => true, 'keepLines' => true));
$phpWord->addParagraphStyle('scientificname', array('align' => 'left', 'lineHeight' => 1.0, 'spaceAfter' => 0, 'keepNext' => true, 'keepLines' => true));
$phpWord->addFontStyle('scientificnameFont', array('bold' => true, 'italic' => true, 'size' => 10, 'name' => 'Arial'));
$phpWord->addFontStyle('scientificnameinterFont', array('bold' => true, 'size' => 10, 'name' => 'Arial'));
$phpWord->addFontStyle('scientificnameauthFont', array('size' => 10, 'name' => 'Arial'));
$phpWord->addFontStyle('identifiedFont', array('size' => 8, 'name' => 'Arial'));
$tableStyle = array('width' => 100, 'borderColor' => '000000', 'borderSize' => 2, 'cellMargin' => 75);
$colRowStyle = array('cantSplit' => true);
$phpWord->addTableStyle('defaultTable', $tableStyle, $colRowStyle);
Example #22
0
<?php

include_once 'Sample_Header.php';
// New Word Document
echo date('H:i:s'), " Create new PhpWord object", EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$filler = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' . 'Nulla fermentum, tortor id adipiscing adipiscing, tortor turpis commodo. ' . 'Donec vulputate iaculis metus, vel luctus dolor hendrerit ac. ' . 'Suspendisse congue congue leo sed pellentesque.';
// Normal
$section = $phpWord->addSection();
$section->addText('Normal paragraph. ' . $filler);
// Two columns
$section = $phpWord->addSection(array('colsNum' => 2, 'colsSpace' => 1440, 'breakType' => 'continuous'));
$section->addText('Two columns, one inch (1440 twips) spacing. ' . $filler);
// Normal
$section = $phpWord->addSection(array('breakType' => 'continuous'));
$section->addText('Normal paragraph again. ' . $filler);
// Three columns
$section = $phpWord->addSection(array('colsNum' => 3, 'colsSpace' => 720, 'breakType' => 'continuous'));
$section->addText('Three columns, half inch (720 twips) spacing. ' . $filler);
// Normal
$section = $phpWord->addSection(array('breakType' => 'continuous'));
$section->addText('Normal paragraph again.');
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
    include_once 'Sample_Footer.php';
}
        </style>
    </head>
    <body>
        <h1>Ejemplo Certificado y CAPTCHA</h1>
    <?php 
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $securimage = new Securimage();
    if ($securimage->check($_POST['captcha_code']) == false) {
        echo "El CAPTCHA ingresado es incorrecto.<br /><br />";
        echo "Por favor <a href='javascript:history.go(-1)'>vuelve</a> a intentarlo.";
        exit;
    }
    ob_end_clean();
    header("Content-Encoding: None", true);
    \PhpOffice\PhpWord\Autoloader::register();
    $phpWord = new \PhpOffice\PhpWord\PhpWord();
    $filenameModelo = "modelo2.docx";
    $template = $phpWord->loadTemplate($filenameModelo);
    $template->setValue('proveedor', $_POST['prestador']);
    $template->setValue('chofer', $_POST['chofer']);
    $template->setValue('matricula', $_POST['matricula']);
    $template->setValue('dni', $_POST['dni']);
    $template->setValue('curso', $_POST['curso']);
    $template->setValue('sede', $_POST['sede']);
    $template->setValue('fechacurso', $_POST['fecha_curso']);
    $template->setValue('numero', $_POST['transaccion']);
    $template->setValue('fechatrans', $_POST['fecha_transaccion']);
    // QR
    $url = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}" . "status_chofer.php";
    $qrFile = generarQR($url);
    $template->setImageValue("image1.png", $qrFile);
$app->hook('panel.menu:after', function () use($app) {
    if (!$app->user->is('admin') && !$app->user->is('staff')) {
        return;
    }
    $a_class = $this->template == 'panel/em-cartaz' ? 'active' : '';
    $url = $app->createUrl('panel', 'em-cartaz');
    echo "<li><a class='{$a_class}' href='{$url}'><span class='icon icon-em-cartaz'></span> Em Cartaz</a></li>";
});
$app->hook('GET(panel.em-cartaz-<<download|preview>>)', function () use($app, $defaultFrom, $defaultTo) {
    if (!$app->user->is('admin') && !$app->user->is('staff')) {
        //throw new MapasCulturais\Exceptions\PermissionDenied;
        $app->pass();
    }
    $from = isset($this->getData['from']) ? new DateTime($this->getData['from']) : $defaultFrom;
    $to = isset($this->getData['to']) ? new DateTime($this->getData['to']) : $defaultTo;
    $phpWord = new \PhpOffice\PhpWord\PhpWord();
    // Every element you want to append to the word document is placed in a section.
    // To create a basic section:
    $section = $phpWord->addSection();
    $defaultFont = $phpWord->addFontStyle('defaultFont', array('name' => 'Arial', 'size' => 12));
    $documentHead = $phpWord->addFontStyle('documentHead', array('name' => 'Arial', 'size' => 18, 'color' => '44AA88', 'bold' => true));
    $eventTitleFont = $phpWord->addFontStyle('eventTitle', array('name' => 'Arial', 'size' => 12, 'color' => '880000', 'bold' => true));
    $linguagemStyle = $phpWord->addFontStyle('linguagemStyle', array('name' => 'Arial', 'size' => 12, 'color' => 'FF0000', 'bold' => true));
    $linguagens = array('Cinema', 'Dança', 'Teatro', 'Música Popular', 'Música Erudita', 'Exposição', 'Curso ou Oficina', 'Palestra, Debate ou Encontro');
    $section->addText('ROTEIRO GERAL (SITE) REVISTA', $documentHead);
    $getEventTextBlock = function ($event) use($app) {
        //        return "TEXT {$event->name}";
        $eventText = trim($event->shortDescription);
        if (!empty($event->classificacaoEtaria)) {
            $eventText .= $event->classificacaoEtaria;
        }
Example #25
0
<?php

include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s'), " Create new PhpWord object", EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$document = $phpWord->loadTemplate('resources/Sample_23_TemplateBlock.docx');
/*
$section->addText('Hello world!');
$section->addText('Hello world!');
$section->addText('Hello world!');
$section->addText('Hello world!');*/
// Will clone everything between ${tag} and ${/tag}, the number of times. By default, 1.
$document->cloneBlock('CLONEME', 3);
// Everything between ${tag} and ${/tag}, will be deleted/erased.
$document->deleteBlock('DELETEME');
$name = 'Sample_23_TemplateBlock.docx';
echo date('H:i:s'), " Write to Word2007 format", EOL;
$document->saveAs($name);
rename($name, "results/{$name}");
echo getEndingNotes(array('Word2007' => 'docx'));
if (!CLI) {
    include_once 'Sample_Footer.php';
}
Example #26
0
<?php

include "../core/autoload.php";
include "../core/app/model/ReservationData.php";
include "../core/app/model/PacientData.php";
include "../core/app/model/MedicData.php";
include "../core/app/model/StatusData.php";
include "../core/app/model/PaymentData.php";
session_start();
require_once '../PhpWord/Autoloader.php';
use PhpOffice\PhpWord\Autoloader;
use PhpOffice\PhpWord\Settings;
Autoloader::register();
$word = new PhpOffice\PhpWord\PhpWord();
$alumns = $_SESSION["report_data"];
$section1 = $word->AddSection();
$section1->addText("REPORTE DE CITAS", array("size" => 22, "bold" => true, "align" => "right"));
$styleTable = array('borderSize' => 6, 'borderColor' => '888888', 'cellMargin' => 40);
$styleFirstRow = array('borderBottomColor' => '0000FF', 'bgColor' => 'AAAAAA');
$table1 = $section1->addTable("table1");
$table1->addRow();
$table1->addCell()->addText("Asunto");
$table1->addCell()->addText("Paciente");
$table1->addCell()->addText("Medico");
$table1->addCell()->addText("Fecha");
$table1->addCell()->addText("Estado");
$table1->addCell()->addText("Pago");
$table1->addCell()->addText("Costo");
$total = 0;
foreach ($alumns as $al) {
    $medic = $al->getMedic();
<?php

include_once 'Sample_Header.php';
// New Word Document
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
$header = array('size' => 16, 'bold' => true);
//1.Use EastAisa FontStyle
$section->addText(htmlspecialchars('中文楷体样式测试'), array('name' => '楷体', 'size' => 16, 'color' => '1B2232'));
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
    include_once 'Sample_Footer.php';
}
<?php

include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s'), " Create new PhpWord object", EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$document = $phpWord->loadTemplate('resources/Sample_07_TemplateCloneRow.docx');
// Variables on different parts of document
$document->setValue('weekday', date('l'));
// On section/content
$document->setValue('time', date('H:i'));
// On footer
$document->setValue('serverName', realpath(__DIR__));
// On header
// Simple table
$document->cloneRow('rowValue', 10);
$document->setValue('rowValue#1', 'Sun');
$document->setValue('rowValue#2', 'Mercury');
$document->setValue('rowValue#3', 'Venus');
$document->setValue('rowValue#4', 'Earth');
$document->setValue('rowValue#5', 'Mars');
$document->setValue('rowValue#6', 'Jupiter');
$document->setValue('rowValue#7', 'Saturn');
$document->setValue('rowValue#8', 'Uranus');
$document->setValue('rowValue#9', 'Neptun');
$document->setValue('rowValue#10', 'Pluto');
$document->setValue('rowNumber#1', '1');
$document->setValue('rowNumber#2', '2');
$document->setValue('rowNumber#3', '3');
$document->setValue('rowNumber#4', '4');
$document->setValue('rowNumber#5', '5');
Example #29
0
}
$queryEj = " select UPPER(Frase) Frase from catejercicio where Ejercicio =  '" . $ano . "'";
$rsEje = $cnx->Execute($queryEj);
$nRowsEj = $rsEje->_numOfRows;
$dataEje = array();
if ($nRowsEj > 0) {
    while (!$rsEje->EOF) {
        array_push($dataEje, array_map('utf8_encode', $rsEje->fields));
        $rsEje->movenext();
    }
    $dataEje = end($dataEje);
}
include_once 'Sample_Header.php';
// New Word document
//echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$phpWord->setDefaultParagraphStyle(array('align' => 'both', 'spaceAfter' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(12), 'spacing' => 15, 'name' => 'Tahoma'));
// Sample
$section = $phpWord->addSection(array('breakType' => 'continuous'));
$section->addText(htmlspecialchars($dataEje['Frase']), array('bold' => false), array('space' => array('before' => 600, 'after' => 250), 'align' => 'center'));
$section->addText(htmlspecialchars('203200-' . $dataOfi['PfjOfi'] . '-' . substr($dataOfi['CveOfi'], 2, 4) . '/' . substr($ano, 2, 2)), array('bold' => false), array('space' => array('before' => 80, 'after' => 80), 'align' => 'right'));
$section->addText(htmlspecialchars('Toluca de Lerdo, México;'), array('bold' => false), array('space' => array('before' => 80, 'after' => 80), 'align' => 'right'));
$section->addText(htmlspecialchars($fechaOficio), array('bold' => false), array('space' => array('before' => 80, 'after' => 80), 'align' => 'right'));
$table = $section->addTable('Table');
$table->addRow(300);
$table->addCell(6000, array('valign' => 'center'))->addText(htmlspecialchars('Asunto:'), array('bold' => true), array('align' => 'right'));
$table->addCell(4000, array('valign' => 'center'))->addText(htmlspecialchars(nl2br($dataOfi['AsuOfi'])), array('bold' => false), array('align' => 'right'));
//Acentos
$tit = nl2br($dataOfi['TitOfi']);
$titular = explode("<br />", $tit);
foreach ($titular as $tit) {
Example #30
-1
 function write($fileName)
 {
     $phpWord = new \PhpOffice\PhpWord\PhpWord();
     //echo dirname(__FILE__).'/'.$this->plantilla;exit;
     $document = $phpWord->loadTemplate(dirname(__FILE__) . '/' . $this->plantilla);
     setlocale(LC_ALL, "es_ES@euro", "es_ES", "esp");
     //var_dump($this->dataSource);
     foreach ($this->dataSource->getParameters() as $col => $val) {
         //echo 'kkk:'. $col .' '.$val;
         $document->setValue($col, $val);
         // On section/content
     }
     //echo 'iiiiiooooooo: '.$fileName;exit;
     $document->saveAs($fileName);
 }