dqitk20644 2015-12-14 12:52
浏览 71

TCPDF打印格式化文本

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
  • 写回答

1条回答 默认 最新

  • dongxie3681 2015-12-14 13:38
    关注

    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>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么