• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Apache and pdfs

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    #11
    Post the php here, I'm sure NF or similar here will spot the problem in no time.

    Comment


      #12
      Originally posted by DimPrawn View Post
      Post the php here, I'm sure NF or similar here will spot the problem in no time.
      Hokeydokes. I shan't post all the php code, only the relevant bit.

      Our good friend pdf.php executes Print.php (I know follow how it all links together after some reading through the code)

      Print.php renders the pdf like this

      Code:
      $pdf->Output("Invoice.pdf", "I");
      Where $pdf is an instance of the Invoice class. The two arguments here are the name of the document to create, and the second argument is to do with the Content-Type.

      The pertinent bit in the Output method of the invoice class looks like this
      Code:
      switch($dest)
      
      	{
      
      		case 'I':
      
      			//Send to standard output
      			if(isset($HTTP_SERVER_VARS['SERVER_NAME']))
      			//if (true)
      
      			{
      
      				//We send to a browser
      
      				Header('Content-Type: application/pdf');
      
      				if(headers_sent())
      
      					$this->Error('Some data has already been output to browser, can\'t send PDF file');
      
      				Header('Content-Length: '.strlen($this->buffer));
      
      				Header('Content-disposition: inline; filename='.$name);
      
      			}
      
      			echo $this->buffer;
      
      			break;
      So we know the flag is set to "I" so the only thing that can stop this branch from working is if

      Code:
      if(isset($HTTP_SERVER_VARS['SERVER_NAME']))
      is returning false.

      This document explaining what $HTTP_SERVER_VARS actually is makes me nervous

      $HTTP_SERVER_VARS [deprecated]

      $_SERVER -- $HTTP_SERVER_VARS [deprecated] — Server and execution environment information
      Report a bug
      Description

      $_SERVER is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server. There is no guarantee that every web server will provide any of these; servers may omit some, or provide others not listed here. That said, a large number of these variables are accounted for in the » CGI/1.1 specification, so you should be able to expect those.

      $HTTP_SERVER_VARS contains the same initial information, but is not a superglobal. (Note that $HTTP_SERVER_VARS and $_SERVER are different variables and that PHP handles them as such)
      So it looks like as I built this machine from the latest bits the php version is too high and hence I have a build problem.

      Now fecking idea where next. I tried removing the if case and just setting the Content_Type anyway, but I then get an empty page loading instead.

      OK NF, over to you.
      Knock first as I might be balancing my chakras.

      Comment


        #13
        The correct (ie non deprecated code would be)

        Code:
        case 'I':
        
        			//Send to standard output
        			//if(isset($HTTP_SERVER_VARS['SERVER_NAME']))
        			if(isset($_SERVER['SERVER_NAME']))
        			//if (true)
        
        			{
        
        				//We send to a browser
        
        				Header('Content-Type: application/pdf');
        
        				if(headers_sent())
        
        					$this->Error('Some data has already been output to browser, can\'t send PDF file');
        
        				Header('Content-Length: '.strlen($this->buffer));
        
        				Header('Content-disposition: inline; filename='.$name);
        
        			}
        
        			echo $this->buffer;
        
        			break;
        Which now steps into the branch but the moment the Content_Type is set I get a blank page

        I added the line

        Code:
        error_reporting(E_ALL);
        just before the output but again I still get a blank page.

        So yes it is the content type not being set correctly, but when you set it then it loads nothing at all.
        Knock first as I might be balancing my chakras.

        Comment


          #14
          I restarted apache out of desperation.

          It works.

          A luverly little pdf gets opened up.

          Off for a glass of vino, before coming back and pozzie repping everyone in this thread. Time for some suity loving, you better buckle up.
          Knock first as I might be balancing my chakras.

          Comment


            #15
            Originally posted by suityou01 View Post
            I restarted apache out of desperation.

            It works.

            A luverly little pdf gets opened up.

            Off for a glass of vino, before coming back and pozzie repping everyone in this thread. Time for some suity loving, you better buckle up.

            Comment


              #16
              Originally posted by suityou01 View Post
              I restarted apache out of desperation.

              It works.

              A luverly little pdf gets opened up.

              Off for a glass of vino, before coming back and pozzie repping everyone in this thread. Time for some suity loving, you better buckle up.
              Well done on the debug. What a win-win, SuitYou sorted his problem and we all got his positive rep.
              Vote Corbyn ! Save this country !

              Comment


                #17
                Originally posted by suityou01 View Post
                So it looks like as I built this machine from the latest bits the php version is too high and hence I have a build problem.
                PHP can be a bit of a swine with the deprecated stuff. I had a fair old bit of digging and updating of code to do when I went to 5.3. I've still got some websites to switch over and check they don't barf.

                Originally posted by suityou01 View Post
                I restarted apache out of desperation.

                It works.

                A luverly little pdf gets opened up.
                Excellent news!

                Behold the warranty -- the bold print giveth and the fine print taketh away.

                Comment

                Working...
                X