PDF viewing

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).


Why can e.g. Wordpress preview PDF’s out of the box and SuiteCMR cannot…? Wordpress is developed under GPLv2, could this source be utilized…?

1 Like

Also interested in this. X2 shows the PDF in the app. I would happy with an in browser view…

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?

Hello everyone,

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

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";
    case "jpeg":
        $ContentType = "image/jpeg";
    case ".jpg":
        $ContentType = "image/jpeg";
    case ".png":
        $ContentType = "image/png";
    case ".gif":
        $ContentType = "image/gif";

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');


	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


    $entry_point_registry['YourCustomEntryPoint'] = array(
        'file' => 'custom/YourCustomEntryPoint.php',
        'auth' => true

Go to studio=>documents=>fields an make a custom field with the below properties (as described on the link provided):

  • Datatype: Iframe
  • Field label: Preview
  • Generate URL: Yes
    - Standard value: http://{suite url}/index.php?entryPoint=YourCustomEntryPoint&file={document_revision_id}&fileName={filename}
  • Maximun size: 225
  • Iframe height: 500
  • Save
  • Go to studio=>documents=>layout=>detailview and make a panel called something like “Preview”
  • Place the “preview” block on the new panel and make it fit the whole line.

Then, navigate to Admin > Repair > Quick Repair and Rebuild.

If the browser is not set to download certain file extensions, you should be able to view pdf, jpeg, png and gif.


How i can this in custom module? There is no document_revision_id field in new module…

it is viewing as pdf helpful for me

Try change standard value to:
http://{suite url}/index.php?entryPoint=YourCustomEntryPoint&file={id}&fileName={filename}


@DDI209 Thank you. Please, how to enable online viewing for .docx, .xlxs, .pptx? Any advice is welcome.