Library code for manipulating PDFs.
More...
|
| add_annotation ($sx, $sy, $ex, $ey, $colour='yellow', $type='line', $path, $imagefolder) |
| Add an annotation to the current page. More...
|
|
| add_comment ($text, $x, $y, $width, $colour='yellow') |
| Add a comment to the current page. More...
|
|
| add_comment_marker ($pageno, $index, $x, $y, $link, $colour='yellow') |
| Add a comment marker to the specified page. More...
|
|
| add_image_page ($imagestoredfile) |
| This function add an image file to PDF page. More...
|
|
| append_comments ($allcomments) |
| Append all comments to the end of the document. More...
|
|
| combine_pdfs ($pdflist, $outfilename) |
| Combine the given PDF files into a single PDF. More...
|
|
| copy_page () |
| Copy the next page from the source file and set it as the current page. More...
|
|
| copy_remaining_pages () |
| Copy all the remaining pages in the file.
|
|
| current_page () |
| The number of the current page in the PDF being processed. More...
|
|
| get_image ($pageno) |
| Generate an image of the specified page in the PDF. More...
|
|
| load_pdf ($filename) |
| Load the specified PDF and set the initial output configuration Used when processing comments and outputting a new PDF. More...
|
|
| page_count () |
| The total number of pages in the PDF being processed. More...
|
|
| save_pdf ($filename) |
| Save the completed PDF to the given file. More...
|
|
| set_image_folder ($folder) |
| Set the path to the folder in which to generate page image files. More...
|
|
| set_pdf ($filename, $pagecount=0) |
| Sets the name of the PDF to process, but only loads the file if the pagecount is zero (in order to count the number of pages) Used when generating page images (but not a new PDF) More...
|
|
|
static | ensure_pdf_compatible (\stored_file $file) |
| Check to see if PDF is version 1.4 (or below); if not: use ghostscript to convert it. More...
|
|
static | ensure_pdf_file_compatible ($tempsrc) |
| Check to see if PDF is version 1.4 (or below); if not: use ghostscript to convert it. More...
|
|
static | get_error_image ($errorimagefolder, $pageno) |
| Generate an localised error image for the given pagenumber. More...
|
|
static | send_test_image () |
| If the test image has been generated correctly - send it direct to the browser.
|
|
static | test_gs_path ($generateimage=true) |
| Test that the configured path to ghostscript is correct and working. More...
|
|
|
const | BLANK_PDF = '/mod/assign/feedback/editpdf/fixtures/blank.pdf' |
| Blank PDF file used during error.
|
|
const | GSPATH_DOESNOTEXIST = 'doesnotexist' |
| Does not exist.
|
|
const | GSPATH_EMPTY = 'empty' |
| Not set.
|
|
const | GSPATH_ERROR = 'error' |
| Any other error.
|
|
const | GSPATH_ISDIR = 'isdir' |
| Is a dir.
|
|
const | GSPATH_NOTESTFILE = 'notestfile' |
| Test file missing.
|
|
const | GSPATH_NOTEXECUTABLE = 'notexecutable' |
| Not executable.
|
|
const | GSPATH_OK = 'ok' |
| No errors.
|
|
const | IMAGE_PAGE = 'image_page' |
| Page image file name prefix.
|
|
const | MIN_ANNOTATION_HEIGHT = 5 |
| Min. More...
|
|
const | MIN_ANNOTATION_WIDTH = 5 |
| Min. More...
|
|
|
int | $currentpage = 0 |
| the number of the current page in the PDF being processed
|
|
string | $filename = null |
| the path to the PDF currently being processed
|
|
string | $imagefolder = null |
| the path in which to store generated page images
|
|
int | $pagecount = 0 |
| the total number of pages in the PDF being processed
|
|
float | $scale = 0.0 |
| used to scale the pixel position of annotations (in the database) to the position in the final PDF
|
|
Library code for manipulating PDFs.
- Copyright
- 2012 Davo Smith
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
◆ add_annotation()
assignfeedback_editpdf\pdf::add_annotation |
( |
|
$sx, |
|
|
|
$sy, |
|
|
|
$ex, |
|
|
|
$ey, |
|
|
|
$colour = 'yellow' , |
|
|
|
$type = 'line' , |
|
|
|
$path, |
|
|
|
$imagefolder |
|
) |
| |
Add an annotation to the current page.
- Parameters
-
int | $sx | starting x-coordinate (in pixels) |
int | $sy | starting y-coordinate (in pixels) |
int | $ex | ending x-coordinate (in pixels) |
int | $ey | ending y-coordinate (in pixels) |
string | $colour | optional the colour of the annotation (red, yellow, green, blue, white, black) |
string | $type | optional the type of annotation (line, oval, rectangle, highlight, pen, stamp) |
int[] | string | $path | optional for 'pen' annotations this is an array of x and y coordinates for the line, for 'stamp' annotations it is the name of the stamp file (without the path) |
string | $imagefolder | - Folder containing stamp images. |
- Return values
-
bool | true if successful (always) |
◆ add_comment()
assignfeedback_editpdf\pdf::add_comment |
( |
|
$text, |
|
|
|
$x, |
|
|
|
$y, |
|
|
|
$width, |
|
|
|
$colour = 'yellow' |
|
) |
| |
Add a comment to the current page.
- Parameters
-
string | $text | the text of the comment |
int | $x | the x-coordinate of the comment (in pixels) |
int | $y | the y-coordinate of the comment (in pixels) |
int | $width | the width of the comment (in pixels) |
string | $colour | optional the background colour of the comment (red, yellow, green, blue, white, clear) |
- Return values
-
bool | true if successful (always) |
◆ add_comment_marker()
assignfeedback_editpdf\pdf::add_comment_marker |
( |
|
$pageno, |
|
|
|
$index, |
|
|
|
$x, |
|
|
|
$y, |
|
|
|
$link, |
|
|
|
$colour = 'yellow' |
|
) |
| |
Add a comment marker to the specified page.
- Parameters
-
int | $pageno | The page number to add markers to (starting at 0). |
int | $index | The comment index. |
int | $x | The x-coordinate of the marker (in pixels). |
int | $y | The y-coordinate of the marker (in pixels). |
int | $link | The link identifier pointing to the full comment text. |
string | $colour | The fill colour of the marker (red, yellow, green, blue, white, clear). |
- Return values
-
◆ add_image_page()
assignfeedback_editpdf\pdf::add_image_page |
( |
|
$imagestoredfile | ) |
|
This function add an image file to PDF page.
- Parameters
-
◆ append_comments()
assignfeedback_editpdf\pdf::append_comments |
( |
|
$allcomments | ) |
|
Append all comments to the end of the document.
- Parameters
-
array | $allcomments | All comments, indexed by page number (starting at 0). |
- Return values
-
array|bool | An array of links to comments, or false. |
◆ combine_pdfs()
assignfeedback_editpdf\pdf::combine_pdfs |
( |
|
$pdflist, |
|
|
|
$outfilename |
|
) |
| |
Combine the given PDF files into a single PDF.
Optionally add a coversheet and coversheet fields.
- Parameters
-
string[] | $pdflist | the filenames of the files to combine |
string | $outfilename | the filename to write to |
- Return values
-
int | the number of pages in the combined PDF |
◆ copy_page()
assignfeedback_editpdf\pdf::copy_page |
( |
| ) |
|
Copy the next page from the source file and set it as the current page.
- Return values
-
◆ create_page_from_source()
assignfeedback_editpdf\pdf::create_page_from_source |
( |
|
$pageno | ) |
|
|
protected |
Create a page from a source PDF.
- Parameters
-
◆ current_page()
assignfeedback_editpdf\pdf::current_page |
( |
| ) |
|
The number of the current page in the PDF being processed.
- Return values
-
◆ ensure_pdf_compatible()
static assignfeedback_editpdf\pdf::ensure_pdf_compatible |
( |
\stored_file |
$file | ) |
|
|
static |
Check to see if PDF is version 1.4 (or below); if not: use ghostscript to convert it.
- Parameters
-
- Return values
-
string | path to copy or converted pdf (false == fail) |
◆ ensure_pdf_file_compatible()
static assignfeedback_editpdf\pdf::ensure_pdf_file_compatible |
( |
|
$tempsrc | ) |
|
|
static |
Check to see if PDF is version 1.4 (or below); if not: use ghostscript to convert it.
- Parameters
-
string | $tempsrc | The path to the file on disk. |
- Return values
-
string | path to copy or converted pdf (false == fail) |
◆ get_error_image()
static assignfeedback_editpdf\pdf::get_error_image |
( |
|
$errorimagefolder, |
|
|
|
$pageno |
|
) |
| |
|
static |
Generate an localised error image for the given pagenumber.
- Parameters
-
string | $errorimagefolder | path of the folder where error image needs to be created. |
int | $pageno | page number for which error image needs to be created. |
- Return values
-
- Exceptions
-
◆ get_image()
assignfeedback_editpdf\pdf::get_image |
( |
|
$pageno | ) |
|
Generate an image of the specified page in the PDF.
- Parameters
-
int | $pageno | the page to generate the image of |
- Exceptions
-
- Return values
-
string | the filename of the generated image |
◆ load_pdf()
assignfeedback_editpdf\pdf::load_pdf |
( |
|
$filename | ) |
|
Load the specified PDF and set the initial output configuration Used when processing comments and outputting a new PDF.
- Parameters
-
string | $filename | the path to the PDF to load |
- Return values
-
int | the number of pages in the PDF |
◆ page_count()
assignfeedback_editpdf\pdf::page_count |
( |
| ) |
|
The total number of pages in the PDF being processed.
- Return values
-
◆ save_pdf()
assignfeedback_editpdf\pdf::save_pdf |
( |
|
$filename | ) |
|
Save the completed PDF to the given file.
- Parameters
-
string | $filename | the filename for the PDF (including the full path) |
◆ set_image_folder()
assignfeedback_editpdf\pdf::set_image_folder |
( |
|
$folder | ) |
|
Set the path to the folder in which to generate page image files.
- Parameters
-
◆ set_pdf()
assignfeedback_editpdf\pdf::set_pdf |
( |
|
$filename, |
|
|
|
$pagecount = 0 |
|
) |
| |
Sets the name of the PDF to process, but only loads the file if the pagecount is zero (in order to count the number of pages) Used when generating page images (but not a new PDF)
- Parameters
-
string | $filename | the path to the PDF to process |
int | $pagecount | optional the number of pages in the PDF, if known |
- Return values
-
int | the number of pages in the PDF |
◆ test_gs_path()
static assignfeedback_editpdf\pdf::test_gs_path |
( |
|
$generateimage = true | ) |
|
|
static |
Test that the configured path to ghostscript is correct and working.
- Parameters
-
bool | $generateimage | - If true - a test image will be generated to verify the install. |
- Return values
-
◆ MIN_ANNOTATION_HEIGHT
const assignfeedback_editpdf\pdf::MIN_ANNOTATION_HEIGHT = 5 |
Min.
height an annotation should have
◆ MIN_ANNOTATION_WIDTH
const assignfeedback_editpdf\pdf::MIN_ANNOTATION_WIDTH = 5 |
Min.
width an annotation should have
The documentation for this class was generated from the following file:
- mod/assign/feedback/editpdf/classes/pdf.php