<?php
class Andy_OpenPDF_ViewPublic_Attachment_View extends XFCP_Andy_OpenPDF_ViewPublic_Attachment_View
{
   //######################################## 
   // the original renderRaw() function is located in library/Xenforo/ViewPublic/Attachment/View.php
   // this renderRaw() will run instead of the original unless we the return parent::renderRaw()
   //########################################
   public function renderRaw()
   { 
     $attachment = $this->_params['attachment'];
     $extension = XenForo_Helper_File::getFileExtension($attachment['filename']);
 
     if ($extension === 'pdf')
     {
       $this->_response->setHeader('Content-type', 'application/pdf', true);
       $this->setDownloadFileName($attachment['filename'], true);
   
       $this->_response->setHeader('ETag', $attachment['attach_date'], true);
       $this->_response->setHeader('Content-Length', $attachment['file_size'], true);
       $this->_response->setHeader('X-Content-Type-Options', 'nosniff');     
   
       return new XenForo_FileOutput($this->_params['attachmentFile']);
     } else {
       // run the original renderRaw() function
       return parent::renderRaw();
     }
   }
}
?>