OpenTBS/php 输出问题

OpenTBS/php problems with output

我正在 LAMP 服务器上编写一个 php 应用程序,它获取一个文档 (.odt) 并在适当的位置用正确的信息填充它。当代码编译时,它在一页上显示 header 的打印件,在另一页上显示一连串明显的乱码,如下所示:

''mimetypeapplication/vnd.oasis.opendocument.textPK?H?1?aoThumbnails/thumbnail.png#PNG IHDR?g?rxIDATx9???﾿?ᄃrҩ?Kヨヒ\䆻ᄆ ᄊ?l?R ᄂ )?トト?jᄄ&lc {??ٲz ??yovg?6?z=yoovvv?3y?R0B#4tD~?y+yF 5BCL#r! 1y@jyF 5BCL#j!jH??jL?Dī? j?BrD?~??HgKQPWJ?v?>oLR+?쟰.shi?w???shi8Q???。??8&r/ゥ?Ć??a?8 /Whin?,tthiP[tthi캁?Is .!??.7?BN?没有?0\r%ya>? }?!4?'0?5z?xL?x?x^?4?G(#fi??+?<4ロ?ロᄚ<???ラz??ᆬロ?Dワxk゙??Fa'フŜ -4ᄚg\ミ6z^°??y?y

我怀疑这可能是编码问题,我尝试了不同的方法,但到目前为止没有任何效果。我没有太多运气在网上寻找类似的情况,所以任何 suggestions/recommendations/help 将不胜感激

<?php 

session_start(); 
include 'conn.php'; 

if(empty($_SESSION['username']) || empty($_SESSION['password'])) 
    print("Access to database denied"); 
else { 
    $username = $_SESSION['username']; 
    $password = $_SESSION['password']; 
    $type = $_SESSION['type']; 

    if($type == "admin") { 
        include '../includes/aheader.html'; 
    } 
    if($type == "user") { 
        include '../includes/uheader.html'; 
    } 
    if(isset($_POST["searchButton"])) { 
        print_r($_POST);
        $keyword = $_POST['keyword']; 
        $choice = $_POST['choice'];

    if($choice == "company_name") 
        $sql = $mysqli -> prepare("SELECT * FROM clients WHERE company_name LIKE ?"); 

    if($choice == "project_code") 
        $sql = $mysqli -> prepare("SELECT * FROM clients WHERE project_code LIKE ?"); 

    $keyword = '%'.$keyword.'%'; 
    $sql -> bind_param('s', $keyword); 
    $sql -> execute(); 
    $result = $sql -> get_result(); 

        if(!$result) 
            print("<p>Select query failed</p>"); 
        else { 
            if($result -> num_rows == 0) 
            print("<p>No match found</p>");

        else {
            while($row = mysqli_fetch_array($result)) {
                $company_name = $row['0'];
                $phone = $row['1'];
                $address = $row['2'];
                $approximate_employees = $row['3'];
                $project_code = $row['4'];
                extract($row);
            }

            include_once('tbs_class.php');
            include_once('tbs_plugin_opentbs.php');

            $TBS = new clsTinyButStrong;
            $TBS -> Plugin(TBS_INSTALL, OPENTBS_PLUGIN);

            $TBS -> LoadTemplate('document.odt');
            $TBS -> Show(OPENTBS_FILE, 'document.odt');             

            $TBS -> MergeField('company_name', $company_name);
            $TBS -> MergeField('address', $address);
            $TBS -> MergeField('phone', $phone);

        }
    }
}
    else {
        include '../includes/searchForm.html';
        include '../includes/footer.html';
    }
}
$mysqli -> close();

?>

您必须先合并字段才能呈现结果。 并且结果必须是与模板不同的文件。

        $TBS = new clsTinyButStrong;
        $TBS -> Plugin(TBS_INSTALL, OPENTBS_PLUGIN);

        // Load the template
        $TBS -> LoadTemplate('document.odt');

        // Merge fields
        $TBS -> MergeField('company_name', $company_name);
        $TBS -> MergeField('address', $address);
        $TBS -> MergeField('phone', $phone);

        // Render the result
        $TBS -> Show(OPENTBS_FILE, 'document_result.odt');