簡體   English   中英

mPDF:如何使用粗體文本使用 WriteCell 函數?

[英]mPDF: How to use WriteCell function using bold text?

我在 Laravel 中有這個片段,那里有一個包裝器。 注意我直接使用 mPDF,而不是包裝函數

    $pdf = new MPdf();
    $mpdf = $pdf->getMpdf();
    $mpdf->SetSourceFile(public_path() . DIRECTORY_SEPARATOR  . 'pdf' . DIRECTORY_SEPARATOR   . 'my_template.pdf');
    $template = $mpdf->ImportPage(1);
    $mpdf->UseTemplate($template);
    $mpdf->WriteCell(130,140, $text_to_write );

我的需要只是用粗體寫出我的文字。 我永遠不需要更改字體文件。

如何 ?!

我解決了訪問底層 FPDF 函數的問題。

回顧:Laravel-mpdf 是 mPDF 的包裝器。 mPDF“包裝”並增強了少數 pdf 處理庫之一。

它在此處說明: https : //mpdf.github.io/“它基於 FPDF 和 HTML2FPDF,具有許多增強功能”

有了這些信息,我只是嘗試使用 FPDF 函數並且它們起作用了。 FPDF 文檔: http ://www.fpdf.org/en/doc

片段

    $pdf = new MPdf();
    $mpdf = $pdf->getMpdf();
    $mpdf->SetSourceFile('name_and_path_of_template_file.pdf');
    $template = $mpdf->ImportPage(1);
    $mpdf->UseTemplate($template);
    $mpdf->SetFont('Arial','B', 11);

    $mpdf->WriteText(11,82, $what_to_write_in_bold );

    $mpdf->SetFont('Arial','', 10);

    $mpdf->WriteText(164, 243.46, $what_to_write_in_noraml);

    $mpdf->Output();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM