commitall
This commit is contained in:
19
account/application/third_party/pdf/fpdm.php
vendored
Normal file
19
account/application/third_party/pdf/fpdm.php
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Entry point for legacy calls
|
||||
*
|
||||
* Devs not using composer autoload will have included this file directly.
|
||||
* Keeping it as a wrapper allows to retain compatibility with legacy projects
|
||||
* while allowing adjustments to the source to improve composer integration.
|
||||
*/
|
||||
|
||||
define('FPDM_DIRECT', true);
|
||||
|
||||
require_once("fpdm/fpdm.php");
|
||||
|
||||
require_once("fpdm/filters/FilterASCIIHex.php");
|
||||
require_once("fpdm/filters/FilterASCII85.php");
|
||||
require_once("fpdm/filters/FilterFlate.php");
|
||||
require_once("fpdm/filters/FilterLZW.php");
|
||||
require_once("fpdm/filters/FilterStandard.php");
|
20
account/application/third_party/pdf/fpdm/ex-array.php
vendored
Normal file
20
account/application/third_party/pdf/fpdm/ex-array.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/***************************
|
||||
Sample using a PHP array
|
||||
****************************/
|
||||
|
||||
require('fpdm.php');
|
||||
|
||||
$fields = array(
|
||||
'name' => 'My name',
|
||||
'address' => 'My address',
|
||||
'city' => 'My city',
|
||||
'phone' => 'My phone number'
|
||||
);
|
||||
|
||||
$pdf = new FPDM('template.pdf');
|
||||
$pdf->Load($fields, false); // second parameter: false if field values are in ISO-8859-1, true if UTF-8
|
||||
$pdf->Merge();
|
||||
$pdf->Output();
|
||||
?>
|
12
account/application/third_party/pdf/fpdm/ex-fdf.php
vendored
Normal file
12
account/application/third_party/pdf/fpdm/ex-fdf.php
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/***************************
|
||||
Sample using an FDF file
|
||||
****************************/
|
||||
|
||||
require('fpdm.php');
|
||||
|
||||
$pdf = new FPDM('template.pdf', 'fields.fdf');
|
||||
$pdf->Merge();
|
||||
$pdf->Output();
|
||||
?>
|
BIN
account/application/third_party/pdf/fpdm/ex.pdf
vendored
Normal file
BIN
account/application/third_party/pdf/fpdm/ex.pdf
vendored
Normal file
Binary file not shown.
0
account/application/third_party/pdf/fpdm/export/cache/.gitkeep
vendored
Normal file
0
account/application/third_party/pdf/fpdm/export/cache/.gitkeep
vendored
Normal file
2
account/application/third_party/pdf/fpdm/export/cache/data.fdf
vendored
Normal file
2
account/application/third_party/pdf/fpdm/export/cache/data.fdf
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
%FDF-1.2
|
||||
%<25><><EFBFBD><EFBFBD>
|
BIN
account/application/third_party/pdf/fpdm/export/cache/pdf_flatten.pdf
vendored
Normal file
BIN
account/application/third_party/pdf/fpdm/export/cache/pdf_flatten.pdf
vendored
Normal file
Binary file not shown.
125
account/application/third_party/pdf/fpdm/export/fdf/fdf.php
vendored
Normal file
125
account/application/third_party/pdf/fpdm/export/fdf/fdf.php
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
|
||||
/****************************************************************
|
||||
*@file fdf.php
|
||||
*@name Generates fdf files
|
||||
*@internal fdf bridge to forge_fdf
|
||||
*@package fpdftk
|
||||
*@date 2010-12-05
|
||||
*@author 0livier
|
||||
*@version 2.1
|
||||
*@note
|
||||
* V2.1 (05.12.2010) Adaptation for FPDM
|
||||
* V2.0 (27.10.2010) USe of URL TOOLBOX package
|
||||
* V1.0 (22.10.2010) First working release
|
||||
******************************************************************/
|
||||
|
||||
require ("forge_fdf.php");
|
||||
|
||||
if (!defined('URL_TOOLBOX')) die("Requires the URL_TOOLBOX package!");
|
||||
|
||||
|
||||
/**
|
||||
*Resolves relative pdf urls to absolute
|
||||
*
|
||||
*@note pdf paths MUST BE ABSOLUTE in the fdf file or http scheme because when path contains .. then fdf fails
|
||||
*@param String $pdf_url any url
|
||||
*@return String $url the absolute url
|
||||
**/
|
||||
function resolve_pdf_url($pdf_url) {
|
||||
//----------------------------------
|
||||
$url=resolve_url($pdf_url);
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
*Generates a form definition file (fdf)
|
||||
*
|
||||
*@note error message is dumped into syslog if supported
|
||||
*@todo Expand support not only to fdf_data_strings (I don't need this feature)
|
||||
*@param String $pdf_url
|
||||
*@param Array $pdf_data the array that holds fields datas (field_name => field_value
|
||||
*@param String $output_mode
|
||||
* 'D' : WARNING!! By default, THIS FUNCTION SENDS HTTP HEADERS! It MUST be called before
|
||||
* any content is spooled to the browser, or the function will fail!
|
||||
* 'S' : Return the fdf file generated as a string
|
||||
* <fdf_file> fullpathname to where the fdf file content has to be saved.
|
||||
*@return mixed ret the return value which can be:
|
||||
* -a boolean true when output_mode is set to 'D'
|
||||
* -a text the fdf content when output_mode is set to 'S'
|
||||
* -an array holding success flag with either the fdf size or the error message
|
||||
**/
|
||||
function output_fdf($pdf_url,$pdf_data,$output_mode='D') {
|
||||
//---------------------------------------------------------
|
||||
|
||||
// Ensures pdf path is absolute
|
||||
$pdf_form_url=resolve_pdf_url($pdf_url);
|
||||
|
||||
// string data, used for text fields, combo boxes and list boxes
|
||||
$fdf_data_strings=$pdf_data;
|
||||
|
||||
// name data, used for checkboxes and radio buttons
|
||||
// (e.g., /Yes and /Off for true and false)
|
||||
$fdf_data_names=array();
|
||||
|
||||
//fields security and accessibility attributes
|
||||
$fields_hidden=array();
|
||||
$fields_readonly=array();
|
||||
|
||||
|
||||
$fdf=forge_fdf( $pdf_form_url,
|
||||
$fdf_data_strings,
|
||||
$fdf_data_names,
|
||||
$fields_hidden,
|
||||
$fields_readonly );
|
||||
|
||||
|
||||
switch($output_mode) {
|
||||
case "D"://Send the fdf header so acrobat recognize it.
|
||||
header ("Content-Type: application/vnd.fdf");
|
||||
print $fdf;
|
||||
$ret=true;
|
||||
break;
|
||||
case "S"://String
|
||||
$ret=$fdf;
|
||||
break;
|
||||
default:// write the file out
|
||||
|
||||
$error_fdf_access='';
|
||||
$fdf_file=$output_mode;
|
||||
$fdf_dir=dirname($fdf_file);
|
||||
|
||||
//Parano<6E>d access mode with syslog in background as watchdog for errors
|
||||
if(file_exists($fdf_dir)) {
|
||||
if(is_writable($fdf_dir)) {
|
||||
if(!is_writable($fdf_file)&&false) { //Create
|
||||
$error_fdf_access="can not write fdf file ($fdf_file), disk full or missing rights?";
|
||||
}
|
||||
}else {
|
||||
$error_fdf_access="can not write into fdf's directory ($fdf_dir)";
|
||||
}
|
||||
}else {
|
||||
$error_fdf_access="can not access to fdf's directory ($fdf_dir)";
|
||||
}
|
||||
$success=false;
|
||||
if($error_fdf_access !="") {
|
||||
$err="output_fdf : Unable to create fdf file '".$fdf_file."'<br> because $error_fdf_access.";
|
||||
} else {
|
||||
if($fp=fopen($fdf_file,'w')){
|
||||
$err=fwrite($fp,$fdf,strlen($fdf));
|
||||
if(function_exists('syslog')) syslog(LOG_WARNING,"FDF file '".$output_mode."' written successfully ($err bytes)");
|
||||
$success=true;
|
||||
}else{
|
||||
$err="output_fdf : Unable to generate file '".$output_mode."', disk full or corrupted?.";
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
$ret=array("success"=>$success,"return"=>$err);
|
||||
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
?>
|
146
account/application/third_party/pdf/fpdm/export/fdf/forge_fdf.php
vendored
Normal file
146
account/application/third_party/pdf/fpdm/export/fdf/forge_fdf.php
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
/* forge_fdf, by Sid Steward
|
||||
version 1.0
|
||||
visit: www.pdfhacks.com/forge_fdf/
|
||||
|
||||
For text fields, combo boxes and list boxes, add
|
||||
field values as a name => value pair to $fdf_data_strings.
|
||||
|
||||
For check boxes and radio buttons, add field values
|
||||
as a name => value pair to $fdf_data_names. Typically,
|
||||
true and false correspond to the (case sensitive)
|
||||
names "Yes" and "Off".
|
||||
|
||||
Any field added to the $fields_hidden or $fields_readonly
|
||||
array must also be a key in $fdf_data_strings or
|
||||
$fdf_data_names; this might be changed in the future
|
||||
|
||||
Any field listed in $fdf_data_strings or $fdf_data_names
|
||||
that you want hidden or read-only must have its field
|
||||
name added to $fields_hidden or $fields_readonly; do this
|
||||
even if your form has these bits set already
|
||||
|
||||
PDF can be particular about CR and LF characters, so I
|
||||
spelled them out in hex: CR == \x0d : LF == \x0a
|
||||
*/
|
||||
|
||||
function escape_pdf_string( $ss )
|
||||
{
|
||||
$ss_esc= '';
|
||||
$ss_len= strlen( $ss );
|
||||
for( $ii= 0; $ii< $ss_len; ++$ii ) {
|
||||
if( ord($ss{$ii})== 0x28 || // open paren
|
||||
ord($ss{$ii})== 0x29 || // close paren
|
||||
ord($ss{$ii})== 0x5c ) // backslash
|
||||
{
|
||||
$ss_esc.= chr(0x5c).$ss{$ii}; // escape the character w/ backslash
|
||||
}
|
||||
else if( ord($ss{$ii}) < 32 || 126 < ord($ss{$ii}) ) {
|
||||
$ss_esc.= sprintf( "\\%03o", ord($ss{$ii}) ); // use an octal code
|
||||
}
|
||||
else {
|
||||
$ss_esc.= $ss{$ii};
|
||||
}
|
||||
}
|
||||
return $ss_esc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
$key = addcslashes($key, "\n\r\t\\()");
|
||||
$val = addcslashes($val, "\n\r\t\\()");
|
||||
**/
|
||||
function escape_pdf_name( $ss )
|
||||
{
|
||||
$ss_esc= '';
|
||||
$ss_len= strlen( $ss );
|
||||
for( $ii= 0; $ii< $ss_len; ++$ii ) {
|
||||
if( ord($ss{$ii}) < 33 || 126 < ord($ss{$ii}) ||
|
||||
ord($ss{$ii})== 0x23 ) // hash mark
|
||||
{
|
||||
$ss_esc.= sprintf( "#%02x", ord($ss{$ii}) ); // use a hex code
|
||||
}
|
||||
else {
|
||||
$ss_esc.= $ss{$ii};
|
||||
}
|
||||
}
|
||||
return $ss_esc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generates the fdf code
|
||||
*
|
||||
*@param String $pdf_form_url: a string containing a URL path to a PDF file on the
|
||||
* server. This PDF MUST exist and contain fields with
|
||||
* the names referenced by $pdf_data for this function
|
||||
* to work.
|
||||
*@param Array $fdf_data_strings: an array of any fields in $pdf_form_url that you want to
|
||||
* populate, of the form key=>val; where the field
|
||||
* name is the key, and the field's value is in val.
|
||||
*@return String
|
||||
**/
|
||||
function forge_fdf( $pdf_form_url,
|
||||
$fdf_data_strings,
|
||||
$fdf_data_names,
|
||||
$fields_hidden,
|
||||
$fields_readonly )
|
||||
{
|
||||
$fdf = "%FDF-1.2\x0d%\xe2\xe3\xcf\xd3\x0d\x0a"; // header
|
||||
$fdf.= "1 0 obj\x0d<< "; // open the Root dictionary
|
||||
$fdf.= "\x0d/FDF << "; // open the FDF dictionary
|
||||
$fdf.= "/Fields [ "; // open the form Fields array
|
||||
|
||||
// string data, used for text fields, combo boxes and list boxes
|
||||
foreach( $fdf_data_strings as $key => $value ) {
|
||||
$fdf.= "<< /V (".escape_pdf_string($value).")".
|
||||
"/T (".escape_pdf_string($key).") ";
|
||||
if( in_array( $key, $fields_hidden ) )
|
||||
$fdf.= "/SetF 2 ";
|
||||
else
|
||||
$fdf.= "/ClrF 2 ";
|
||||
|
||||
if( in_array( $key, $fields_readonly ) )
|
||||
$fdf.= "/SetFf 1 ";
|
||||
else
|
||||
$fdf.= "/ClrFf 1 ";
|
||||
|
||||
$fdf.= ">> \x0d";
|
||||
}
|
||||
|
||||
// name data, used for checkboxes and radio buttons
|
||||
// (e.g., /Yes and /Off for true and false)
|
||||
foreach( $fdf_data_names as $key => $value ) {
|
||||
$fdf.= "<< /V /".escape_pdf_name($value).
|
||||
" /T (".escape_pdf_string($key).") ";
|
||||
if( in_array( $key, $fields_hidden ) )
|
||||
$fdf.= "/SetF 2 ";
|
||||
else
|
||||
$fdf.= "/ClrF 2 ";
|
||||
|
||||
if( in_array( $key, $fields_readonly ) )
|
||||
$fdf.= "/SetFf 1 ";
|
||||
else
|
||||
$fdf.= "/ClrFf 1 ";
|
||||
$fdf.= ">> \x0d";
|
||||
}
|
||||
|
||||
$fdf.= "] \x0d"; // close the Fields array
|
||||
|
||||
// the PDF form filename or URL, if given
|
||||
if( $pdf_form_url ) {
|
||||
$fdf.= "/F (".escape_pdf_string($pdf_form_url).") \x0d";
|
||||
}
|
||||
|
||||
$fdf.= ">> \x0d"; // close the FDF dictionary
|
||||
$fdf.= ">> \x0dendobj\x0d"; // close the Root dictionary
|
||||
|
||||
// trailer; note the "1 0 R" reference to "1 0 obj" above
|
||||
$fdf.= "trailer\x0d<<\x0d/Root 1 0 R \x0d\x0d>>\x0d";
|
||||
$fdf.= "%%EOF\x0d\x0a";
|
||||
|
||||
return $fdf;
|
||||
}
|
||||
|
||||
?>
|
148
account/application/third_party/pdf/fpdm/export/pdf/pdftk.php
vendored
Normal file
148
account/application/third_party/pdf/fpdm/export/pdf/pdftk.php
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
/****************************************************************
|
||||
*@file pdftk.php
|
||||
*@name Generates pdf files using the pdf toolkit
|
||||
*@requires the pdftk binary os dependant placed in this same directory, see line 63 of this script.
|
||||
*@internal fdf bridge to pdftk
|
||||
*@package fpdftk
|
||||
*@date 2010-12-06
|
||||
*@author 0livier
|
||||
*@version 2.0
|
||||
*@note
|
||||
* V2.0 '06.12.2010) Add security support , first public release.
|
||||
* V1.0 (05.12.2010) First working release
|
||||
******************************************************************/
|
||||
|
||||
if (!defined('URL_TOOLBOX')) die("Requires the URL_TOOLBOX package!");
|
||||
|
||||
define("PHP5_ENGINE",version_compare(phpversion(), "5"));
|
||||
|
||||
//!NOTE try to detect your OS
|
||||
|
||||
function is_windows(){
|
||||
$PHP_OS=php_uname('s');
|
||||
return (strtoupper(substr($PHP_OS, 0, 3)) === 'WIN');
|
||||
}
|
||||
|
||||
function is_mac() {
|
||||
//--------------
|
||||
$PHP_OS=php_uname('s');
|
||||
return (strtoupper(substr($PHP_OS, 0, 6)) === 'DARWIN'); //not tested
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*Generate randomly an unique id
|
||||
*@note this is used to fight acrobat cache
|
||||
**/
|
||||
function rnunid() {
|
||||
return md5( uniqid() ); // 32 characters long
|
||||
//$unique = sha1( uniqid() ); // 40 characters long
|
||||
}
|
||||
|
||||
/**
|
||||
*@name pdftk
|
||||
*@brief Validate with xmlint (external tool) an xml file using the schema (XML|DTD|XSD|RNG|SCH)
|
||||
*@access public
|
||||
*@note This function will call pdftk/pdftk.exe like this:
|
||||
* pdftk form.pdf fill_form data.fdf output out.pdf flatten
|
||||
* (pdftk form.filled.pdf output out.pdf flatten is not supported)
|
||||
*
|
||||
* If the input FDF file includes Rich Text formatted data in
|
||||
* addition to plain text, then the Rich Text data is packed
|
||||
* into the form fields as well as the plain text. Pdftk also
|
||||
* sets a flag that cues Acrobat/Reader to generate new field
|
||||
* appearances based on the Rich Text data. That way, when the
|
||||
* user opens the PDF, the viewer will create the Rich Text
|
||||
* fields on the spot. If the user's PDF viewer does not sup-
|
||||
* port Rich Text, then the user will see the plain text data
|
||||
* instead. If you flatten this form before Acrobat has a
|
||||
* chance to create (and save) new field appearances, then the
|
||||
* plain text field data is what you'll see.
|
||||
*
|
||||
*@internal Wrapper to call pdftk, a shell command, in background.
|
||||
*@param String pdf_file absolute pathname to a pdf form file
|
||||
*@param String fdf_file absolute pathname to a pdf data file
|
||||
*@param String settings
|
||||
*
|
||||
* Output modes 'compress', 'uncompress', 'flatten' ..(see pdftk --help)
|
||||
*@return Array an associative array with two keys:
|
||||
* Boolean success a flag , if positive meaning the process is a success
|
||||
* String return the path to the pdf generated or the error message
|
||||
**/
|
||||
function pdftk($pdf_file,$fdf_file,$settings) {
|
||||
//------------------------------------------
|
||||
|
||||
$descriptorspec = array(
|
||||
0 => array("pipe", "r"), // // stdin
|
||||
1 => array("pipe", "w"), // stdout
|
||||
2 => array("pipe", "w") // stderr
|
||||
);
|
||||
|
||||
$output_modes=$settings['output_modes'];
|
||||
$security=$settings['security'];
|
||||
|
||||
$cwd = '/tmp';
|
||||
$env = array('misc_options' => 'aeiou');
|
||||
$err='';
|
||||
$success=0;
|
||||
|
||||
if(is_windows()) {
|
||||
$cmd="pdftk.exe"; //For windows
|
||||
}else{
|
||||
$cmd="pdftk"; //For linux and mac
|
||||
}
|
||||
|
||||
$dircmd=fix_path(dirname(__file__));
|
||||
|
||||
if(file_exists("$dircmd/$cmd")) {
|
||||
|
||||
$pdf_out=FPDM_CACHE."pdf_flatten.pdf";
|
||||
|
||||
$cmdline="$dircmd/$cmd \"$pdf_file\" fill_form \"$fdf_file\" output \"$pdf_out\" $output_modes $security"; //direct to ouptut
|
||||
|
||||
//echo htmlentities("$cmdline , $descriptorspec, $cwd, $env");
|
||||
|
||||
if(PHP5_ENGINE) { // Php5
|
||||
$process = proc_open($cmdline, $descriptorspec, $pipes, $cwd, $env);
|
||||
}else { //Php4
|
||||
$process = proc_open($cmdline, $descriptorspec, $pipes);
|
||||
}
|
||||
|
||||
if (is_resource($process)) {
|
||||
|
||||
if(PHP5_ENGINE) {
|
||||
$err=stream_get_contents($pipes[2]);
|
||||
}else { //Php4
|
||||
$err= "";
|
||||
while (($str = fgets($pipes[2], 4096))) {
|
||||
$err.= "$str\n";
|
||||
}
|
||||
}
|
||||
|
||||
fclose($pipes[2]);
|
||||
|
||||
//Its important to close the pipes before proc_close call to avoid dead locks
|
||||
$return_value = proc_close($process);
|
||||
|
||||
}else {
|
||||
$err="No more resource to execute the command";
|
||||
}
|
||||
|
||||
}else {
|
||||
$err="Sorry but pdftk binary is not provided / Cette fonctionnalite requiere pdftk non fourni ici<ol>";
|
||||
$err.="<li>download it from / telecharger ce dernier a partir de <br><blockquote><a href=\"http://www.pdflabs.com/docs/install-pdftk/\">pdflabs</a></blockquote>";
|
||||
$err.="<li>copy the executable in this directory / Copier l'executable dans<br><blockquote><b>$dircmd</b></blockquote>" ;
|
||||
$err.="<li>set \$cmd to match binary name in / configurer \$cmd pour qu'il corresponde dans le fichier<br><blockquote><b>".__file__."</b></blockquote></ol>";
|
||||
}
|
||||
|
||||
if($err) {
|
||||
$ret=array("success"=> false,"return"=>$err);
|
||||
}else
|
||||
$ret=array("success"=> true,"return"=>$pdf_out);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
?>
|
454
account/application/third_party/pdf/fpdm/export/pdf/pdftk.txt
vendored
Normal file
454
account/application/third_party/pdf/fpdm/export/pdf/pdftk.txt
vendored
Normal file
@@ -0,0 +1,454 @@
|
||||
|
||||
pdftk 1.43 a Handy Tool for Manipulating PDF Documents
|
||||
Copyright (C) 2003-10, Sid Steward - Please Visit: www.pdftk.com
|
||||
This is free software; see the source code for copying conditions. There is
|
||||
NO warranty, not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
SYNOPSIS
|
||||
pdftk <input PDF files | - | PROMPT>
|
||||
[input_pw <input PDF owner passwords | PROMPT>]
|
||||
[<operation> <operation arguments>]
|
||||
[output <output filename | - | PROMPT>]
|
||||
[encrypt_40bit | encrypt_128bit]
|
||||
[allow <permissions>]
|
||||
[owner_pw <owner password | PROMPT>]
|
||||
[user_pw <user password | PROMPT>]
|
||||
[flatten] [compress | uncompress]
|
||||
[keep_first_id | keep_final_id] [drop_xfa]
|
||||
[verbose] [dont_ask | do_ask]
|
||||
Where:
|
||||
<operation> may be empty, or:
|
||||
[cat | attach_files | unpack_files | burst |
|
||||
fill_form | background | stamp | generate_fdf |
|
||||
multibackground | multistamp |
|
||||
dump_data | dump_data_fields | update_info]
|
||||
|
||||
For Complete Help: pdftk --help
|
||||
|
||||
DESCRIPTION
|
||||
If PDF is electronic paper, then pdftk is an electronic staple-remover,
|
||||
hole-punch, binder, secret-decoder-ring, and X-Ray-glasses. Pdftk is a
|
||||
simple tool for doing everyday things with PDF documents. Use it to:
|
||||
|
||||
* Merge PDF Documents
|
||||
* Split PDF Pages into a New Document
|
||||
* Rotate PDF Documents or Pages
|
||||
* Decrypt Input as Necessary (Password Required)
|
||||
* Encrypt Output as Desired
|
||||
* Fill PDF Forms with X/FDF Data and/or Flatten Forms
|
||||
* Generate FDF Data Stencil from PDF Forms
|
||||
* Apply a Background Watermark or a Foreground Stamp
|
||||
* Report PDF Metrics such as Metadata and Bookmarks
|
||||
* Update PDF Metadata
|
||||
* Attach Files to PDF Pages or the PDF Document
|
||||
* Unpack PDF Attachments
|
||||
* Burst a PDF Document into Single Pages
|
||||
* Uncompress and Re-Compress Page Streams
|
||||
* Repair Corrupted PDF (Where Possible)
|
||||
|
||||
OPTIONS
|
||||
A summary of options is included below.
|
||||
|
||||
--help, -h
|
||||
Show summary of options.
|
||||
|
||||
<input PDF files | - | PROMPT>
|
||||
A list of the input PDF files. If you plan to combine these PDFs
|
||||
(without using handles) then list files in the order you want
|
||||
them combined. Use - to pass a single PDF into pdftk via stdin.
|
||||
Input files can be associated with handles, where a handle is a
|
||||
single, upper-case letter:
|
||||
|
||||
<input PDF handle>=<input PDF filename>
|
||||
|
||||
Handles are often omitted. They are useful when specifying PDF
|
||||
passwords or page ranges, later.
|
||||
|
||||
For example: A=input1.pdf B=input2.pdf
|
||||
|
||||
[input_pw <input PDF owner passwords | PROMPT>]
|
||||
Input PDF owner passwords, if necessary, are associated with
|
||||
files by using their handles:
|
||||
|
||||
<input PDF handle>=<input PDF file owner password>
|
||||
|
||||
If handles are not given, then passwords are associated with
|
||||
input files by order.
|
||||
|
||||
Most pdftk features require that encrypted input PDF are accom-
|
||||
panied by the ~owner~ password. If the input PDF has no owner
|
||||
password, then the user password must be given, instead. If the
|
||||
input PDF has no passwords, then no password should be given.
|
||||
|
||||
When running in do_ask mode, pdftk will prompt you for a pass-
|
||||
word if the supplied password is incorrect or none was given.
|
||||
|
||||
[<operation> <operation arguments>]
|
||||
If this optional argument is omitted, then pdftk runs in 'fil-
|
||||
ter' mode. Filter mode takes only one PDF input and creates a
|
||||
new PDF after applying all of the output options, like encryp-
|
||||
tion and compression.
|
||||
|
||||
Available operations are: cat, attach_files, unpack_files,
|
||||
burst, fill_form, background, stamp, multibackground, multi-
|
||||
stamp, dump_data, dump_data_fields, generate_fdf, update_info.
|
||||
Some operations takes additional arguments, described below.
|
||||
|
||||
cat [<page ranges>]
|
||||
Catenates pages from input PDFs to create a new PDF. Page
|
||||
order in the new PDF is specified by the order of the given
|
||||
page ranges. Page ranges are described like this:
|
||||
|
||||
<input PDF handle>[<begin page number>[-<end page num-
|
||||
ber>[<qualifier>]]][<page rotation>]
|
||||
|
||||
Where the handle identifies one of the input PDF files, and
|
||||
the beginning and ending page numbers are one-based refer-
|
||||
ences to pages in the PDF file, and the qualifier can be even
|
||||
or odd, and the page rotation can be N, S, E, W, L, R, or D.
|
||||
|
||||
If the handle is omitted from the page range, then the pages
|
||||
are taken from the first input PDF.
|
||||
|
||||
The even qualifier causes pdftk to use only the even-numbered
|
||||
PDF pages, so 1-6even yields pages 2, 4 and 6 in that order.
|
||||
6-1even yields pages 6, 4 and 2 in that order.
|
||||
|
||||
The odd qualifier works similarly to the even.
|
||||
|
||||
The page rotation setting can cause pdftk to rotate pages and
|
||||
documents. Each option sets the page rotation as follows (in
|
||||
degrees): N: 0, E: 90, S: 180, W: 270, L: -90, R: +90, D:
|
||||
+180. L, R, and D make relative adjustments to a page's rota-
|
||||
tion.
|
||||
|
||||
If no arguments are passed to cat, then pdftk combines all
|
||||
input PDFs in the order they were given to create the output.
|
||||
|
||||
NOTES:
|
||||
* <end page number> may be less than <begin page number>.
|
||||
* The keyword end may be used to reference the final page of
|
||||
a document instead of a page number.
|
||||
* Reference a single page by omitting the ending page number.
|
||||
* The handle may be used alone to represent the entire PDF
|
||||
document, e.g., B1-end is the same as B.
|
||||
|
||||
Page Range Examples w/o Handles:
|
||||
1-endE - rotate entire document 90 degrees
|
||||
5 11 20
|
||||
5-25oddW - take odd pages in range, rotate 90 degrees
|
||||
6-1
|
||||
|
||||
Page Range Examples Using Handles:
|
||||
Say A=in1.pdf B=in2.pdf, then:
|
||||
A1-21
|
||||
Bend-1odd
|
||||
A72
|
||||
A1-21 Beven A72
|
||||
AW - rotate entire document 90 degrees
|
||||
B
|
||||
A2-30evenL - take the even pages from the range, remove 90
|
||||
degrees from each page's rotation
|
||||
A A
|
||||
AevenW AoddE
|
||||
AW BW BD
|
||||
attach_files <attachment filenames | PROMPT> [to_page <page number |
|
||||
PROMPT>]
|
||||
Packs arbitrary files into a PDF using PDF's file attachment
|
||||
features. More than one attachment may be listed after
|
||||
attach_files. Attachments are added at the document level
|
||||
unless the optional to_page option is given, in which case
|
||||
the files are attached to the given page number (the first
|
||||
page is 1, the final page is end). For example:
|
||||
|
||||
pdftk in.pdf attach_files table1.html table2.html to_page 6
|
||||
output out.pdf
|
||||
|
||||
unpack_files
|
||||
Copies all of the attachments from the input PDF into the
|
||||
current folder or to an output directory given after output.
|
||||
For example:
|
||||
|
||||
pdftk report.pdf unpack_files output ~/atts/
|
||||
|
||||
or, interactively:
|
||||
|
||||
pdftk report.pdf unpack_files output PROMPT
|
||||
|
||||
burst Splits a single, input PDF document into individual pages.
|
||||
Also creates a report named doc_data.txt which is the same as
|
||||
the output from dump_data. If the output section is omitted,
|
||||
then PDF pages are named: pg_%04d.pdf, e.g.: pg_0001.pdf,
|
||||
pg_0002.pdf, etc. To name these pages yourself, supply a
|
||||
printf-styled format string via the output section. For
|
||||
example, if you want pages named: page_01.pdf, page_02.pdf,
|
||||
etc., pass output page_%02d.pdf to pdftk. Encryption can be
|
||||
applied to the output by appending output options such as
|
||||
owner_pw, e.g.:
|
||||
|
||||
pdftk in.pdf burst owner_pw foopass
|
||||
|
||||
fill_form <FDF data filename | XFDF data filename | - | PROMPT>
|
||||
Fills the single input PDF's form fields with the data from
|
||||
an FDF file, XFDF file or stdin. Enter the data filename
|
||||
after fill_form, or use - to pass the data via stdin, like
|
||||
so:
|
||||
|
||||
pdftk form.pdf fill_form data.fdf output form.filled.pdf
|
||||
|
||||
After filling a form, the form fields remain interactive
|
||||
unless you also use the flatten output option. flatten merges
|
||||
the form fields with the PDF pages. You can use flatten
|
||||
alone, too, but only on a single PDF:
|
||||
|
||||
pdftk form.pdf fill_form data.fdf output out.pdf flatten
|
||||
|
||||
or:
|
||||
|
||||
pdftk form.filled.pdf output out.pdf flatten
|
||||
|
||||
If the input FDF file includes Rich Text formatted data in
|
||||
addition to plain text, then the Rich Text data is packed
|
||||
into the form fields as well as the plain text. Pdftk also
|
||||
sets a flag that cues Acrobat/Reader to generate new field
|
||||
appearances based on the Rich Text data. That way, when the
|
||||
user opens the PDF, the viewer will create the Rich Text
|
||||
fields on the spot. If the user's PDF viewer does not sup-
|
||||
port Rich Text, then the user will see the plain text data
|
||||
instead. If you flatten this form before Acrobat has a
|
||||
chance to create (and save) new field appearances, then the
|
||||
plain text field data is what you'll see.
|
||||
|
||||
background <background PDF filename | - | PROMPT>
|
||||
Applies a PDF watermark to the background of a single input
|
||||
PDF. Pass the background PDF's filename after background
|
||||
like so:
|
||||
|
||||
pdftk in.pdf background back.pdf output out.pdf
|
||||
|
||||
Pdftk uses only the first page from the background PDF and
|
||||
applies it to every page of the input PDF. This page is
|
||||
scaled and rotated as needed to fit the input page. You can
|
||||
use - to pass a background PDF into pdftk via stdin.
|
||||
|
||||
If the input PDF does not have a transparent background (such
|
||||
as a PDF created from page scans) then the resulting back-
|
||||
ground won't be visible -- use the stamp feature instead.
|
||||
|
||||
multibackground <background PDF filename | - | PROMPT>
|
||||
Same as the background feature, but applies each page of the
|
||||
background PDF to the corresponding page of the input PDF.
|
||||
If the input PDF has more pages than the stamp PDF, then the
|
||||
final stamp page is repeated across these remaining pages in
|
||||
the input PDF.
|
||||
|
||||
stamp <stamp PDF filename | - | PROMPT>
|
||||
This behaves just like the background feature except it over-
|
||||
lays the stamp PDF page on top of the input PDF document's
|
||||
pages. This works best if the stamp PDF page has a transpar-
|
||||
ent background.
|
||||
|
||||
multistamp <stamp PDF filename | - | PROMPT>
|
||||
Same as the stamp feature, but applies each page of the back-
|
||||
ground PDF to the corresponding page of the input PDF. If
|
||||
the input PDF has more pages than the stamp PDF, then the
|
||||
final stamp page is repeated across these remaining pages in
|
||||
the input PDF.
|
||||
|
||||
dump_data
|
||||
Reads a single, input PDF file and reports various statis-
|
||||
tics, metadata, bookmarks (a/k/a outlines), and page labels
|
||||
to the given output filename or (if no output is given) to
|
||||
stdout. Does not create a new PDF.
|
||||
|
||||
dump_data_fields
|
||||
Reads a single, input PDF file and reports form field statis-
|
||||
tics to the given output filename or (if no output is given)
|
||||
to stdout. Does not create a new PDF.
|
||||
|
||||
generate_fdf
|
||||
Reads a single, input PDF file and generates a FDF file suit-
|
||||
able for fill_form out of it to the given output filename or
|
||||
(if no output is given) to stdout. Does not create a new
|
||||
PDF.
|
||||
|
||||
update_info <info data filename | - | PROMPT>
|
||||
Changes the metadata stored in a single PDF's Info dictionary
|
||||
to match the input data file. The input data file uses the
|
||||
same syntax as the output from dump_data. This does not
|
||||
change the metadata stored in the PDF's XMP stream, if it has
|
||||
one. For example:
|
||||
|
||||
pdftk in.pdf update_info in.info output out.pdf
|
||||
|
||||
[output <output filename | - | PROMPT>]
|
||||
The output PDF filename may not be set to the name of an input
|
||||
filename. Use - to output to stdout. When using the dump_data
|
||||
operation, use output to set the name of the output data file.
|
||||
When using the unpack_files operation, use output to set the
|
||||
name of an output directory. When using the burst operation,
|
||||
you can use output to control the resulting PDF page filenames
|
||||
(described above).
|
||||
|
||||
[encrypt_40bit | encrypt_128bit]
|
||||
If an output PDF user or owner password is given, output PDF
|
||||
encryption strength defaults to 128 bits. This can be overrid-
|
||||
den by specifying encrypt_40bit.
|
||||
|
||||
[allow <permissions>]
|
||||
Permissions are applied to the output PDF only if an encryption
|
||||
strength is specified or an owner or user password is given. If
|
||||
permissions are not specified, they default to 'none,' which
|
||||
means all of the following features are disabled.
|
||||
|
||||
The permissions section may include one or more of the following
|
||||
features:
|
||||
|
||||
Printing
|
||||
Top Quality Printing
|
||||
|
||||
DegradedPrinting
|
||||
Lower Quality Printing
|
||||
|
||||
ModifyContents
|
||||
Also allows Assembly
|
||||
|
||||
Assembly
|
||||
|
||||
CopyContents
|
||||
Also allows ScreenReaders
|
||||
|
||||
ScreenReaders
|
||||
|
||||
ModifyAnnotations
|
||||
Also allows FillIn
|
||||
|
||||
FillIn
|
||||
|
||||
AllFeatures
|
||||
Allows the user to perform all of the above, and top
|
||||
quality printing.
|
||||
|
||||
[owner_pw <owner password | PROMPT>]
|
||||
|
||||
[user_pw <user password | PROMPT>]
|
||||
If an encryption strength is given but no passwords are sup-
|
||||
plied, then the owner and user passwords remain empty, which
|
||||
means that the resulting PDF may be opened and its security
|
||||
parameters altered by anybody.
|
||||
|
||||
[compress | uncompress]
|
||||
These are only useful when you want to edit PDF code in a text
|
||||
editor like vim or emacs. Remove PDF page stream compression by
|
||||
applying the uncompress filter. Use the compress filter to
|
||||
restore compression.
|
||||
|
||||
[flatten]
|
||||
Use this option to merge an input PDF's interactive form fields
|
||||
(and their data) with the PDF's pages. Only one input PDF may be
|
||||
given. Sometimes used with the fill_form operation.
|
||||
|
||||
[keep_first_id | keep_final_id]
|
||||
When combining pages from multiple PDFs, use one of these
|
||||
options to copy the document ID from either the first or final
|
||||
input document into the new output PDF. Otherwise pdftk creates
|
||||
a new document ID for the output PDF. When no operation is
|
||||
given, pdftk always uses the ID from the (single) input PDF.
|
||||
|
||||
[drop_xfa]
|
||||
If your input PDF is a form created using Acrobat 7 or Adobe
|
||||
Designer, then it probably has XFA data. Filling such a form
|
||||
using pdftk yields a PDF with data that fails to display in
|
||||
Acrobat 7 (and 6?). The workaround solution is to remove the
|
||||
form's XFA data, either before you fill the form using pdftk or
|
||||
at the time you fill the form. Using this option causes pdftk to
|
||||
omit the XFA data from the output PDF form.
|
||||
|
||||
This option is only useful when running pdftk on a single input
|
||||
PDF. When assembling a PDF from multiple inputs using pdftk,
|
||||
any XFA data in the input is automatically omitted.
|
||||
|
||||
[verbose]
|
||||
By default, pdftk runs quietly. Append verbose to the end and it
|
||||
will speak up.
|
||||
|
||||
[dont_ask | do_ask]
|
||||
Depending on the compile-time settings (see ASK_ABOUT_WARNINGS),
|
||||
pdftk might prompt you for further input when it encounters a
|
||||
problem, such as a bad password. Override this default behavior
|
||||
by adding dont_ask (so pdftk won't ask you what to do) or do_ask
|
||||
(so pdftk will ask you what to do).
|
||||
|
||||
When running in dont_ask mode, pdftk will over-write files with
|
||||
its output without notice.
|
||||
|
||||
EXAMPLES
|
||||
|
||||
|
||||
Decrypt a PDF
|
||||
pdftk secured.pdf input_pw foopass output unsecured.pdf
|
||||
|
||||
Encrypt a PDF using 128-bit strength (the default), withhold all per-
|
||||
missions (the default)
|
||||
pdftk 1.pdf output 1.128.pdf owner_pw foopass
|
||||
|
||||
Same as above, except password 'baz' must also be used to open output
|
||||
PDF
|
||||
pdftk 1.pdf output 1.128.pdf owner_pw foo user_pw baz
|
||||
|
||||
Same as above, except printing is allowed (once the PDF is open)
|
||||
pdftk 1.pdf output 1.128.pdf owner_pw foo user_pw baz allow printing
|
||||
|
||||
Join in1.pdf and in2.pdf into a new PDF, out1.pdf
|
||||
pdftk in1.pdf in2.pdf cat output out1.pdf
|
||||
or (using handles):
|
||||
pdftk A=in1.pdf B=in2.pdf cat A B output out1.pdf
|
||||
or (using wildcards):
|
||||
pdftk *.pdf cat output combined.pdf
|
||||
|
||||
Remove 'page 13' from in1.pdf to create out1.pdf
|
||||
pdftk in.pdf cat 1-12 14-end output out1.pdf
|
||||
or:
|
||||
pdftk A=in1.pdf cat A1-12 A14-end output out1.pdf
|
||||
|
||||
Apply 40-bit encryption to output, revoking all permissions (the
|
||||
default). Set the owner PW to 'foopass'.
|
||||
pdftk 1.pdf 2.pdf cat output 3.pdf encrypt_40bit owner_pw foopass
|
||||
|
||||
Join two files, one of which requires the password 'foopass'. The out-
|
||||
put is not encrypted.
|
||||
pdftk A=secured.pdf 2.pdf input_pw A=foopass cat output 3.pdf
|
||||
|
||||
Uncompress PDF page streams for editing the PDF in a text editor (e.g.,
|
||||
vim, emacs)
|
||||
pdftk doc.pdf output doc.unc.pdf uncompress
|
||||
|
||||
Repair a PDF's corrupted XREF table and stream lengths, if possible
|
||||
pdftk broken.pdf output fixed.pdf
|
||||
|
||||
Burst a single PDF document into pages and dump its data to
|
||||
doc_data.txt
|
||||
pdftk in.pdf burst
|
||||
|
||||
Burst a single PDF document into encrypted pages. Allow low-quality
|
||||
printing
|
||||
pdftk in.pdf burst owner_pw foopass allow DegradedPrinting
|
||||
|
||||
Write a report on PDF document metadata and bookmarks to report.txt
|
||||
pdftk in.pdf dump_data output report.txt
|
||||
|
||||
Rotate the first PDF page to 90 degrees clockwise
|
||||
pdftk in.pdf cat 1E 2-end output out.pdf
|
||||
|
||||
Rotate an entire PDF document to 180 degrees
|
||||
pdftk in.pdf cat 1-endS output out.pdf
|
||||
|
||||
NOTES
|
||||
The pdftk home page permalink is:
|
||||
http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/
|
||||
The easy-to-remember shortcut is: www.pdftk.com
|
||||
|
||||
AUTHOR
|
||||
Sid Steward (sid.steward at pdflabs dot com) maintains pdftk. Please
|
||||
email him with questions or bug reports. Include pdftk in the subject
|
||||
line to ensure successful delivery. Thank you.
|
12
account/application/third_party/pdf/fpdm/fields.fdf
vendored
Normal file
12
account/application/third_party/pdf/fpdm/fields.fdf
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
%FDF-1.2
|
||||
%<25><><EFBFBD><EFBFBD>
|
||||
1 0 obj
|
||||
<<
|
||||
/FDF <</Fields [<</T (name) /V (My name)>> <</T (address) /V (My address)>> <</T (city) /V (My city)>> <</T (phone) /V (My phone number)>>] /F (template.pdf)>>
|
||||
>>
|
||||
endobj
|
||||
trailer
|
||||
<<
|
||||
/Root 1 0 R
|
||||
>>
|
||||
%%EOF
|
108
account/application/third_party/pdf/fpdm/filters/FilterASCII85.php
vendored
Normal file
108
account/application/third_party/pdf/fpdm/filters/FilterASCII85.php
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
//
|
||||
// FPDI - Version 1.3.4
|
||||
//
|
||||
// Copyright 2004-2010 Setasign - Jan Slabon
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
if (!defined('ORD_z'))
|
||||
define('ORD_z',ord('z'));
|
||||
if (!defined('ORD_exclmark'))
|
||||
define('ORD_exclmark', ord('!'));
|
||||
if (!defined('ORD_u'))
|
||||
define('ORD_u', ord('u'));
|
||||
if (!defined('ORD_tilde'))
|
||||
define('ORD_tilde', ord('~'));
|
||||
|
||||
$__tmp = version_compare(phpversion(), "5") == -1 ? array('FilterASCII85') : array('FilterASCII85', false);
|
||||
if (!call_user_func_array('class_exists', $__tmp)) {
|
||||
|
||||
|
||||
if(isset($FPDM_FILTERS)) array_push($FPDM_FILTERS,"ASCII85Decode");
|
||||
|
||||
|
||||
class FilterASCII85 {
|
||||
|
||||
function error($msg) {
|
||||
die($msg);
|
||||
}
|
||||
|
||||
function decode($in) {
|
||||
$out = '';
|
||||
$state = 0;
|
||||
$chn = null;
|
||||
|
||||
$l = strlen($in);
|
||||
|
||||
for ($k = 0; $k < $l; ++$k) {
|
||||
$ch = ord($in[$k]) & 0xff;
|
||||
|
||||
if ($ch == ORD_tilde) {
|
||||
break;
|
||||
}
|
||||
if (preg_match('/^\s$/',chr($ch))) {
|
||||
continue;
|
||||
}
|
||||
if ($ch == ORD_z && $state == 0) {
|
||||
$out .= chr(0).chr(0).chr(0).chr(0);
|
||||
continue;
|
||||
}
|
||||
if ($ch < ORD_exclmark || $ch > ORD_u) {
|
||||
return $this->error('Illegal character in ASCII85Decode.');
|
||||
}
|
||||
|
||||
$chn[$state++] = $ch - ORD_exclmark;
|
||||
|
||||
if ($state == 5) {
|
||||
$state = 0;
|
||||
$r = 0;
|
||||
for ($j = 0; $j < 5; ++$j)
|
||||
$r = $r * 85 + $chn[$j];
|
||||
$out .= chr($r >> 24);
|
||||
$out .= chr($r >> 16);
|
||||
$out .= chr($r >> 8);
|
||||
$out .= chr($r);
|
||||
}
|
||||
}
|
||||
$r = 0;
|
||||
|
||||
if ($state == 1)
|
||||
return $this->error('Illegal length in ASCII85Decode.');
|
||||
if ($state == 2) {
|
||||
$r = $chn[0] * 85 * 85 * 85 * 85 + ($chn[1]+1) * 85 * 85 * 85;
|
||||
$out .= chr($r >> 24);
|
||||
}
|
||||
else if ($state == 3) {
|
||||
$r = $chn[0] * 85 * 85 * 85 * 85 + $chn[1] * 85 * 85 * 85 + ($chn[2]+1) * 85 * 85;
|
||||
$out .= chr($r >> 24);
|
||||
$out .= chr($r >> 16);
|
||||
}
|
||||
else if ($state == 4) {
|
||||
$r = $chn[0] * 85 * 85 * 85 * 85 + $chn[1] * 85 * 85 * 85 + $chn[2] * 85 * 85 + ($chn[3]+1) * 85 ;
|
||||
$out .= chr($r >> 24);
|
||||
$out .= chr($r >> 16);
|
||||
$out .= chr($r >> 8);
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
function encode($in) {
|
||||
return $this->error("ASCII85 encoding not implemented.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($__tmp);
|
65
account/application/third_party/pdf/fpdm/filters/FilterASCIIHex.php
vendored
Normal file
65
account/application/third_party/pdf/fpdm/filters/FilterASCIIHex.php
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
//
|
||||
// FPDM - Filter ASCII Hex
|
||||
// NOTE: Not tested but should work.
|
||||
//
|
||||
|
||||
if(isset($FPDM_FILTERS)) array_push($FPDM_FILTERS,"ASCIIHexDecode");
|
||||
|
||||
class FilterASCIIHex {
|
||||
|
||||
|
||||
/**
|
||||
*Get a binary string from its hexadecimal representation
|
||||
*
|
||||
*@internal same as _hex2bin ($hexString)
|
||||
*@access public
|
||||
*@note Function was written because PHP has a bin2hex, but not a hex2bin!
|
||||
*@internal note pack(<28>C<EFBFBD>,hexdec(substr($data,$i,2))) DOES NOT WORK
|
||||
*
|
||||
**/
|
||||
function decode($data) {
|
||||
|
||||
$hexString=$data;
|
||||
$BinStr = '';
|
||||
|
||||
$hexLength=strlen($hexString);
|
||||
// only hex numbers is allowed
|
||||
if ($hexLength % 2 != 0 || preg_match("/[^\da-fA-F]/",$hexString)) return FALSE;
|
||||
|
||||
|
||||
//Loop through the input and convert it
|
||||
for ($i = 0; $i < $hexLength; $i += 2)
|
||||
$BinStr .= '%'.substr ($hexString, $i, 2);
|
||||
|
||||
|
||||
// Raw url-decode and return the result
|
||||
return rawurldecode ($BinStr);//chr(hexdec())
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*Encodes a binary string to its hexadecimal representation
|
||||
*
|
||||
*@internal same as bin2hex
|
||||
*@access public
|
||||
*@internal dechex(ord($str{$i})); is buggy because for hex value of 0-15 heading 0 is missing! Using sprintf() to get it right.
|
||||
*@param string $str a binary string
|
||||
*@return string hex the hexified string
|
||||
**/
|
||||
function encode($data) {
|
||||
//----------------------
|
||||
$str=$data;
|
||||
$hex = "";
|
||||
$i = 0;
|
||||
do {
|
||||
$hex .= sprintf("%02x", ord($str[$i]));
|
||||
$i++;
|
||||
} while ($i < strlen($str));
|
||||
return $hex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
49
account/application/third_party/pdf/fpdm/filters/FilterFlate.php
vendored
Normal file
49
account/application/third_party/pdf/fpdm/filters/FilterFlate.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
//
|
||||
// FPDM - Filter Flate
|
||||
// NOTE: requires ZLIB >= 1.0.9!
|
||||
//
|
||||
|
||||
$__tmp = version_compare(phpversion(), "5") == -1 ? array('FilterFlateDecode') : array('FilterFlateDecode', false);
|
||||
if (!call_user_func_array('class_exists', $__tmp)) {
|
||||
|
||||
|
||||
if(isset($FPDM_FILTERS)) array_push($FPDM_FILTERS,"FlateDecode");
|
||||
|
||||
class FilterFlate {
|
||||
|
||||
var $data = null;
|
||||
var $dataLength = 0;
|
||||
|
||||
function error($msg) {
|
||||
die($msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to decode GZIP compressed data.
|
||||
*
|
||||
* @param string data The compressed data.
|
||||
* @return uncompressed data
|
||||
*/
|
||||
function decode($data) {
|
||||
|
||||
$this->data = $data;
|
||||
$this->dataLength = strlen($data);
|
||||
|
||||
// uncompress
|
||||
$data=gzuncompress($data);
|
||||
|
||||
if(!$data) $this->error("FilterFlateDecode: invalid stream data.");
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
function encode($in) {
|
||||
return gzcompress($in, 9);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//unset $__tmp;
|
||||
?>
|
162
account/application/third_party/pdf/fpdm/filters/FilterLZW.php
vendored
Normal file
162
account/application/third_party/pdf/fpdm/filters/FilterLZW.php
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
//
|
||||
// FPDI - Version 1.3.4
|
||||
//
|
||||
// Copyright 2004-2010 Setasign - Jan Slabon
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
$__tmp = version_compare(phpversion(), "5") == -1 ? array('FilterLZW') : array('FilterLZW', false);
|
||||
if (!call_user_func_array('class_exists', $__tmp)) {
|
||||
|
||||
if(isset($FPDM_FILTERS)) array_push($FPDM_FILTERS,"LZWDecode");
|
||||
|
||||
class FilterLZW {
|
||||
|
||||
var $sTable = array();
|
||||
var $data = null;
|
||||
var $dataLength = 0;
|
||||
var $tIdx;
|
||||
var $bitsToGet = 9;
|
||||
var $bytePointer;
|
||||
var $bitPointer;
|
||||
var $nextData = 0;
|
||||
var $nextBits = 0;
|
||||
var $andTable = array(511, 1023, 2047, 4095);
|
||||
|
||||
function error($msg) {
|
||||
die($msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to decode LZW compressed data.
|
||||
*
|
||||
* @param string data The compressed data.
|
||||
*/
|
||||
function decode($data) {
|
||||
|
||||
if($data[0] == 0x00 && $data[1] == 0x01) {
|
||||
$this->error('LZW flavour not supported.');
|
||||
}
|
||||
|
||||
$this->initsTable();
|
||||
|
||||
$this->data = $data;
|
||||
$this->dataLength = strlen($data);
|
||||
|
||||
// Initialize pointers
|
||||
$this->bytePointer = 0;
|
||||
$this->bitPointer = 0;
|
||||
|
||||
$this->nextData = 0;
|
||||
$this->nextBits = 0;
|
||||
|
||||
$oldCode = 0;
|
||||
|
||||
$string = '';
|
||||
$uncompData = '';
|
||||
|
||||
while (($code = $this->getNextCode()) != 257) {
|
||||
if ($code == 256) {
|
||||
$this->initsTable();
|
||||
$code = $this->getNextCode();
|
||||
|
||||
if ($code == 257) {
|
||||
break;
|
||||
}
|
||||
|
||||
$uncompData .= $this->sTable[$code];
|
||||
$oldCode = $code;
|
||||
|
||||
} else {
|
||||
|
||||
if ($code < $this->tIdx) {
|
||||
$string = $this->sTable[$code];
|
||||
$uncompData .= $string;
|
||||
|
||||
$this->addStringToTable($this->sTable[$oldCode], $string[0]);
|
||||
$oldCode = $code;
|
||||
} else {
|
||||
$string = $this->sTable[$oldCode];
|
||||
$string = $string.$string[0];
|
||||
$uncompData .= $string;
|
||||
|
||||
$this->addStringToTable($string);
|
||||
$oldCode = $code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $uncompData;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the string table.
|
||||
*/
|
||||
function initsTable() {
|
||||
$this->sTable = array();
|
||||
|
||||
for ($i = 0; $i < 256; $i++)
|
||||
$this->sTable[$i] = chr($i);
|
||||
|
||||
$this->tIdx = 258;
|
||||
$this->bitsToGet = 9;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new string to the string table.
|
||||
*/
|
||||
function addStringToTable ($oldString, $newString='') {
|
||||
$string = $oldString.$newString;
|
||||
|
||||
// Add this new String to the table
|
||||
$this->sTable[$this->tIdx++] = $string;
|
||||
|
||||
if ($this->tIdx == 511) {
|
||||
$this->bitsToGet = 10;
|
||||
} else if ($this->tIdx == 1023) {
|
||||
$this->bitsToGet = 11;
|
||||
} else if ($this->tIdx == 2047) {
|
||||
$this->bitsToGet = 12;
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the next 9, 10, 11 or 12 bits
|
||||
function getNextCode() {
|
||||
if ($this->bytePointer == $this->dataLength) {
|
||||
return 257;
|
||||
}
|
||||
|
||||
$this->nextData = ($this->nextData << 8) | (ord($this->data[$this->bytePointer++]) & 0xff);
|
||||
$this->nextBits += 8;
|
||||
|
||||
if ($this->nextBits < $this->bitsToGet) {
|
||||
$this->nextData = ($this->nextData << 8) | (ord($this->data[$this->bytePointer++]) & 0xff);
|
||||
$this->nextBits += 8;
|
||||
}
|
||||
|
||||
$code = ($this->nextData >> ($this->nextBits - $this->bitsToGet)) & $this->andTable[$this->bitsToGet-9];
|
||||
$this->nextBits -= $this->bitsToGet;
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
function encode($in) {
|
||||
$this->error("LZW encoding not implemented.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($__tmp);
|
20
account/application/third_party/pdf/fpdm/filters/FilterStandard.php
vendored
Normal file
20
account/application/third_party/pdf/fpdm/filters/FilterStandard.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
//
|
||||
// FPDM - Filter Standard
|
||||
// NOTE: dummy filter for unfiltered streams!
|
||||
//
|
||||
|
||||
if(isset($FPDM_FILTERS)) array_push($FPDM_FILTERS,"Standard");
|
||||
|
||||
class FilterStandard {
|
||||
|
||||
function decode($data) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
function encode($data) {
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
?>
|
2234
account/application/third_party/pdf/fpdm/fpdm.php
vendored
Normal file
2234
account/application/third_party/pdf/fpdm/fpdm.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
184
account/application/third_party/pdf/fpdm/lib/url.php
vendored
Normal file
184
account/application/third_party/pdf/fpdm/lib/url.php
vendored
Normal file
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
|
||||
/****************************************************************
|
||||
*@file url.php
|
||||
*@name Url manipulation toolbox
|
||||
*@internal Useful functions to deal with URLs
|
||||
*@package URL_TOOLBOX
|
||||
*@date 2010-10-27
|
||||
*@author 0livier
|
||||
*@version 1.0
|
||||
*@note
|
||||
* V1.0 (27.10.2010) First release
|
||||
******************************************************************/
|
||||
|
||||
if (!defined('URL_TOOLBOX')) {
|
||||
|
||||
|
||||
function getScheme(/*$port is optional*/) {
|
||||
//---------------------------------------
|
||||
$numargs = func_num_args();
|
||||
$port=($numargs >0) ? func_get_arg(0) : $_SERVER["SERVER_PORT"];
|
||||
$schemes=array(
|
||||
'http'=> 80,// default for http
|
||||
'https'=> 443, // default for https
|
||||
'ftp' => 21, // default for ftp
|
||||
'ftps'=> 990 // default for ftps
|
||||
);
|
||||
$ports=array_flip($schemes);
|
||||
return (array_key_exists($port,$ports)) ? $ports[$port] : 0;
|
||||
}
|
||||
|
||||
function getHost() {
|
||||
//------------------
|
||||
return $_SERVER["HTTP_HOST"];// [SERVER_NAME]
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('fix_path')) {
|
||||
// fixes windows paths...
|
||||
// (windows accepts forward slashes and backwards slashes, so why does PHP use backwards?
|
||||
function fix_path($path) {
|
||||
//-------------------------
|
||||
return str_replace('\\','/',$path);
|
||||
}
|
||||
}
|
||||
|
||||
function getWebDir($local_dir) {
|
||||
//----------------------------
|
||||
$local_root=$_SERVER["DOCUMENT_ROOT"];
|
||||
$server_dir=str_replace($local_root,'',$local_dir);
|
||||
return $server_dir;
|
||||
}
|
||||
|
||||
//Local dir may be:
|
||||
// the main script dir: dirname($_SERVER['PHP_SELF'])
|
||||
// the current script dir fix_path(dirname(__FILE__))
|
||||
//return the full url with ending /
|
||||
function getUrlfromDir($local_dir) {
|
||||
//-------------------------------
|
||||
$server_dir=getWebDir($local_dir);
|
||||
$server_scheme=getScheme();
|
||||
$server_host=getHost();
|
||||
return "{$server_scheme}://{$server_host}/$server_dir";
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiles url out of array of it's pieces
|
||||
* 'query' is ignored if 'query_params' is present
|
||||
*
|
||||
* @param Array $aUrl Array of url pieces
|
||||
*/
|
||||
function build_url($aUrl) {
|
||||
//-------------------------
|
||||
//[scheme]://[user]:[pass]@[host]/[path]?[query]#[fragment]
|
||||
|
||||
if (!is_array($aUrl)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
$sQuery = '';
|
||||
|
||||
// Compile query
|
||||
if (isset($aUrl['query_params']) && is_array($aUrl['query_params'])) {
|
||||
$aPairs = array();
|
||||
foreach ($aUrl['query_params'] as $sKey=>$sValue) {
|
||||
$aPairs[] = $sKey.'='.urlencode($sValue);
|
||||
}
|
||||
$sQuery = implode('&', $aPairs);
|
||||
} else {
|
||||
if(isset($aUrl['query'])) $sQuery = $aUrl['query'];
|
||||
}
|
||||
|
||||
// Compile url
|
||||
$sUrl =
|
||||
$aUrl['scheme'] . '://' . (
|
||||
isset($aUrl['user']) && $aUrl['user'] != '' && isset($aUrl['pass'])
|
||||
? $aUrl['user'] . ':' . $aUrl['pass'] . '@'
|
||||
: ''
|
||||
) .
|
||||
$aUrl['host'] . (
|
||||
isset($aUrl['path']) && $aUrl['path'] != ''
|
||||
? $aUrl['path']
|
||||
: ''
|
||||
) . (
|
||||
$sQuery != ''
|
||||
? '?' . $sQuery
|
||||
: ''
|
||||
) . (
|
||||
isset($aUrl['fragment']) && $aUrl['fragment'] != ''
|
||||
? '#' . $aUrl['fragment']
|
||||
: ''
|
||||
);
|
||||
return $sUrl;
|
||||
}
|
||||
|
||||
function resolve_url($relative_url) {
|
||||
//-----------------------------
|
||||
$url=parse_url($relative_url);
|
||||
$url["path"]=resolve_path($url["path"]); //fix this
|
||||
$absolute_url=build_url($url);
|
||||
return $absolute_url;
|
||||
}
|
||||
|
||||
|
||||
//Get realpath without checking existence of file like php function does..
|
||||
function resolve_path($path) {
|
||||
//----------------------------------
|
||||
$out=array();
|
||||
foreach(explode('/', $path) as $i=>$fold){
|
||||
if ($fold=='' || $fold=='.') continue;
|
||||
if ($fold=='..' && $i>0 && end($out)!='..') array_pop($out);
|
||||
else $out[]= $fold;
|
||||
} return ($path{0}=='/'?'/':'').join('/', $out);
|
||||
}
|
||||
|
||||
|
||||
//This part is from http://fr2.php.net/manual/en/function.parse-url.php
|
||||
function j_parseUrl($url) {
|
||||
//--------------------------
|
||||
$r = "(?:([a-z0-9+-._]+)://)?";
|
||||
$r .= "(?:";
|
||||
$r .= "(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9a-f]{2})*)@)?";
|
||||
$r .= "(?:\[((?:[a-z0-9:])*)\])?";
|
||||
$r .= "((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9a-f]{2})*)";
|
||||
$r .= "(?::(\d*))?";
|
||||
$r .= "(/(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9a-f]{2})*)?";
|
||||
$r .= "|";
|
||||
$r .= "(/?";
|
||||
$r .= "(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+";
|
||||
$r .= "(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9a-f]{2})*";
|
||||
$r .= ")?";
|
||||
$r .= ")";
|
||||
$r .= "(?:\?((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9a-f]{2})*))?";
|
||||
$r .= "(?:#((?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9a-f]{2})*))?";
|
||||
preg_match("`$r`i", $url, $match);
|
||||
$parts = array(
|
||||
"scheme"=>'',
|
||||
"userinfo"=>'',
|
||||
"authority"=>'',
|
||||
"host"=> '',
|
||||
"port"=>'',
|
||||
"path"=>'',
|
||||
"query"=>'',
|
||||
"fragment"=>'');
|
||||
switch (count ($match)) {
|
||||
case 10: $parts['fragment'] = $match[9];
|
||||
case 9: $parts['query'] = $match[8];
|
||||
case 8: $parts['path'] = $match[7];
|
||||
case 7: $parts['path'] = $match[6] . $parts['path'];
|
||||
case 6: $parts['port'] = $match[5];
|
||||
case 5: $parts['host'] = $match[3]?"[".$match[3]."]":$match[4];
|
||||
case 4: $parts['userinfo'] = $match[2];
|
||||
case 3: $parts['scheme'] = $match[1];
|
||||
}
|
||||
$parts['authority'] = ($parts['userinfo']?$parts['userinfo']."@":"").
|
||||
$parts['host'].
|
||||
($parts['port']?":".$parts['port']:"");
|
||||
return $parts;
|
||||
}
|
||||
|
||||
define('URL_TOOLBOX',1);
|
||||
|
||||
}//End of URL_TOOLBOX
|
||||
?>
|
BIN
account/application/third_party/pdf/fpdm/template.pdf
vendored
Normal file
BIN
account/application/third_party/pdf/fpdm/template.pdf
vendored
Normal file
Binary file not shown.
Reference in New Issue
Block a user