コード例 #1
0
// PDFNet::AddFontSubst(PDFNet::e_Identity, "C:/WINDOWS/Fonts/arialuni.ttf");
// PDFNet::AddFontSubst(PDFNet::e_Japan1, "C:/Program Files/Adobe/Acrobat 7.0/Resource/CIDFont/KozMinProVI-Regular.otf");
// PDFNet::AddFontSubst(PDFNet::e_Japan2, "c:/myfonts/KozMinProVI-Regular.otf");
// PDFNet::AddFontSubst(PDFNet::e_Korea1, "AdobeMyungjoStd-Medium.otf");
// PDFNet::AddFontSubst(PDFNet::e_CNS1, "AdobeSongStd-Light.otf");
// PDFNet::AddFontSubst(PDFNet::e_GB1, "AdobeMingStd-Light.otf");
$draw = new PDFDraw();
//--------------------------------------------------------------------------------
// Example 1) Convert the first page to PNG and TIFF at 92 DPI.
// A three step tutorial to convert PDF page to an image.
// A) Open the PDF document.
$doc = new PDFDoc($input_path . "tiger.pdf");
// Initialize the security handler, in case the PDF is encrypted.
$doc->InitSecurityHandler();
// B) The output resolution is set to 92 DPI.
$draw->SetDPI(92);
// C) Rasterize the first page in the document and save the result as PNG.
$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.