static function html2pdf($html, $encode = "SJIS") { //echo 1;exit; //$html=self::pdf_change_encode($html,$encode); define('FPDF_FONTPATH', ROOT . 'lib/html2fpdf/font/'); include ROOT . 'lib/html2fpdf/jphtml2fpdf.php'; $pdf = new HTML2FPDF("l", "mm", "A4"); $pdf->Open(); $pdf->SetCompression(false); $pdf->SetDisplayMode("real"); $pdf->UseCSS(); $pdf->UsePRE(); $pdf->AddSJISFont(); $pdf->setBasePath(""); $pdf->AddPage(); //ファイル情報 $pdf->SetAuthor("HPX"); $pdf->Bookmark("HPX"); $pdf->SetTitle("HPX"); $pdf->SetCreator("HPX"); // 本文 $pdf->SetMargins(10, 10); $pdf->DisplayPreferences('HideWindowUI'); //$pdf->SetFont( HideWindowUI,"",8); $pdf->WriteHTML($html); // 出力 $pdf->Output('doc.pdf', 'D'); exit; }
function PDF_html_2_pdf($data) { global $auth; $pdf = new HTML2FPDF(); $pdf->UseCSS(); $pdf->UseTableHeader(); $pdf->AddPage(); $pdf->WriteHTML(AdjustHTML($data)); $pdf->Output(); }
<tr class="fil"> <td><span>5.2 PRESUPUESTO DEL PROYECTO : <?php echo strtoupper(utf8_encode($value[39])); ?> </span> </td> </tr> <tr class="fil"> <td><span>5.3 FINANCIAMIENTO : <?php echo strtoupper(utf8_encode($value[41])); ?> </strong></span> </td> </tr> <?php } ?> </tbody></table> </div> <?php $content = ob_get_clean(); $pdf = new HTML2FPDF('P', 'mm', 'A4', 'UTF-8'); $pdf->UseCSS($opt == true); $pdf->AddPage(); $pdf->WriteHTML($content); $pdf->ReadCSS($content); $pdf->Output('proyecto.pdf'); ?>
$xtpl->assign("dividerSpan", 4); //Assign DetailView Fileds $xtpl->assign('name', $focus->name); $xtpl->assign('account_name', $focus->account_name); $xtpl->assign('account_id', $focus->account_id); $xtpl->assign('contact_name', $focus->contact_name); $xtpl->assign('contact_id', $focus->contact_id); $xtpl->assign('assigned_user_name', $focus->assigned_user_name); $xtpl->assign('description', nl2br(url2html($focus->description))); $xtpl->assign('vision', $focus->vision); $xtpl->assign('period', $app_list_strings['clientorders_period_options'][$focus->period]); $xtpl->assign('pnum', $focus->number); $xtpl->assign('category', $app_list_strings['clientorders_category_options'][$focus->category]); $xtpl->assign('note', $focus->note); $xtpl->assign('quantity', $focus->quantity); $xtpl->assign('status', $app_list_strings['clientorder_component_status'][$focus->status]); $xtpl->assign('samples', $focus->samples); $xtpl->assign('file', $focus->file); $xtpl->assign('deadline', $focus->deadline); $xtpl->assign('date_entered', $focus->date_entered); $xtpl->assign('date_modified', $focus->date_modified); $pdf->DisplayPreferences('HideWindowUI'); $pdf->AddPage(); $xtpl->parse("main"); $html = $xtpl->pdf_out('main'); $html_encoded = iconv('utf-8', 'CP1251', $html); $pdf->UseCSS(true); $pdf->DisableTags(); $pdf->WriteHTML($html_encoded); //echo $html_encoded; $pdf->Output("{$focus->number}.pdf", 'D');
<a href=>est</a> <table border=1><tr><td>1</td></tr><tr><td>1</td></tr><tr><td>1</td></tr><tr><td>1</td></tr> </table> </BODY> </HTML> <?php $html = ob_get_contents(); ob_end_clean(); // PDFの書式設定 $pdf = new HTML2FPDF("l", "mm", "A4"); $pdf->Open(); $pdf->SetCompression(false); $pdf->SetDisplayMode("real"); $pdf->UseCSS(); $pdf->UsePRE(); $pdf->setBasePath("http://google.com"); $pdf->AddPage(); //ファイル情報 $pdf->SetAuthor("Kazuhiko HiroseKazuhiko HiroseKazuhiko HiroseKazuhiko HiroseKazuhiko HiroseKazuhiko HiroseKazuhiko HiroseKazuhiko Hirose"); $pdf->Bookmark("BookmarkBookmarkBookmarkBookmarkBookmarkBookmarkBookmarkBookmarkBookmarkBookmarkBookmark"); $pdf->SetTitle("SetTitleSetTitleSetTitleSetTitleSetTitleSetTitleSetTitleSetTitleSetTitleSetTitleSetTitleSetTitle"); $pdf->SetCreator("SetCreatorSetCreatorSetCreatorSetCreatorSetCreatorSetCreatorSetCreatorSetCreatorSetCreatorSetCreator"); // 本文 $pdf->SetMargins(10, 10); $pdf->DisplayPreferences('HideWindowUI'); //$pdf->SetFont( HideWindowUI,"",8); $pdf->WriteHTML($html); // 出力 $pdf->Output('doc.pdf', 'D');
function HandlePDF($pagename) { global $WikiTitle; // modify WikiTitle $WikiTitle = str_replace(' ', '_', $WikiTitle); $WikiTitle = html_entity_decode($WikiTitle); // read wiki page ! //$page = ReadPage($pagename); $page = RetrieveAuthPage($pagename, 'read', true, READPAGE_CURRENT); //$date['modif'] = filemtime($_SERVER['DOCUMENT_ROOT'].'/wiki.d/'.$pagename); // define variable $xyz['author'] = 'by ' . $page['author']; // pdf author $xyz['name']['page'] = str_replace('.', '_', $pagename); // page name $xyz['name']['pdf'] = $WikiTitle . '_' . $xyz['name']['page'] . '.pdf'; // pdf name $xyz['text'] = mv_breakpage($page['text']); // to transform breakpage markup $xyz['title'] = $WikiTitle . ' : page ' . $xyz['name']['page']; // pdf title $xyz['path'] = $_SERVER["DOCUMENT_ROOT"]; // return root path of your site web $xyz['url'] = 'http://' . HOST . URI; // pdf URL // transform text to html ! $html = change_code(MarkupToHTML($pagename, $xyz['text'])); /*** for test ! *** echo $xyz['text']; echo "\n HTML : ".$html; /** */ //out pass memory server ini_set('memory_limit', '24M'); ini_set('max_execution_time', 0); // declare a new object pdf $pdf = new HTML2FPDF(); // Disactive elements HTML ... cause bad support ! $pdf->DisableTags('<span>'); $pdf->DisableTags('<dl>'); $pdf->DisableTags('<dt>'); $pdf->DisableTags('<dd>'); // generals informations $pdf->SetCompression(1); $pdf->SetAuthor($xyz['author']); $pdf->SetTitle($xyz['title']); // method implemented by me to return in footer pdf generated. $pdf->PutHREF($xyz['url']); // method implemented by html2pdf author ! $pdf->setBasePath($xyz['path']); // to implement path of your site ; need it for include correctly the image on pdf ! $pdf->UseCSS(false); // to recognize CSS ... run correctly ? $pdf->UsePRE(false); // to recognize element PRE in your code HTML ... but, really bad support ! // build the page PDF $pdf->AddPage(); $pdf->WriteHTML($html); $pdf->Output($xyz['name']['pdf'], I); /**/ // retabli valeur serveur ini_set('memory_limit', MEM); ini_set('max_execution_time', MAX_TIME); }