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


PHP Pdf::createPdf方法代码示例

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


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

示例1: postProcess


//.........这里部分代码省略.........
                             if ($mask->getCorrect() === '1' && !$foundInStudentsAnswer) {
                                 $allcorrect = false;
                                 break;
                             } elseif ($mask->getCorrect() === '0' && $foundInStudentsAnswer) {
                                 $allcorrect = false;
                                 break;
                             }
                         }
                     }
                     if ($allcorrect) {
                         $points = $pro->getExercise()->getMaxPoints();
                     }
                     // save the marking
                     #region Form to PDF
                     if ($pro->getMarking() === null) {
                         $raw = $pro->getRawSubmission();
                         $exerciseName = '';
                         if ($raw !== null) {
                             $exerciseName = $raw->getExerciseName();
                         }
                         $answer = "";
                         if ($forms->getType() == 0) {
                             $answer = $formdata->getChoices()[0]->getText();
                         }
                         if ($forms->getType() == 1) {
                             $answer = $this->ChoiceIdToText($formdata->getChoices()[0]->getText(), $forms->getChoices());
                         }
                         if ($forms->getType() == 2) {
                             foreach ($formdata->getChoices() as $chosen) {
                                 $answer .= $this->ChoiceIdToText($chosen->getText(), $forms->getChoices()) . '<br>';
                             }
                         }
                         $answer2 = "";
                         foreach ($forms->getChoices() as $chosen) {
                             if ($chosen->getCorrect() === '1') {
                                 $answer2 .= $chosen->getText() . '<br>';
                             }
                         }
                         $Text = "<h1>AUFGABE {$exerciseName}</h1>" . "<hr>";
                         if ($forms->getTask() !== null && trim($forms->getTask()) != '') {
                             $Text .= "<p>" . "<h2>Aufgabenstellung:</h2>" . $forms->getTask() . "</p>";
                         }
                         $Text .= "<p>" . "<h2>Antwort:</h2>" . "<span style=\"color: " . ($points === 0 ? 'red' : 'black') . "\">" . $answer . "</span></p>";
                         if ($points === 0) {
                             $Text .= "<p>" . "<h2>L&ouml;sung:</h2><span style=\"color: green\">" . $answer2 . "</span></p>";
                         }
                         if ($forms->getSolution() !== null && trim($forms->getSolution()) != '') {
                             $Text .= "<p>" . "<h2>L&ouml;sungsbegr&uuml;ndung:</h2>" . $forms->getSolution() . "</p>";
                         }
                         $Text .= "<p style=\"text-align: center;\">" . "<h2><span style=\"color: red\">{$points}P</span></h2>" . "</p>";
                         $pdf = Pdf::createPdf($Text);
                         //echo Pdf::encodePdf($pdf);return;
                         $result = Request::routeRequest('POST', '/pdf', array(), Pdf::encodePdf($pdf), $this->_pdf, 'pdf');
                         // checks the correctness of the query
                         if ($result['status'] >= 200 && $result['status'] <= 299) {
                             $pdf = File::decodeFile($result['content']);
                             $pdf->setDisplayName($exerciseName . '.pdf');
                             $pdf->setTimeStamp($timestamp);
                             $pdf->setBody(null);
                             $submission = $pro->getSubmission();
                             if ($submission === null) {
                                 $submission = $pro->getRawSubmission();
                             }
                             $studentId = $pro->getRawSubmission() !== null ? $pro->getRawSubmission()->getStudentId() : null;
                             if ($studentId === null) {
                                 $studentId = $pro->getSubmission() !== null ? $pro->getSubmission()->getStudentId() : null;
                             }
                             $marking = Marking::createMarking(null, $studentId, null, null, null, null, 3, $points, $submission->getDate() !== null ? $submission->getDate() : time());
                             if (is_object($submission)) {
                                 $marking->setSubmission(clone $submission);
                             }
                             $marking->setFile($pdf);
                             $pro->setMarking($marking);
                         } else {
                             $res[] = null;
                             $this->app->response->setStatus(409);
                             continue;
                         }
                     }
                     #endregion
                     $rawSubmission = $pro->getRawSubmission();
                     $rawFile = $rawSubmission->getFile();
                     $rawFile->setBody(Form::encodeForm($formdata), true);
                     $rawSubmission->setFile($rawFile);
                     $rawSubmission->setExerciseId($eid);
                     $pro->setRawSubmission($rawSubmission);
                     $res[] = $pro;
                     continue;
                 }
             }
         }
         $this->app->response->setStatus(409);
         $res[] = null;
     }
     if (!$arr && count($res) == 1) {
         $this->app->response->setBody(Process::encodeProcess($res[0]));
     } else {
         $this->app->response->setBody(Process::encodeProcess($res));
     }
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:101,代码来源:LFormProcessor.php

示例2: foreach

            if ($key == 0) {
                $text .= '<tr style="font-weight: bold;">';
            } else {
                $text .= '<tr>';
            }
            foreach ($row as $r) {
                $text .= '<td>' . $r . '</td>';
            }
            if ($key == 0) {
                $text .= '</tr>';
            } else {
                $text .= '</tr>';
            }
        }
        $text .= '</table>';
        $pdf = Pdf::createPdf($text, 'L');
        $file = http_post_data($filesystemURI . '/pdf', Pdf::encodePdf($pdf), true);
        $file = File::decodeFile($file);
        $file->setDisplayName('conditions.pdf');
        $file = File::encodeFile($file);
    } elseif (isset($_GET['downloadConditionCsv'])) {
        $csv = Csv::createCsv($rows);
        $file = http_post_data($filesystemURI . '/csv', Csv::encodeCsv($csv), true);
        $file = File::decodeFile($file);
        $file->setDisplayName('conditions.csv');
        $file = File::encodeFile($file);
    }
    echo $file;
    exit(0);
}
if (isset($_GET['sortby'])) {
开发者ID:sawh,项目名称:ostepu-system,代码行数:31,代码来源:Condition.php

示例3: postProcess


//.........这里部分代码省略.........
                                         while ($i < count($parameter)) {
                                             if (@preg_match($test, DefaultNormalizer::normalizeText($choice->getText())) !== false) {
                                                 break;
                                             }
                                             $test .= ' ' . $parameter[$i];
                                             $i++;
                                         }
                                         $match = @preg_match($test, DefaultNormalizer::normalizeText($choice->getText()));
                                         if ($match === false) {
                                             $fail = true;
                                             $pro->addMessage('"' . $test . '" ist kein gültiger regulärer Ausdruck.');
                                         } elseif ($match == false) {
                                             $fail = true;
                                             $pro->addMessage('"' . $choice->getText() . '" entspricht nicht dem regulären Ausdruck "' . $test . '".');
                                         }
                                         break;
                                 }
                             }
                         }
                     }
                     if ($fail) {
                         // received submission isn't correct
                         $pro->setStatus(409);
                         $res[] = $pro;
                         $this->app->response->setStatus(409);
                         continue;
                     }
                     // save the submission
                     #region Form to PDF
                     if ($pro->getSubmission() === null) {
                         $raw = $pro->getRawSubmission();
                         $exerciseName = '';
                         if ($raw !== null) {
                             $exerciseName = $raw->getExerciseName();
                         }
                         $answer = "";
                         if ($forms->getType() == 0) {
                             $answer = $formdata->getChoices()[0]->getText();
                         }
                         if ($forms->getType() == 1) {
                             $answer = $this->ChoiceIdToText($formdata->getChoices()[0]->getText(), $forms->getChoices());
                         }
                         if ($forms->getType() == 2) {
                             foreach ($formdata->getChoices() as $chosen) {
                                 $answer .= $this->ChoiceIdToText($chosen->getText(), $forms->getChoices()) . '<br>';
                             }
                         }
                         $Text = "<h1>AUFGABE {$exerciseName}</h1>" . "<hr>";
                         if ($forms->getTask() !== null && trim($forms->getTask()) != '') {
                             $Text .= "<p>" . "<h2>Aufgabenstellung:</h2>" . $forms->getTask() . "</p>";
                         }
                         $Text .= "<p>" . "<h2>Antwort:</h2>" . $answer . "</p>";
                         $pdf = Pdf::createPdf($Text);
                         $pdf->setText($Text);
                         //echo Pdf::encodePdf($pdf);return;
                         $result = Request::routeRequest('POST', '/pdf', array(), Pdf::encodePdf($pdf), $this->_pdf, 'pdf');
                         // checks the correctness of the query
                         if ($result['status'] >= 200 && $result['status'] <= 299) {
                             $pdf = File::decodeFile($result['content']);
                             $pdf->setDisplayName($exerciseName . '.pdf');
                             $pdf->setTimeStamp($timestamp);
                             $pdf->setBody(null);
                             if (is_object($pro->getRawSubmission())) {
                                 $submission = clone $pro->getRawSubmission();
                             } else {
                                 $submission = new Submission();
                             }
                             $submission->setFile($pdf);
                             $submission->setExerciseId($eid);
                             $pro->setSubmission($submission);
                         } else {
                             $pro->setStatus(409);
                             $res[] = $pro;
                             $this->app->response->setStatus(409);
                             continue;
                         }
                     }
                     #endregion
                     $rawSubmission = $pro->getRawSubmission();
                     $rawFile = $rawSubmission->getFile();
                     $rawFile->setBody(Form::encodeForm($formdata), true);
                     $rawSubmission->setFile($rawFile);
                     $rawSubmission->setExerciseId($eid);
                     $pro->setRawSubmission($rawSubmission);
                     $pro->setStatus(201);
                     $res[] = $pro;
                     continue;
                 }
             }
         }
         $this->app->response->setStatus(409);
         $pro->setStatus(409);
         $res[] = $pro;
     }
     if (!$arr && count($res) == 1) {
         $this->app->response->setBody(Process::encodeProcess($res[0]));
     } else {
         $this->app->response->setBody(Process::encodeProcess($res));
     }
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:101,代码来源:LFormPredecessor.php


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