News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Problem printing invoice as pdf via backend: opens as text in browser

Started by pceend, May 21, 2015, 00:46:41 AM

Previous topic - Next topic

pceend

Hi all,

I upgraded VM 2 to version 2.6.14 and now I have a problem with printing the invoices of orders to PDF in the backend of the system. The weird thing is that the PDF files are created in the Invoice folder and when the I donwload them I can open them without problems. But when opening in the backend they will open as text in the browser. This is the same for all browsers. When I use fidler to see the HTTP headers of the page it seems to be not right. When I look in the invoice controler file I do see that the hearder is set correctly before opening the file.

controler code:    if (file_exists ($fileLocation)) {            
            $maxSpeed = 200;
            $range = 0;
            $size = filesize ($fileLocation);
            $contentType = 'application/pdf';
            header ("Cache-Control: public");
            header ("Content-Transfer-Encoding: binary\n");
            header ('Content-Type: application/pdf');
            $contentDisposition = 'attachment';
            $agent = strtolower ($_SERVER['HTTP_USER_AGENT']);

            if (strpos ($agent, 'msie') !== FALSE) {
               $fileName = preg_replace ('/\./', '%2e', $fileName, substr_count ($fileName, '.') - 1);
            }

Network mon output:

Response hearders:
Connection:Keep-Alive
Content-Encoding:gzip
Content-Type:text/html
Date:Wed, 20 May 2015 22:38:19 GMT
Keep-Alive:timeout=5, max=99
Server:Apache
Transfer-Encoding:chunked
Vary:Accept-Encoding

Request Headers:
view source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch
Accept-Language:nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Cookie:0b8e04c7d90b88a21a129e1ebbfd6d74=df11054e1388935c7522915aa41db098; 6e0ec35a8285fbe397669cc1c96474de=05a76e80d0019b7025b7917ca23bca66; accordeon=1; vmapply=0; __utma=236877826.166070460.1368222364.1430378029.1432067709.12; __utmc=236877826; __utmz=236877826.1429126579.3.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); jpanesliders_sef-info-pane=1; jpanesliders_panel-sliders=0
Host:www.2brothersrc.com
Referer:http://www.2brothersrc.com/index.php?option=com_virtuemart&view=invoice&layout=deliverynote&format=pdf&tmpl=component&virtuemart_order_id=683&order_number=48fd0388&order_pass=p_934ec
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.152 Safari/537.36
Query String Parameters
view source
view URL encoded
option:com_virtuemart
view:invoice
layout:deliverynote
format:pdf
tmpl:component
virtuemart_order_id:683
order_number:48fd0388
order_pass:p_934ec

Has anyone seen this before? It feels like there is an additional redirect somewhere.  I spend way to much time on this already :)

Kind regards,

Jorrit