The Downsize PDF server action offers the possibility to reduce the size of PDFs if the file is too large. Learn how to configure the server actions and configure the parameters to calculate the downsized PDF.
By default, these server actions are not installed on your system.
Context
The censhare Admin Client is needed to configure the server actions.
The parameters for the calculation of the downsized PDF are stored in a module asset.
Prerequisites
censhare Server or censhare Service Client with installed Ghostscript.
Deeper knowledge of Ghostscript, if you want to adapt the PDF calculation parameters to your own needs.
InstalledPDF downsizemodule asset in the censhare Admin Client. This module asset is optional and therefore not installed by default.
Introduction
TheDownsize PDFserver actions provides you with a simple built-in solution to reduce the size of a PDF.
censhare uses the "Ghostscript" open-source tool for the calculation of the downsized PDF. For the conversion it calls the tool with the parameters that are configured in censhare. There are two possibilities to start the conversion: By a user and by asset automation:
TheDownsize PDF (manual)server action for user.
TheDownsize PDF (automatic)server action for asset automation.
Users can call theDownsize PDF (manual)server action within censhare Web or the censhare Client. The server action is available for assets that have thePDF documentMIME-type. TheDownsize PDF (automatic)server action is executed if one of the events occur that are defined for this server action. Typically, these can be asset events likeSave and closeorAsset workflow changed.
There are two places where configuration takes place:
On the censhare Admin Client: thePDF downsizemodule with the two server actions.
On censhare Web or censhare Java Client: thePreset Downsize PDFconfiguration asset that contains the parameters for the conversion by Ghostscript.
Note:By default, the Downsize PDF functionality is not installed on your system. Before you can configure it for the first time, you have to install thePDF downsizemodule on your system. This is done by theSynchronize module assetsserver action in the Admin Client.
For the Downsize PDF (manual) server action, there is not much configuration needed. You just have to activate the server action.
For theDownsize PDF (automatic) serveraction there are three configuration topics: the activation of the server action, the definition of theTrigger eventsand the adaption of theAsset filters. The trigger events tell censhare when to execute the conversion. The asset filters define for which assets the server action is applied to.
For the configuration of the parameters appliedby Ghostscript, censhare provides a set of parameters. These parameters can be used without modification. But you can adapt them if needed.
censhare does not allow you to have multiple configuration assets that can be used side by side. There can only be one configuration asset in the system. This means, the values stored in this configuration asset are used for all PDF downsize operations.
Asset XML
When censhare has converted the original PDF, it attaches the new file to the asset and names itDownsize PDF. You can see this also in the asset XML (presentation shortened):
"<storage_item" refers to a file attached to the asset. The new created "Downsize PDF" file has thepdf-downsizefile type (attribute = "key"). The MIME type for the file is set to PDF (application/pdf).
You can use the file type in censhare Client or censhare Web to search for all assets that have aDownsize PDFfile. In the censhare Client, open the search and go to the theExperttab and selectFile typeas search parameter. In censhare Web use the Expert search in the top navigation and selectFile typeas search parameter, too.
Configuration of the Ghostscript parameters
censhare stores the parameters for the conversion in the master file of thePreset Downsize PDFconfiguration asset. This configuration asset needs to have a resource key with thepreset-downsize-pdfvalue. This setting must not be changed. If the system does not find a configuration asset containing this resource key, the calculation of a downsized PDF will fail.
The parameters atPreset Downsize PDFconfiguration asset can be used without modification. But you can adapt them if needed.
Note:You should change the parameters only if you have a deeper understanding of PDFs and know how Ghostscript is working. Otherwise, you might not get the expected results.
In the following, you find some more information about the configuration of the parameters for the downsizing of the PDF. Besides, you will learn how censhare invokes the Ghostscript command and what is written into the log when executing the command. This might help you in case of troubleshooting.
The configuration for Ghostscript is an XML file attached with thePreset Downsize PDFasset. This file contains the following parameters by default:
"INSTALL_PATH" is the place where Ghostscript is installed. "sOutputFile=PATH1/OUTPUT.pdf" indicates where to write the output file. "PATH2/ORIGIN.pdf" is the input file for the calculation. You can use this commandline to test your parameters before you add them to the configuration file in censhare.
When censhare executes Ghostscript it writes the call also into the log file. Therefore, you can use the command line call to find the place in the log file where theDownsize PDFserver action (manual or automatic) was executed. Depending whether the conversion is manually or automatically started, the entries slightly differ from each other.
Installation of the Downsize PDF configuration asset
If you do not have to configure theDownsize PDFmodule for the first time, you can skip this step. It is only necessary, if the module asset for PDF Downsize configuration is not yet installed. The module asset is only optional and therefore might not have been installed.
You install the Downsize PDF module asset in the Admin Client using theSynchronize module assetsserver action. The configuration for the module is stored on your server within the following path:
Before you can execute theSynchronize module assetsasset action, you need to configure the path for the desired module. censhare needs to know where to find the configuration of the desired module. When you execute the server action, you than the select this stored path for the installation.
In the Admin Client, go to the "Configuration/Modules/Administration/Module Assets" folder.
Double-cklick to openSynchronize module assets.
Go to the end of theSearch pathsin theConfiguration asset importsection.
Click the "" icon and enter "optional/pdf-presets" in thePathfield.
Uncheck theEnabledfield. It prevents that the installation option is enabled by default when calling theSynchronize module assetsserver action.
Click OK at the top of the dialog.
Update the server configuration
Now, you have to transfer the configuration from the Admin Client to the Master server and then to Remote servers if existing:
Click theUpdate server configurationicon at the top of the Admin Client to transfer the changed configuration to your Master server.
If there are remote servers, you have to update them, too. Click theSynchronize remote servericon at the top.
Synchronize the Downsize PDF Module
Now, perform the installation of the Downsize PDF module asset itself:
Click theServer actionicon at he top of Admin Client and selectSynchronize module assets
A dialog opens where you have to choose the modules you want to synchronize. Only activateoptional/pdf-presets. Make sure that you uncheck all other boxes. Otherwise, you will synchronize that modules, too.
Click OK. After that thePDF downsizefolder is visible inConfiguration/Modulesfolder and you can configure it.
Configure Downsize PDF (manual) server action
To use the Downsize PDF (manual) server action you just need to activate it:
In the Admin Client select theConfiguration/Modules/PDFdownsizefolder.
Double-click to openPDF downsize (manual).
Activate theEnabledfield in theGeneral setupsection and click OK.
Update the server configuration.
The manual server action is then available in the censhare Client and censhare Web.
Configure Downsize PDF (automatic) server action
To use the Downsize PDF (automatic) server action you have to do three things:
Activate the server action.
Configure the triggers to execute the action.
Adapt theAsset filters.
There should be a filter that the action is only applied with assets that have a master file with the MIME typePDF document. This prevents that the action is called at all for assets that do not have an appropriate master file attached. Besides, you can define a filter to only generate a downsized PDF from files that exceed a certain file size.
Activate the server action
In the Admin Client, select theConfiguration/Modules/PDF downsizefolder.
Double-click to openPDF downsize (manual).
Activate theEnabledfield in theGeneral setupsection.
Configure the triggers
To configure the triggers select theTrigger eventssection.
censhare provides different kind of triggers:Asset events,Timer event,Cron eventandGeneric asset events. Configure the triggers according to your needs.
Adapt the asset filters
Each automatic server action also has an asset filter set. You can restrict which assets are considered if the server action is triggered. You can adapt the filter search to your needs:
Double click theSearchfield in theAsset filterssection to open the search dialog.
Add additional search parameters.
As theDownsize PDFserver actions only works with assets that have thePDF documentMIME type we recommend that you add a filter for this:
Go to theAdvancedtab.
Click the "" icon and selectMime typeas search parameter.
SelectPDF documentas search value.
This ensures that the server action is only raised for PDF assets. Of course, the server action itself would at least check if the passed asset is an appropriate one for conversion.
For each asset file attached to an asset, censhare stores the file size in the asset in the accordingFile lengthproperty. You can use this value to ensure that a PDF with reduced size is only calculated for larger PDFs:
Go to theAdvancedtab.
Click the "" icon and selectFile lengthas search parameter.
Enter the minimum file size for PDFs in bytes in the search field and choose the ">=" comparison operator.
When you are finished close the search dialog with OK and the configuration dialog with OK, too. Then, update your system: seeUpdating the server configuration.
Result
TheDownsize PDF (manual)server action is available for users in the censhare Client and censhare Web. The server automation forDownsize PDF (automatic)is configured. Whenever the defined events occur, theDownsize PDFis executed for the respective assets.
JavaScript errors detected
Please note, these errors can depend on your browser setup.
If this problem persists, please contact our support.