Unless I have overlooked it there seems to be no basic PDF viewing capability in SuiteCRM. PDF documents can be uploaded, but have to be downloaded again for previewing.
I’ve been scouring the web for solutions, but nothing really good seems to be out there (I could not get the below to work in SuiteCRM 7.4.3).
Found this because I’m looking for the same functionality. my use case requires a lot of pdf viewing and limiting the downloads would be great, “Open in Browser” would be plenty for me. Is there perhaps a way to convert the download link to a view link?
Based on the link provided by lotz98 I have created a script that does the job. (At least for me) Please note that based on some browsers settings the files may still be downloaded. Also, if there are better ways of doing this please let me know.
You will need to create a Custom Entry Point which is fairly simple. First you create the entry point file in ./custom/YourCustomEntryPoint.php
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
$fileRevision = $_GET['file'];
$filename = $_GET['fileName'];
$documentExt = substr(strtolower($filename), -4);
switch ($documentExt) {
case ".pdf":
$ContentType = "application/pdf";
break;
case "jpeg":
$ContentType = "image/jpeg";
break;
case ".jpg":
$ContentType = "image/jpeg";
break;
case ".png":
$ContentType = "image/png";
break;
case ".gif":
$ContentType = "image/gif";
break;
}
if ($ContentType == "application/pdf" || $ContentType == "image/jpeg" || $ContentType == "image/png" || $ContentType == "image/gif") {
$file = "upload://". $fileRevision;
header('Content-type: '. $ContentType );
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file));
header('Accept-Ranges: bytes');
@readfile($file);
}else{
echo "Preview is not supported for this type of file.";
}
?>
Then create the extension in the application extensions. ./custom/Extension/application/Ext/EntryPointRegistry/YourCustomEntryPoint.php