Php TCPDF打印格式化文本

Php TCPDF打印格式化文本,php,html,pdf,moodle,Php,Html,Pdf,Moodle,我在Moodle中为课程信息添加了print功能。使用TCPDF库和javascript,它从$description变量打印以下内容: 课程可见性和分类 “课程”的讲师将首先按可用性排序(已提供给学生的课程将首先显示,然后是不提供给学生的课程),然后按学期排序。例如,如果您在本学期教授一门课程,并且该课程可供学生使用,则该课程将显示在课程列表的顶部。如果您在本学期教授一门课程,但该课程不提供给学生,则该课程将出现在所有可提供给学生的课程之后。 学生一年级学生二年级学生研究生 请注意,«课程»附

我在
Moodle
中为
课程
信息
添加了
print
功能。使用
TCPDF
javascript
,它从
$description
变量
打印以下内容:

课程可见性和分类 “课程”的讲师将首先按可用性排序(已提供给学生的课程将首先显示,然后是不提供给学生的课程),然后按学期排序。例如,如果您在本学期教授一门课程,并且该课程可供学生使用,则该课程将显示在课程列表的顶部。如果您在本学期教授一门课程,但该课程不提供给学生,则该课程将出现在所有可提供给学生的课程之后。
学生一年级学生二年级学生研究生

请注意,
«课程»
附带了
pdf
中的原始格式

以下是我在
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');
$html='1!'

机构名称
董事会
部门
下属部门

课程信息 “.$title。”
“.$description。”
'; $pdf->writeHTML($html,true,false,true,false,”); $pdf->lastPage(); $pdf->Output('CourseInfo.pdf','D');
是否可以按
$description
页面上的原始格式打印:

课程可见性和排序

讲师:将首先按可用性对«课程»进行排序(提供给学生的课程将首先显示,然后是不提供给学生的课程),然后按学期进行排序。例如,如果您在本学期教授一门课程,并且该课程可供学生使用,则该课程将显示在课程列表的顶部。如果您在本学期教授一门课程,但该课程不提供给学生,则该课程将显示在所有可提供给学生的课程之后

学生:

  • 一年级学生
  • 二年级学生
  • 研究生

您可以更改以html方式传递到
printpdf.php
$description
变量

<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>
课程可见性和排序
讲师:«课程»将首先按可用性(课程)排序
提供给学生的课程将首先出现,然后是课程
不适用于学生),然后按学期计算。例如,如果您正在教授
本学期的课程,并可供学生使用
出现在课程列表的顶部。如果你正在用英语教授一门课程
如果当前学期不提供给学生,则会出现
在学生可以参加的所有课程之后

学生:
一年级学生
二年级学生
研究生

它是用户生成的文本,每次通过不同格式的html传递变量。我使用了
$pdf->MultiCell(0,0,$description.”,0,'J',0,0,','',true)
并至少获得了文本的不同对齐方式。我缺少的是诸如项目符号等字符。请使用php函数
str_replace()
将项目符号替换为tcpdf允许的内容。