It looks like you're new here. If you want to get involved, click one of these buttons!
else {
$pdf->Output('Invoice.pdf','D'); //added file name to make it work in IE, also forces the download giving the user the option to save
exit();
}
elseif($purpose == 'webservice')
{
global $PDFBuffer;
$log->debug("Switched to buffer. Purpose = ". $purpose);
$PDFBuffer = $pdf->Output('','S'); // S means send the pdf output in buffer instead of file
}
else
{
$pdf->Output('Invoice.pdf','D'); //added file name to make it work in IE, also forces the download giving the user the option to save
exit();
}
Step3 (if you use CRM-NOW PDF Configurator)else {
createpdffile ($_REQUEST[record],'print');
}
byelse
{
if ($purpose != "webservice"){$purpose = "print";}
createpdffile ($_REQUEST[record], $purpose);
}
elseif($purpose == 'webservice')
{
global $PDFBuffer;
$log->debug("Switched to buffer. Purpose = ". $purpose);
$PDFBuffer = $pdf->Output('','S'); // S means send the pdf output in buffer instead of file
}
function display($documentid) //documentid in ws format
{
$returndata = getPDF($documentid);
if(is_array($returndata) && ! empty($returndata))
{
$pdf_data = base64_decode($returndata['0']['pdf_data']);
send_to_browser($pdf_data);
}
else
{
$message = "We currently have a problem. Please retry later.";
}
}
function getPDF($documentid)
{
if($this->vtlogin == false)
{
return false;
}
$response = $this->vtclient->doInvoke('getpdfdata', array('id' => $documentid), 'POST');
if($response)
{
$return_value = $response;
}
else
{
$wasError= $this->vtclient->lastError();
if($wasError)
{
echo "<br>". $wasError['code'] . ':' . $wasError['message'] . "<br>"; //TODO remove after debug
}
$return_value = false;
}
return $return_value;
}
function send_to_browser($pdf_data)
{
//Header('Content-Type: application/pdf');
//header('Content-Disposition: attachment; filename="invoice.pdf"');
// fix for IE catching or PHP bug issue
header("Pragma: public");
header("Expires: 0"); // set expiration time
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
// browser must download file from server instead of cache
// force download dialog
header("Content-Type: application/force-download");
Header('Content-Type: application/pdf');
header("Content-Type: application/download");
// use the Content-Disposition header to supply a recommended filename and
// force the browser to display the save dialog.
header('Content-Disposition: attachment; filename="invoice.pdf"');
/*
The Content-transfer-encoding header should be binary, since the file will be read
directly from the disk and the raw bytes passed to the downloading computer.
The Content-length header is useful to set for downloads. The browser will be able to
show a progress meter as a file downloads. The content-lenght can be determines by
filesize function returns the size of a file.
*/
header("Content-Transfer-Encoding: binary");
//Header('Content-Length: '.filesize($f));
echo $pdf_data;
exit;
}
Comments
thanks for the pointing out to the typo, i have re-upload the documentation with the fix. the download can be reached as pointed at vtwsclib - 1.4 released
<!-- s;-) --><img src="{smilies_path}/icon_wink.gif" alt=";-)" title="wink" /><!-- s;-) -->
thanks
david v.
now it contains getpdfdata.php
thanks to kimbo and to winifred for pointing out the missing file.
does anyone know how to modifiy the original post to reflect this change ?
david v.
no problem for pointing out the missing file.
in the meanwhile i was able to cook up my own webservice getpdfdata.php file, which i added as attachment.
please note that this is only a quick workaround, and not really intended for real usage ( but it works <!-- s;-) --><img src="{smilies_path}/icon_wink.gif" alt=";-)" title="wink" /><!-- s;-) --> with a small modification to the display_pdf method (it returns the pdf-data string instead of a result array...) )
kind regards,
kim
i wonder inf you can help, i'm on the verg of frustration, can even achive a simple login. any assistence would be extremely appreciated.
i used wamp server, this way i have apache, mysql and php configured and running. i used the add on php 5.2.9 for compatibility reasons (you know more than i do that vtiger does not work under php 5.3.0)
i installed vtiger 5.1.0 by using source files, enabled php_curl extension, installed pear http_client and zendframework-1.6.1-minimal, i wonder what am i missing, because when i tried a simple login, only "login failed" shows. prassad suggest me to give a try vtwsbrowser-1.0, and it does not work even if i use <!-- m --><a class="postlink" href="http://en.vtiger.com">http://en.vtiger.com</a><!-- m --> params, it just not connect. i extract it to root folder at wamp (www) nothing. i hope you can help me.
i cant see the attachment..
any ideas why?
http://corebos.org/development/view.php?id=124
and see it working in the "test code" here:
https://github.com/tsolucio/coreboswsdevelopment