示例#1
0
    $new_doc->InsertPages($i, $in_doc, 1, $in_doc->GetPageCount(), PDFDoc::e_none);
    $in_doc->Close();
}
$new_doc->Save($output_path . "newsletter_merge_pages.pdf", SDFDoc::e_remove_unused);
echo nl2br("Done. Result saved in newsletter_merge_pages.pdf...\n");
$in_doc->Close();
// Sample 3 - Delete every second page
echo nl2br("_______________________________________________\n");
echo nl2br("Sample 3 - Delete every second page...\n");
echo nl2br("Opening the input pdf...\n");
$in_doc = new PDFDoc($input_path . "newsletter.pdf");
$in_doc->InitSecurityHandler();
$page_num = $in_doc->GetPageCount();
while ($page_num >= 1) {
    $itr = $in_doc->GetPageIterator($page_num);
    $in_doc->PageRemove($itr);
    $page_num -= 2;
}
$in_doc->Save($output_path . "newsletter_page_remove.pdf", 0);
echo nl2br("Done. Result saved in newsletter_page_remove.pdf...\n");
//Close the open document to free up document memory sooner than waiting for the
//garbage collector
$in_doc->Close();
// Sample 4 - Inserts a page from one document at different
// locations within another document
echo nl2br("_______________________________________________\n");
echo nl2br("Sample 4 - Insert a page at different locations...\n");
echo nl2br("Opening the input pdf...\n");
$in1_doc = new PDFDoc($input_path . "newsletter.pdf");
$in1_doc->InitSecurityHandler();
$in2_doc = new PDFDoc($input_path . "fish.pdf");