drt3751 2014-07-09 13:41
浏览 39

PDF二进制ZF2

I am trying to get a PDF from binaries. My old code is working, but now that I'm using ZF2, the PDF seems to be corrupted and I'm not sure why.

Old code

echo $html->link($zvk,array('controller'=>'daten', 'action'=>'download',$id,$zvk),array('escape' => false)); 

Action

header('Content-Disposition: attachment; filename=doc_' . $zvk . '.pdf');
header("Cache-control: private");
header("Content-transfer-encoding: binary");
header("Content-type: application/pdf;");
header('Content-length: ' . strlen($binary));
echo $binary;

ZF2 Code

// Disable layout and view
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);

// Generate PDF filename
$sFilename = sprintf("doc(%s, %s) - %s.pdf",
            $oSelectedP->name,
            $oSelectedZ->Zvk,
            date("Y-m-d"));

$this->getResponse()
->setHeader("Content-type", "application/pdf")
->setHeader("Content-disposition", "attachment; filename=\"" . $sFilename . "\"")
->setHeader("Content-length", strlen($aData[0]["dokument"]))
->setHeader("Cache-control", "private")
->setHeader("Content-transfer-encoding", "binary")
->setBody($aData[0]["dokument"]);

I dont get any error messages, just the corrupted file. Any suggestions?

Checking the corrupted PDF give this

Open file. 0x80410108 - E - The end-of-file marker was not found. - File: C:\Windows\TEMP\tmpCB04.tmp 0x8041010A - E - The 'startxref' keyword or the xref position was not found. - File: C:\Windows\TEMP\tmpCB04.tmp 0x80410108 - E - The end-of-file marker was not found. - File: C:\Windows\TEMP\tmpCB04.tmp Close file.

But I do not know how to set those. I did not have to do this in the first way, so i would guess it is part of the binaries.

  • 写回答

1条回答 默认 最新

  • dongxiaofa6359 2014-07-10 07:51
    关注

    I had to "SET TEXTSIZE 167772160" in the MSSQL DB. But I am not sure why. Id would be nice, if someone could explain this to me.

    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100