从HTML ::模板转换为PDF:Fromhtml说无效的XML



i使用html ::模板创建一个HTML文件。结果代码是有效的XML/HTML(对XML验证器检查)。但是,当使用pdf :: Fromhtml转换为PDF时,找到了" XML文件中无效令牌"的消息。

尝试将第一条声明线从Doctype更改为XML,或者替代,但无济于事。XML :: Simple,PDF:API2,XML :: Writer是最后版本。

我想法发生了什么?

# create template object and store to verify
   shout('s',"create template from $str_filepath") if ($bool_DEBUG);
    $str_mytemplate =  HTML::Template->new(filename => $str_filepath, case_sensitive => 0, no_includes => 1  ); 
    $str_mytemplate->param(%strct_toreplace);
    $str_filepath =  envDir('temp').newID().'.html'; 
    shout('',"template created, storing to : $str_filepath") if ($bool_DEBUG);
    if (open(FILE, '>', $str_filepath)) {
        print FILE $str_mytemplate->output;
        close (FILE);
        }
# generate pdf from created file
    shout('p',"Creating PDF ") if ($bool_DEBUG);
    $pdf_this = PDF::FromHTML->new( encoding => 'utf-8' ); 
    $pdf_this->load_file($str_filepath); 
    $pdf_this->convert( LineHeight => 10, Landscape => 1, PageSize => 'Letter', );    
    shout('p',"Display PDF") if ($bool_DEBUG);  
    print header(-type=>'application/pdf', -charset=>'UTF-8'); 
    print $pdf_this->write_file();
  • $ bool_debug and shout();是调试模式时设置和显示消息的变量和过程。
  • 通过模板生成的html代码:http://www.etoxica.com/examplecode.html
  • 使用的模板:http://www.etoxica.com/exampletemplate.tmpl
  • 显示的消息:

部分:创建PDF软件错误:在第19行,第13列,Byte 430 at/usr/local/lib64/perl5/xml/parser.pm第187行中的第19行,第13列,第13列,字节430列(无效)。 at/home/grupo/perl/usr/share/perl5/pdf/fromhtml.pm 141。

摘要:找到问题(我猜);)

考虑以下行:

<td>
    Some line of data
    <br/>
    A second line of data
</td>

尝试通过pdf :: fromhtml读取时,它将在第五行中发送一条畸形令牌的消息,特别是在 </td> tag的slash'/'上。但是,这不是问题,问题是由<td></td>中的<br/>标签创建的。

如果将其更改为<br><br />找不到错误。我不知道使用<br>是否是XML合并性的良好练习,即使是W3C BR语义的定义。

最新更新