-
Notifications
You must be signed in to change notification settings - Fork 91
Fix inline PDF preview in expensereport #148
Conversation
I use expense reports module. I can preview PDF inline (without download it). As in other documents (order, invoice...), this feature doesn't require imagick/ghostscript. |
There are two places where pdf inline preview is available. One is the list of uploaded files at the bottom of the page. In this one imagick is not needed for preview. The other one is within each row of the expense table. At the most right hand side there should be a clickable icon to preview the file associated with the row. In the dolibarr code, it uses imagick to convert the pdf to png and use the png as the icon. If it cannot do that, it skips the div where the preview link sits in. |
You can find the code to call imagick here https://github.com/Dolibarr/dolibarr/blob/56c198992dce8c29880e84ec6e142e697df6c72d/htdocs/expensereport/card.php#L2210 dol_convert_file requires imagick and ghostscript |
Ok I have never used this part. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid this will make the image bigger. Maybe it's better to document it or add an example. Let's see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you don't need to create a separate script. The xml path will be always the same, you can run sed command directly in Dockerfile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for futural compatibility. The configuration folder depends on the version of Imagick. For example, in the current docker container, it is /etc/ImageMagick-6
You add an example in examples folder. |
Hi @rqi14 |
You can click on these thumbnails and previews will show. It is convenient to check each line has correct receipt attached. |
I think it would be better to change the Dolibarr code. |
I agree the thumbnail here is weird. The preview functionality is available without the thumbnail for the linked files. Your suggestion could be implemented. I am not sure what kind of fix it would be, as technically it is not a bug. It is something I cannot really do because I am not too familiar with php and html. I can sure read it a little bit but not code such a complex page. |
Two lines before this line, did you try to set MAIN_DISABLE_PDF_THUMBS to 1 to see what it does ? Edit : it does nothing more, i've created a PR. |
Tested. The preview won't work with this option set to 1 |
On this line : https://github.com/Dolibarr/dolibarr/blob/0ceacfdc6a40dfbe84317d9477c37a84dbdfe8f9/htdocs/expensereport/card.php#L2234 Change
By :
|
The PR has been merged. |
In expensereport, it requires imagick and ghostscript to convert pdf and show an inline preview. This pull request is to include the installation and configuration of these packages