Пример #1
0
    $label = $doc->GetPageLabel($i);
    if ($label->IsValid()) {
        echo nl2br(" Label: " . $label->GetLabelTitle($i) . "\n");
    } else {
        echo nl2br(" No Label.\n");
    }
}
//-----------------------------------------------------------
// Example 3: Modify page labels from an existing PDF document.
//-----------------------------------------------------------
$doc = new PDFDoc($output_path . "newsletter_with_pagelabels.pdf");
$doc->InitSecurityHandler();
// Remove the alphabetic labels from example 1.
$doc->RemovePageLabel(7);
// Replace the Prefix in the decimal labels (from example 1).
$label = $doc->GetPageLabel(4);
if ($label->IsValid()) {
    $label->SetPrefix("A");
    $label->SetStart(1);
}
// Add a new label
$new_label = PageLabel::Create($doc->GetSDFDoc(), PageLabel::e_decimal, "B", 1);
$doc->SetPageLabel(10, $new_label);
// starting from page 10.
$doc->Save($output_path . "newsletter_with_pagelabels_modified.pdf", SDFDoc::e_linearized);
echo nl2br("Done. Result saved in newsletter_with_pagelabels_modified.pdf...\n");
$page_num = $doc->GetPageCount();
for ($i = 1; $i <= $page_num; ++$i) {
    echo "Page number: " . $i;
    $label = $doc->GetPageLabel($i);
    if ($label->IsValid()) {