Make PDF exports writable in SugarCRM
Just wanted to share quick tip on how to make PDF exports generated by SugarCRM editable. This feature would be especially useful for the Quotes module – when certain corrections must be made. Currently there is no setting anywhere in SugarCRM to disable PDF protection – even though a request has been made, so perhaps this feature will be introduced in the future release.
The modification required to disable PDF protection is fairly trivial, all you have to do is copy “/include/Sugarpdf/sugarpdf_default.php” into “custom/include/Sugarpdf/sugarpdf_default.php” and modify:
to look like the following (by adding modify action to the list of permit-table actions):
This would be a non-issue on a self-hosted instance of SugarCRM Community Edition. In SugarCRM On-Demand however, you are not provided with a direct access to the filesystem, so the only way to copy the file and make the necessary modifications is to create a proper SugarCRM module.
Every module in SugarCRM starts with a manifest.php, which described the module itself and the installation procedure. The following is an example of a manifest that can be used in our situation:
global $sugar_config; $upload_dir = $sugar_config['upload_dir']; $manifest = array( 'acceptable_sugar_versions' => array( 'regex_matches' => array( 0 => '6\.*' ), ), 'acceptable_sugar_flavors' => array( 0 => 'CE', 1 => 'PRO', 2 => 'ENT', 3 => 'CORP' ), 'name' => 'Editable PDF Config', 'description' => 'Editable PDF Config installation package.', 'is_uninstallable' => true, 'author' => 'BlackRiver', 'published_date' => 'July 29, 2013', 'version' => '1.0.0', 'type' => 'module', ); $installdefs = array( 'id' => 'CG_LogicHook', 'mkdir' => array( array('path' => 'custom/include/Sugarpdf'), ), 'copy' => array( array( 'from' => '<basepath>/NewFiles/sugarpdf_default.php', 'to' => 'custom/include/Sugarpdf/sugarpdf_default.php', ), ) );
The most important bit here is the copy element included into the $installdefs array. It tells SugarCRM which files to copy where. The new and already modified sugarpdf_default.php file is already included with the module (make sure to use the latest source from the SugarCRM repository). The module now can be zipped using the following structure:
InstallerTemp (dir) -manifest.php -NewFiles (dir) --sugarpdf_default.php
The resultant zip file can be installed and activated through the SugarCRM Module management tool in the admin panel. You can also download the complete module here.
Excellent Info! I have been looking for this!