// Start a new page ------------------------------------ // // The example illustrates how to embed the external font in a PDF document. // The example also shows how ElementReader can be used to copy and modify // Elements between pages. $reader = new ElementReader(); // Start reading Elements from the last page. We will copy all Elements to // a new page but will modify the font associated with text. $reader->Begin($doc->GetPage($doc->GetPageCount())); $page = $doc->PageCreate(new Rect(0.0, 0.0, 1300.0, 794.0)); $writer->Begin($page); // begin writing to this page $builder->Reset(); // Reset the GState to default // Embed an external font in the document. $font = Font::CreateTrueTypeFont($doc->GetSDFDoc(), $input_path . "font.ttf"); while (($element = $reader->Next()) != null) { if ($element->GetType() == Element::e_text) { $element->GetGState()->SetFont($font, 12); } $writer->WriteElement($element); } $reader->End(); $writer->End(); // save changes to the current page $doc->PagePushBack($page); // Start a new page ------------------------------------ // // The example illustrates how to embed the external font in a PDF document. // The example also shows how ElementReader can be used to copy and modify // Elements between pages.