ITÊýÂë ¹ºÎï ÍøÖ· Í·Ìõ Èí¼þ ÈÕÀú ÔĶÁ ͼÊé¹Ý
TxTС˵ÔĶÁÆ÷
¡ýÓïÒôÔĶÁ,С˵ÏÂÔØ,¹ÅµäÎÄѧ¡ý
ͼƬÅúÁ¿ÏÂÔØÆ÷
¡ýÅúÁ¿ÏÂÔØͼƬ,ÃÀŮͼ¿â¡ý
ͼƬ×Ô¶¯²¥·ÅÆ÷
¡ýͼƬ×Ô¶¯²¥·ÅÆ÷¡ý
Ò»¼üÇå³ýÀ¬»ø
¡ýÇáÇáÒ»µã,Çå³ýϵͳÀ¬»ø¡ý
¿ª·¢: C++֪ʶ¿â Java֪ʶ¿â JavaScript Python PHP֪ʶ¿â È˹¤ÖÇÄÜ Çø¿éÁ´ ´óÊý¾Ý Òƶ¯¿ª·¢ ǶÈëʽ ¿ª·¢¹¤¾ß Êý¾Ý½á¹¹ÓëËã·¨ ¿ª·¢²âÊÔ ÓÎÏ·¿ª·¢ ÍøÂçЭÒé ϵͳÔËά
½Ì³Ì: HTML½Ì³Ì CSS½Ì³Ì JavaScript½Ì³Ì GoÓïÑÔ½Ì³Ì JQuery½Ì³Ì VUE½Ì³Ì VUE3½Ì³Ì Bootstrap½Ì³Ì SQLÊý¾Ý¿â½Ì³Ì CÓïÑÔ½Ì³Ì C++½Ì³Ì Java½Ì³Ì Python½Ì³Ì Python3½Ì³Ì C#½Ì³Ì
ÊýÂë: µçÄÔ ±Ê¼Ç±¾ ÏÔ¿¨ ÏÔʾÆ÷ ¹Ì̬ӲÅÌ Ó²ÅÌ ¶ú»ú ÊÖ»ú iphone vivo oppo СÃ× »ªÎª µ¥·´ ×°»ú ͼÀ­¶¡
 
   -> PHP֪ʶ¿â -> PHP Tcpdf Éú³É pdf ²¢½« £¨Imagick£© pdf Éú³É ͼƬ -> ÕýÎÄÔĶÁ

[PHP֪ʶ¿â]PHP Tcpdf Éú³É pdf ²¢½« £¨Imagick£© pdf Éú³É ͼƬ

ÀûÓÃTcpdfÉú³Épdf,ʹÓà html±êÇ©,Éú³É pdf

Ò»¡¢ À­È¡À©Õ¹´úÂë
ʹÓà composer À­È¡

composer require tecnickcom/tcpdf

https://github.com/tecnickcom/tcpdf Ö±½ÓÏÂÔØ

¹ÙÍøµØÖ· : http://www.tcpdf.org

ÈçÏÂЧ¹û:ÔÚÕâÀï²åÈëͼƬÃèÊö

¶þ¡¢¿ª·¢´úÂë html Éú³Épdf
htmlÑùʽ¸ñʽ¿ÉÒԲο¼¹ÙÍø°¸Àý https://tcpdf.org/examples/

require_once(dirname(dirname(__FILE__)) . '/sdk/tcpdf.php'); //¼ÇµÃÒýÈë

 public function createPdf($pdf_name,$data=[],$type=1)
    {
        if(empty($pdf_name)){
            $pdf_name = md5(microtime());
        }
        $pdf_name = $pdf_name;
        $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT,true, 'UTF-8', false);
		// ÉèÖÃÎĵµÐÅÏ¢
		$pdf->SetCreator('hello world');
		$pdf->SetAuthor('hello world');
		$pdf->SetTitle('hello world');
		$pdf->SetSubject('TCPDF Tutorial');
		$pdf->SetKeywords('TCPDF, PDF, PHP');
		// ÉèÖÃҳüºÍÒ³½ÅÐÅÏ¢
//		$pdf->SetHeaderData('logo.png', 30, 'Helloweba.com', 'ÖÂÁ¦ÓÚWEBÇ°¶Ë¼¼ÊõÔÚÖйúµÄÓ¦ÓÃ', array(0,64,255), array(0,64,128));
		$pdf->setFooterData(array(0,64,0), array(0,64,128));
		// ÉèÖÃҳüºÍÒ³½Å×ÖÌå
		$pdf->setHeaderFont(Array('stsongstdlight', '', '10'));
		$pdf->setFooterFont(Array('helvetica', '', '8'));
		// ÉèÖÃĬÈϵȿí×ÖÌå
		$pdf->SetDefaultMonospacedFont('courier');
		// ÉèÖüä¾à
		$pdf->SetMargins(15, 27, 15);
		$pdf->SetHeaderMargin(5);
		$pdf->SetFooterMargin(10);
		// ÉèÖ÷ÖÒ³
		$pdf->SetAutoPageBreak(TRUE, 25);
		// set image scale factor
		$pdf->setImageScale(1.25);
		// set default font subsetting mode
		$pdf->setFontSubsetting(true);
		//ÉèÖÃ×ÖÌå
		$pdf->SetFont('stsongstdlight', '', 14);//¿ÉÒÔÉèÖÃ×Ô¼ºÖÐÒâ×ÖÌå
		$pdf->AddPage();
		$str1 = $this->getHtml($pdf_name,$data,$pdf);
        $pdf->writeHTML($str1, true, false, true, false, '');

        //Êä³öPDF
        ob_clean();
        $pdf_path = ROOT_PATH .'public/pdf/'.$pdf_name.'.pdf';
        $pdf_png_path = ROOT_PATH .'publi/pdf/png/'.$pdf_name.'.png';
       
      
        $pdf->Output($pdf_path, 'F'); //I:½«ÎļþÄÚÁª·¢Ë͵½ä¯ÀÀÆ÷(ĬÈÏ)¡£Èç¹û¿ÉÓÃ,ÔòʹÓòå¼þ¡£µ±ÔÚÉú³ÉPDFµÄÁ´½ÓÉÏÑ¡Ôñ¡°Áí´æΪ¡±Ñ¡Ïîʱ,ʹÓÃnameÖ¸¶¨µÄÃû³Æ¡£D:·¢Ë͵½ä¯ÀÀÆ÷²¢Ç¿ÖÆʹÓÃnameÖ¸¶¨µÄÃû³ÆÏÂÔØÎļþ¡£F: ÒÔÖ¸¶¨µÄÃû³Æ±£´æµ½±¾µØ·þÎñÆ÷Îļþ¡£S:ÒÔ×Ö·û´®ÐÎʽ·µ»ØÎĵµ(ºöÂÔÃû³Æ)¡£FI:µÈЧÓÚF + IÑ¡ÏîFD:µÈЧÓÚF + DÑ¡ÏîE:·µ»ØÎĵµÎªbase64 mime¶à²¿·Öµç×ÓÓʼþ¸½¼þ(RFC 2045) 

        $this->pdf2png($pdf_path,$pdf_png_path);
        return array($pdf_url,$pdf_png_url);

    }

//»ñÈ¡htmlÑùʽ
public funcitoin getHtml(){
	$html = '<h1>HTML Example</h1>
	Some special characters: &lt; € &euro; &#8364; &amp; ¨¨ &egrave; &copy; &gt; \\slash \\\\double-slash \\\\\\triple-slash
	<h2>List</h2>
	List example:
	<ol>
	    <li><img src="images/logo_example.png" alt="test alt attribute" width="30" height="30" border="0" /> test image</li>
	    <li><b>bold text</b></li>
	    <li><i>italic text</i></li>
	    <li><u>underlined text</u></li>
	    <li><b>b<i>bi<u>biu</u>bi</i>b</b></li>
	    <li><a href="http://www.tecnick.com" dir="ltr">link to http://www.tecnick.com</a></li>
	    <li>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.<br />Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.</li>
	    <li>SUBLIST
	        <ol>
	            <li>row one
	                <ul>
	                    <li>sublist</li>
	                </ul>
	            </li>
	            <li>row two</li>
	        </ol>
	    </li>
	    <li><b>T</b>E<i>S</i><u>T</u> <del>line through</del></li>
	    <li><font size="+3">font + 3</font></li>
	    <li><small>small text</small> normal <small>small text</small> normal <sub>subscript</sub> normal <sup>superscript</sup> normal</li>
	</ol>
	<dl>
	    <dt>Coffee</dt>
	    <dd>Black hot drink</dd>
	    <dt>Milk</dt>
	    <dd>White cold drink</dd>
	</dl>
	<div style="text-align:center">IMAGES<br />
	<img src="images/logo_example.png" alt="test alt attribute" width="100" height="100" border="0" /><img src="images/tcpdf_box.svg" alt="test alt attribute" width="100" height="100" border="0" /><img src="images/logo_example.jpg" alt="test alt attribute" width="100" height="100" border="0" />
	</div>';
	return $html;

}


Ò²¿ÉÒÔʹÓÃÆäËûÐÎʽ,Éú³É pdf,ÓÐÐËȤµÄͬѧ¿ÉÒÔ³¢ÊÔÒ»ÏÂ
ÔÚÕâÀï²åÈëͼƬÃèÊö

Èý¡¢Ê¹Óà Imagick ½« pdf Éú³É png
¸ù¾Ý½éÉÜ°²×°Ò»ÏÂphpÀ©Õ¹ https://www.php.net/manual/zh/book.imagick.php

ÔÚÕâÀï²åÈëͼƬÃèÊö

 //pdfºÏ²¢×ª»»Ò»ÕÅͼƬ from_path pdfÀ´Ô´µØÖ·(¾ø¶ÔµØÖ·) target_path ͼƬ´æ´¢µØÖ· (¾ø¶ÔµØÖ·)
    public  function pdf2png($from_path,$target_path)
    {
 
        try {
            $img =  new \Imagick();
            $img->setCompressionQuality(100);
            $img->setResolution(120, 120);
            $img->readImage($from_path);

            $canvas = new \Imagick();
            $imgNum = $img->getNumberImages();
            foreach ($img as $k => $sub) {
                $sub->setImageFormat('png');
                $sub->stripImage();
                $sub->trimImage(0);
                $width = $sub->getImageWidth() + 10;
                $height = $sub->getImageHeight() + 10;
                if ($k + 1 == $imgNum) $height += 10;
                $canvas->newImage($width, $height, new \ImagickPixel('white'));
                $canvas->compositeImage($sub, \Imagick::COMPOSITE_DEFAULT, 5, 5);
            }

            $canvas->resetIterator();
            $canvas->appendImages(true)->writeImage($target_path);
            return $target_path;
         } catch (Exception $e) {
            echo $e->getMessage();
            echo $e->getTraceAsString();
            return false;
        }
    }

ËÄ¡¢×¢ÒâÊÂÏî

1¡¢Ê¹Óà Tcpdf htmlÉú³É pdfʱ,×¢ÒâÒ»ÏÂhtmlµÄÑùʽÎÊÌâ,²»Ö§³ÖÍⲿcssÑùʽ

2¡¢Ê¹Óà Tcpdf htmlÉú³É pdfʱ,×¢ÒâÒ»ÏÂhtmlµÄÑùʽÎÊÌâ, Äã¿´µ½html²»Ò»¶¨ÄÜÉú³ÉÕý³£htmlŶ!

3¡¢Imagick °²×°Ê±,Ò»¶¨Òª×¢Òâ¼ì²éÊÇ·ñ°²×°³É¹¦,·ñÔò»áÓб¨´íÐÅÏ¢,²»ÄÜÕý³£Ê¹ÓÃ

  PHP֪ʶ¿â ×îÐÂÎÄÕÂ
Laravel ÏÂʵÏÖ Google 2fa ÑéÖ¤
UUCTF WP
DASCTF10ÔÂ web
XAMPPÈÎÒâÃüÁîÖ´ÐÐÌáÉýȨÏÞ©¶´£¨CVE-2020-
[GYCTF2020]Easyphp
iwebsec°Ð³¡ ´úÂëÖ´Ðйؿ¨Í¨¹Ø±Ê¼Ç
¶à¸öÏß³Ìͬ²½Ö´ÐУ¬¶à¸öÏß³ÌÒÀ´ÎÖ´ÐУ¬¶à¸ö
php ûʼǼϳ£Ó÷½·¨ (TP5.1)
phpÖ®jwt
2021-09-18
ÉÏһƪÎÄÕ      ÏÂһƪÎÄÕ      ²é¿´ËùÓÐÎÄÕÂ
¼Ó:2021-10-18 17:08:51  ¸ü:2021-10-18 17:10:06 
 
¿ª·¢: C++֪ʶ¿â Java֪ʶ¿â JavaScript Python PHP֪ʶ¿â È˹¤ÖÇÄÜ Çø¿éÁ´ ´óÊý¾Ý Òƶ¯¿ª·¢ ǶÈëʽ ¿ª·¢¹¤¾ß Êý¾Ý½á¹¹ÓëËã·¨ ¿ª·¢²âÊÔ ÓÎÏ·¿ª·¢ ÍøÂçЭÒé ϵͳÔËά
½Ì³Ì: HTML½Ì³Ì CSS½Ì³Ì JavaScript½Ì³Ì GoÓïÑÔ½Ì³Ì JQuery½Ì³Ì VUE½Ì³Ì VUE3½Ì³Ì Bootstrap½Ì³Ì SQLÊý¾Ý¿â½Ì³Ì CÓïÑÔ½Ì³Ì C++½Ì³Ì Java½Ì³Ì Python½Ì³Ì Python3½Ì³Ì C#½Ì³Ì
ÊýÂë: µçÄÔ ±Ê¼Ç±¾ ÏÔ¿¨ ÏÔʾÆ÷ ¹Ì̬ӲÅÌ Ó²ÅÌ ¶ú»ú ÊÖ»ú iphone vivo oppo СÃ× »ªÎª µ¥·´ ×°»ú ͼÀ­¶¡

360ͼÊé¹Ý ¹ºÎï Èý·á¿Æ¼¼ ÔĶÁÍø ÈÕÀú ÍòÄêÀú 2024Äê12ÈÕÀú -2024/12/28 13:19:11-

ͼƬ×Ô¶¯²¥·ÅÆ÷
¡ýͼƬ×Ô¶¯²¥·ÅÆ÷¡ý
TxTС˵ÔĶÁÆ÷
¡ýÓïÒôÔĶÁ,С˵ÏÂÔØ,¹ÅµäÎÄѧ¡ý
Ò»¼üÇå³ýÀ¬»ø
¡ýÇáÇáÒ»µã,Çå³ýϵͳÀ¬»ø¡ý
ͼƬÅúÁ¿ÏÂÔØÆ÷
¡ýÅúÁ¿ÏÂÔØͼƬ,ÃÀŮͼ¿â¡ý
  ÍøÕ¾ÁªÏµ: qq:121756557 email:121756557@qq.com  ITÊýÂë
Êý¾Ýͳ¼Æ