当前位置: 首页>>代码示例>>PHP>>正文


PHP pdf::set_pdf方法代码示例

本文整理汇总了PHP中pdf::set_pdf方法的典型用法代码示例。如果您正苦于以下问题:PHP pdf::set_pdf方法的具体用法?PHP pdf::set_pdf怎么用?PHP pdf::set_pdf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pdf的用法示例。


在下文中一共展示了pdf::set_pdf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generate_feedback_document

 /**
  * This function takes the combined pdf and embeds all the comments and annotations.
  * @param int|\assign $assignment
  * @param int $userid
  * @param int $attemptnumber (-1 means latest attempt)
  * @return stored_file
  */
 public static function generate_feedback_document($assignment, $userid, $attemptnumber)
 {
     $assignment = self::get_assignment_from_param($assignment);
     if (!$assignment->can_view_submission($userid)) {
         \print_error('nopermission');
     }
     if (!$assignment->can_grade()) {
         \print_error('nopermission');
     }
     // Need to generate the page images - first get a combined pdf.
     $file = self::get_combined_pdf_for_attempt($assignment, $userid, $attemptnumber);
     if (!$file) {
         throw new \moodle_exception('Could not generate combined pdf.');
     }
     $tmpdir = \make_temp_directory('assignfeedback_editpdf/final/' . self::hash($assignment, $userid, $attemptnumber));
     $combined = $tmpdir . '/' . self::COMBINED_PDF_FILENAME;
     $file->copy_content_to($combined);
     // Copy the file.
     $pdf = new pdf();
     $fs = \get_file_storage();
     $stamptmpdir = \make_temp_directory('assignfeedback_editpdf/stamps/' . self::hash($assignment, $userid, $attemptnumber));
     $grade = $assignment->get_user_grade($userid, true, $attemptnumber);
     // Copy any new stamps to this instance.
     if ($files = $fs->get_area_files($assignment->get_context()->id, 'assignfeedback_editpdf', 'stamps', $grade->id, "filename", false)) {
         foreach ($files as $file) {
             $filename = $stamptmpdir . '/' . $file->get_filename();
             $file->copy_content_to($filename);
             // Copy the file.
         }
     }
     $pagecount = $pdf->set_pdf($combined);
     $grade = $assignment->get_user_grade($userid, true, $attemptnumber);
     page_editor::release_drafts($grade->id);
     for ($i = 0; $i < $pagecount; $i++) {
         $pdf->copy_page();
         $comments = page_editor::get_comments($grade->id, $i, false);
         $annotations = page_editor::get_annotations($grade->id, $i, false);
         foreach ($comments as $comment) {
             $pdf->add_comment($comment->rawtext, $comment->x, $comment->y, $comment->width, $comment->colour);
         }
         foreach ($annotations as $annotation) {
             $pdf->add_annotation($annotation->x, $annotation->y, $annotation->endx, $annotation->endy, $annotation->colour, $annotation->type, $annotation->path, $stamptmpdir);
         }
     }
     fulldelete($stamptmpdir);
     $filename = self::get_downloadable_feedback_filename($assignment, $userid, $attemptnumber);
     $filename = clean_param($filename, PARAM_FILE);
     $generatedpdf = $tmpdir . '/' . $filename;
     $pdf->save_pdf($generatedpdf);
     $record = new \stdClass();
     $record->contextid = $assignment->get_context()->id;
     $record->component = 'assignfeedback_editpdf';
     $record->filearea = self::FINAL_PDF_FILEAREA;
     $record->itemid = $grade->id;
     $record->filepath = '/';
     $record->filename = $filename;
     // Only keep one current version of the generated pdf.
     $fs->delete_area_files($record->contextid, $record->component, $record->filearea, $record->itemid);
     $file = $fs->create_file_from_pathname($record, $generatedpdf);
     // Cleanup.
     @unlink($generatedpdf);
     @unlink($combined);
     @rmdir($tmpdir);
     return $file;
 }
开发者ID:covex-nn,项目名称:moodle,代码行数:72,代码来源:document_services.php

示例2: test_gs_path

 /**
  * Test that the configured path to ghostscript is correct and working.
  * @param bool $generateimage - If true - a test image will be generated to verify the install.
  * @return bool
  */
 public static function test_gs_path($generateimage = true)
 {
     global $CFG;
     $ret = (object) array('status' => self::GSPATH_OK, 'message' => null);
     $gspath = \get_config('assignfeedback_editpdf', 'gspath');
     if (empty($gspath)) {
         $ret->status = self::GSPATH_EMPTY;
         return $ret;
     }
     if (!file_exists($gspath)) {
         $ret->status = self::GSPATH_DOESNOTEXIST;
         return $ret;
     }
     if (is_dir($gspath)) {
         $ret->status = self::GSPATH_ISDIR;
         return $ret;
     }
     if (!is_executable($gspath)) {
         $ret->status = self::GSPATH_NOTEXECUTABLE;
         return $ret;
     }
     $testfile = $CFG->dirroot . '/mod/assign/feedback/editpdf/tests/fixtures/testgs.pdf';
     if (!file_exists($testfile)) {
         $ret->status = self::GSPATH_NOTESTFILE;
         return $ret;
     }
     if (!$generateimage) {
         return $ret;
     }
     $testimagefolder = \make_temp_directory('assignfeedback_editpdf_test');
     @unlink($testimagefolder . '/image_page0.png');
     // Delete any previous test images.
     $pdf = new pdf();
     $pdf->set_pdf($testfile);
     $pdf->set_image_folder($testimagefolder);
     try {
         $pdf->get_image(0);
     } catch (\moodle_exception $e) {
         $ret->status = self::GSPATH_ERROR;
         $ret->message = $e->getMessage();
     }
     return $ret;
 }
开发者ID:covex-nn,项目名称:moodle,代码行数:48,代码来源:pdf.php


注:本文中的pdf::set_pdf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。