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; }
<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');