简体   繁体   中英

TCPDF print formatted text

I added print function for the course information in Moodle . Using the TCPDF library and javascript , it prints the following from the $description variable :

Course Visibility and Sorting Instructors The «courses» will be sorted first by availability (courses that have been made available to students will show up first followed by courses not available to students), then by semester. For example, if you are teaching a course in the current semester and it is available to students, it will appear at the top of your course listing. If you are teaching a course in the current semester and it is not available to students, it will appear after all the courses that are available to students.
Students first year students second year students post graduate

Note, that «courses» comes with the original formating in the pdf !

Here is the code I use in printpdf.php :

$html = '<html>
<body>
<img src="/moodle/theme/base/pix/logo.png" alt="test alt attribute" border="0" height="100" width="220" allign="left" /><br />
<p><span style="font-size: small;"><font color="#######">Organisation name<br><b>Directorate <br><b>Department </b><br>Subdepartment</font></span></p>
<h2>Course Information</h2>
<h3>'. $title . '</h3><br />
'. $description . '<br />
</body>
</html>';

$pdf->writeHTML($html, true, false, true, false, '');

$pdf->lastPage();
$pdf->Output('CourseInfo.pdf', 'D');

Is it possible, to print it in the original format as on the page with $description :

Course Visibility and Sorting

Instructors: The «courses» will be sorted first by availability (courses that have been made available to students will show up first followed by courses not available to students), then by semester. For example, if you are teaching a course in the current semester and it is available to students, it will appear at the top of your course listing. If you are teaching a course in the current semester and it is not available to students, it will appear after all the courses that are available to students.

Students:

  • first year students
  • second year students
  • post graduate

you can change the $description variable that you are passing to printpdf.php in a html way.

<h2>Course Visibility and Sorting</h2>

 <p>Instructors: The «courses» will be sorted first by availability (courses     
that have been made available to students will show up first followed by courses     
not available to students), then by semester. For example, if you are teaching a     
course in the current semester and it is available to students, it will 
appear at the top of your course listing. If you are teaching a course in      
the current semester and it is not available to students, it will appear 
after all the courses that are available to students. </p>

<h2>Students:</h2>
<br>

first year students<br>
second year students<br>
post graduate<br>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM