Topic on Project:Support desk

Extension PDFInclude (not working on android tablet)

2
Summary by Chantoune

Update the code of PDFInclude;php to check if we are working on an Android browser

and if is is the case : return an HTML rawElement Iframe after an embedded request to google

$myfile = "https://docs.google.com/gview?url=$myURL&embedded=true";

Chantoune (talkcontribs)

how to perform an update into PDFInclude.php to view the pdf on the android tablet (because nothing is displayed or download)

for memory I solved this problem in PDFEmbed as explain in this post to display PDF on an android tablet

and it will be perfect if you may help me to perform something similar to return a PDFobject as a HTML:rawElement with pdfInclude

Chantoune (talkcontribs)

I solved my problem

I update the code of pdfInclude.php as following :

if( filter_var( $obj, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED ) ) {

  $ua = strtolower($_SERVER['HTTP_USER_AGENT']);

     if(preg_match('/android/i',$ua)) {

      $myfile = "https://docs.google.com/gview?url=$obj&embedded=true";      

      return Html::rawElement('iframe', [

         'src' => $myfile,

        'height' => $height,

        'width'=> $width,

        'frameborder' => "1" ].   );      

      } else {

         return pdfObject( $obj, $width, $height );

      } 

 } else {

        return pdfError( "Path is not valid" );

 }