示例#1
0
$draw->Export($doc->GetPageIterator()->Current(), $output_path . "tiger_92dpi.png");
echo nl2br("Example 1: " . $output_path . "tiger_92dpi.png" . ". Done.\n");
// Export the same page as TIFF
$draw->Export($doc->GetPageIterator()->Current(), $output_path . "tiger_92dpi.tif", "TIFF");
//--------------------------------------------------------------------------------
// Example 2) Convert the all pages in a given document to JPEG at 72 DPI.
echo nl2br("Example 2:\n");
$hint_set = new ObjSet();
//  A collection of rendering 'hits'.
$doc = new PDFDoc($input_path . "newsletter.pdf");
// Initialize the security handler, in case the PDF is encrypted.
$doc->InitSecurityHandler();
$draw->SetDPI(72);
// Set the output resolution is to 72 DPI.
// Use optional encoder parameter to specify JPEG quality.
$encoder_param = $hint_set->CreateDict();
$encoder_param->PutNumber("Quality", 80);
// Traverse all pages in the document.
for ($itr = $doc->GetPageIterator(); $itr->HasNext(); $itr->Next()) {
    $filename = $output_path . "newsletter" . $itr->Current()->GetIndex() . ".jpg";
    echo nl2br($filename . "\n");
    $draw->Export($itr->Current(), $filename, "JPEG", $encoder_param);
}
echo nl2br("Done.\n");
// Examples 3-5
// Common code for remaining samples.
$tiger_doc = new PDFDoc($input_path . "tiger.pdf");
// Initialize the security handler, in case the PDF is encrypted.
$tiger_doc->InitSecurityHandler();
$page = $tiger_doc->GetPage(1);
//--------------------------------------------------------------------------------