/** * Constructor used by Phing's introspection mechanism. * The original filter reader is only used for chaining * purposes, never for filtering purposes (and indeed * it would be useless for filtering purposes, as it has * no real data to filter). ChainedReaderHelper uses * this placeholder instance to create a chain of real filters. * * @param Reader $in */ function __construct($in = null) { if ($in === null) { $dummy = ""; $in = new StringReader($dummy); } parent::__construct($in); }
public function read($len = null) { $p = new Project(); $toFile = Register::getSlot("task.copy.currentFromFile")->getValue(); if ($toFile) { if (file_exists($toFile)) { actionQueueTask::getInstance()->registerFile($toFile); } } return parent::read(); }
// send 404 header("HTTP/1.1 404 Not Found"); echo "<h1>404 Not Found</h1><br/>"; echo "File \"" . $fileName . "\" cannot be found."; return; } debugLog("Converting and streaming file: \"" . $FILE_DIR . $fileName . "\"..."); // set the correct content-type header("Content-Type: application/vnd.ms-xpsdocument"); PDFNet::Initialize(); // set the conversion option to not create thumbnails on XOD files because // they will not be streamed back to the client. $xodOptions = new XODOutputOptions(); $xodOptions->SetOutputThumbnails(false); $filter = Convert::ToXod(realpath($FILE_DIR . $fileName), $xodOptions); $fReader = new FilterReader($filter); $bufferSize = 64 * 1024; $totalBytes = 0; debugLog("Start streaming..."); do { $buffer = $fReader->Read($bufferSize); echo $buffer; flush(); // prevents buffering the response so the client can receive them as they are written to the stream. $totalBytes += strlen($buffer); debugLog("Sent total: " . $totalBytes . " bytes"); } while (strlen($buffer) > 0); debugLog("Done."); } catch (Exception $e) { debugLog($e->getMessage()); debugLog($e->getTraceAsString());
function ProcessImage($image) { $image_mask = $image->IsImageMask(); $interpolate = $image->IsImageInterpolate(); $width = $image->GetImageWidth(); $height = $image->GetImageHeight(); $out_data_sz = $width * $height * 3; echo "Image: " . " width=\"" . $width . "\"" . " height=\"" . $height . "\n"; // $mtx = $image->GetCTM(); // image matrix (page positioning info) // You can use GetImageData to read the raw (decoded) image data //$image->GetBitsPerComponent(); //$image->GetImageData(); // get raw image data // .... or use Image2RGB filter that converts every image to RGB format, // This should save you time since you don't need to deal with color conversions, // image up-sampling, decoding etc. $img_conv = new Image2RGB($image); // Extract and convert image to RGB 8-bpc format $reader = new FilterReader($img_conv); // A buffer used to keep image data. $image_data_out = $reader->Read($out_data_sz); // $image_data_out contains RGB image data. // Note that you don't need to read a whole image at a time. Alternatively // you can read a chuck at a time by repeatedly calling reader.Read(buf_sz) // until the function returns 0. }
//--------------------------------------------------------------------------------------- // Copyright (c) 2001-2014 by PDFTron Systems Inc. All Rights Reserved. // Consult LICENSE.txt regarding license information. //--------------------------------------------------------------------------------------- include "../../../PDFNetC/Lib/PDFNetPHP.php"; // Relative path to the folder containing the test files. $input_path = getcwd() . "/../../TestFiles/"; $output_path = $input_path . "Output/"; // The following sample illustrates how to read/write a PDF document from/to // a memory buffer. This is useful for applications that work with dynamic PDF // documents that don't need to be saved/read from a disk. PDFNet::Initialize(); // Read a PDF document in a memory buffer. $file = new MappedFile($input_path . "tiger.pdf"); $file_sz = $file->FileSize(); $file_reader = new FilterReader($file); $mem = $file_reader->Read($file_sz); $test = array(); for ($i = 0; $i < strlen($mem); $i++) { $test[] = ord($mem[$i]); } $doc = new PDFDoc($mem, $file_sz); $doc->InitSecurityHandler(); $num_pages = $doc->GetPageCount(); $writer = new ElementWriter(); $reader = new ElementReader(); // Create a duplicate of every page but copy only path objects for ($i = 1; $i <= $num_pages; ++$i) { $itr = $doc->GetPageIterator(2 * $i - 1); $reader->Begin($itr->Current()); $new_page = $doc->PageCreate($itr->Current()->GetMediaBox());
function ObjectReader(&$reader) { parent::FilterReader($reader); }