Function SetFont() is a PHP function used to set the font for text output in a PDF document. This function can be used to change the font size, style, and typeface for text in a PDF document.
Here are some examples of using SetFont() function in PHP:
Example 1:
// Load the PDFlib library $pdf = new PDFlib();
// Open the document $pdf->begin_document("output.pdf");
// Set the font for the document using SetFont() $pdf->SetFont("Helvetica", "B", 12);
// Add some text to the document $pdf->show_text("Hello world!");
// Close the document $pdf->end_document(); ?>
In this example, SetFont() is used to set the font for the document to Helvetica Bold, with a font size of 12 points. The text "Hello world!" is then added to the document using the show_text() function.
Example 2:
// Load the FPDF library $pdf = new FPDF();
// Add a page to the document $pdf->AddPage();
// Set the font for the document using SetFont() $pdf->SetFont("Arial", "", 14);
// Add some text to the document $pdf->Cell(0, 10, "This is some sample text using SetFont()", 0, 1, "C");
// Output the document $pdf->Output(); ?>
In this example, SetFont() is used to set the font for the document to Arial, with a font size of 14 points. The text "This is some sample text using SetFont()" is then added to the document using the Cell() function.
The examples above are using different package libraries. The first example is using PDFlib library while the second example is using FPDF library.
PHP PDF::setFont - 30 examples found. These are the top rated real world PHP examples of PDF::setFont extracted from open source projects. You can rate examples to help us improve the quality of examples.