dpfl37651 2018-11-14 16:31
浏览 103
已采纳

Firebird pdf blob由PHP保存为pdf文件

I have a blob which we receive from a Firebird 3.0 database.

if($dbh = ibase_connect($db,$username,$password, 'UTF-8')){
echo "Connecton steht zur Firebird DB steht! <br>";
$sql = "SELECT MEMO FROM DMS where ID = '44'";
// Execute query
$rc = ibase_query($dbh, $sql);
// Get the result row by row as object
$data = ibase_fetch_object($rc);
$blob_data = ibase_blob_info($data->MEMO);
$blob_hndl = ibase_blob_open($data->MEMO);

$inhalt = ibase_blob_get($blob_hndl, $blob_data[0]);

With

ibase_blob_echo($data->MEMO)

there comes a lot of signs in browser, so the SQL query works. Now I'd like to write the content (its a PDF) in a pdf file on disk.

Every try didn't succeed:

file_put_contents('test.pdf', $inhalt);
file_put_contents('test.pdf', ibase_blob_echo($data->MEMO));

and much more.

When we try to open the PDF File with Acrobat Reader, there comes an error message: no PDF File / File-type is not supported

How can we fix this?

  • 写回答

1条回答 默认 最新

  • doufang3001 2018-11-15 10:28
    关注

    thank you for your answers ... We interpreted them in a way, that the code above is basicly correct. After a while, we found out, that the error apears because we changed the charset in the DB Connect to UTF8 for the varchar Fields. For the blob we connect now without Charset change and the readout work properly. Thank you again.

    $dbh = ibase_connect($db,$username,$password)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 系统 24h2 专业工作站版,浏览文件夹的图库,视频,图片之类的怎样删除?
  • ¥15 怎么把512还原为520格式
  • ¥15 MATLAB的动态模态分解出现错误,以CFX非定常模拟结果为快照
  • ¥15 求高通平台Softsim调试经验
  • ¥15 canal如何实现将mysql多张表(月表)采集入库到目标表中(一张表)?
  • ¥15 wpf ScrollViewer实现冻结左侧宽度w范围内的视图
  • ¥15 栅极驱动低侧烧毁MOSFET
  • ¥30 写segy数据时出错3
  • ¥100 linux下qt运行QCefView demo报错
  • ¥50 F1C100S下的红外解码IR_RX驱动问题