"tiger_zoom_900dpi.png", "PNG" ) echo nl2br ( "Example 5: tiger_zoom_900dpi.png\n" ) // - // Example 6) $draw -> SetImageSize ( 50, 50 ) // Set the thumbnail to be 50x50 pixel image. $draw -> SetPageBox ( Page :: e_crop ) $draw -> SetDPI ( 900 ) // Set the output image resolution to 900 DPI. Select the crop region to be used for drawing. "tiger_400x200_stretch.jpg", "JPEG" ) echo nl2br ( "Example 4: tiger_400x200_stretch.jpg\n" ) //- // Example 5) Zoom into a specific region of the page and rasterize the // area at 200 DPI and as a thumbnail (i.e. $draw -> SetRotate ( Page :: e_0 ) // Disable image rotation. "tiger_200x400_rot180.png", "PNG", $gray_hint ) echo nl2br ( "Example 4: tiger_200x400_rot180.png\n" ) $draw -> SetImageSize ( 400, 200, false ) // The third parameter sets 'preserve-aspect-ratio' to false. $gray_hint = $hint_set -> CreateDict ( ) $gray_hint -> PutName ( "ColorSpace", "Gray" ) $draw -> Export ( $page, $output_path. 'gray_hint' tells the rasterizer to export the image as grayscale. "tiger_1000x1000.png", "PNG", $mono_hint ) echo nl2br ( "Example 4: tiger_1000x1000.png\n" ) $draw -> SetImageSize ( 200, 400 ) // Set the output image to be 200 wide and 300 pixels tall $draw -> SetRotate ( Page :: e_180 ) // Rotate all pages 90 degrees clockwise. $draw -> SetImageSize ( 1000, 1000 ) // Set the output image to be 1000 wide and 1000 pixels tall $draw -> Export ( $page, $output_path. $mono_hint = $hint_set -> CreateDict ( ) $mono_hint -> PutNumber ( "BPC", 1 ) // SetImageSize can be used instead of SetDPI() to adjust page scaling // dynamically so that given image fits into a buffer of given dimensions. In this case we tell the rasterizer to export the image as // 1 Bit Per Component (BPC) image. Initialize render 'gray_hint' parameter, that is used to control the // rendering process. Also illustrates some // other features in PDFDraw class such as rotation, image stretching, exporting // to grayscale, or monochrome. - // Example 4) Convert PDF page to a fixed image size. "tiger_100dpi_rot90.raw", $bmp -> GetBuffer ( ) ) echo nl2br ( "Example 3: tiger_100dpi_rot90.raw\n" ) $draw -> SetRotate ( Page :: e_0 ) // Disable image rotation for remaining samples. $bmp = $draw -> GetBitmap ( $page, PDFDraw :: e_rgb ) // Save the raw RGB data to disk. $draw -> SetRotate ( Page :: e_90 ) // Rotate all pages 90 degrees clockwise. $draw -> SetDPI ( 100 ) // Set the output resolution is to 100 DPI. Also, rotate the // page 90 degrees and save the result as RAW. $tiger_doc -> InitSecurityHandler ( ) $page = $tiger_doc -> GetPage ( 1 ) //- // Example 3) Convert the first page to raw bitmap. "tiger.pdf" ) // Initialize the security handler, in case the PDF is encrypted. for ( $itr = $doc -> GetPageIterator ( ) $itr -> HasNext ( ) $itr -> Next ( ) ) echo nl2br ( "Done.\n" ) // Examples 3-5 // Common code for remaining samples. $encoder_param = $hint_set -> CreateDict ( ) $encoder_param -> PutNumber ( "Quality", 80 ) // Traverse all pages in the document. Use optional encoder parameter to specify JPEG quality. $doc -> InitSecurityHandler ( ) $draw -> SetDPI ( 72 ) // Set the output resolution is to 72 DPI. "newsletter.pdf" ) // Initialize the security handler, in case the PDF is encrypted. echo nl2br ( "Example 2:\n" ) $hint_set = new ObjSet ( ) // A collection of rendering 'hits'. "tiger_92dpi.tif", "TIFF" ) //- // Example 2) Convert the all pages in a given document to JPEG at 72 DPI. "tiger_92dpi.png" ) echo nl2br ( "Example 1: tiger_92dpi.png\n" ) // Export the same page as TIFF $draw -> Export ( $doc -> GetPageIterator ( ) -> Current ( ), $output_path. $draw -> Export ( $doc -> GetPageIterator ( ) -> Current ( ), $output_path. $draw -> SetDPI ( 92 ) // C) Rasterize the first page in the document and save the result as PNG. InitSecurityHandler ( ) // B) The output resolution is set to 92 DPI.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |