Get the most out of your Centmin Mod LEMP stack
Become a Member

Optimizing/Compressing PDF files

Discussion in 'System Administration' started by sepulchre, Nov 30, 2019.

  1. sepulchre

    sepulchre Member

    163
    22
    18
    Dec 22, 2014
    Ratings:
    +28
    Local Time:
    3:46 PM
    Hey,

    I have a lot of PDFs in my forum and the newer ones are not optimized at all.

    So each PDF file takes up 1-2 mb storage.

    Does anyone have a script or know a way how I can optimize/compress PDF files on server level without losing quality?
     
  2. eva2000

    eva2000 Administrator Staff Member

    44,750
    10,205
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,816
    Local Time:
    11:46 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    honestly never thought about pdfs but quick google for 'pdf optimize' brings up lots of options to try :)
     
  3. sepulchre

    sepulchre Member

    163
    22
    18
    Dec 22, 2014
    Ratings:
    +28
    Local Time:
    3:46 PM
    It does bring a lot of results which is why I thought maybe someone else already found a suitable solution.
    Most of the stuff found has no feedback, so, I fear of running the optimization and then realizing months later I lost quality. Also as XF saves attachments as data files, I am no sure how to proceed with this.

    I have 66k PDF files. 99% are optimized (before I uploaded them, I optimized via Acrobat, so most of them are like 20-100 kilobyte). Just, now since my members upload PDFs all the time, they are not optimized and take a lot of disk space. Some PDF files are like 50-60 mb big. On the short run, I can take it as it is but on the long run I would like to have a way of optimizing the files.

    I am just not sure how we can optimize PDF files on server level, when the files themselves are hosted as a part of XenForo, so not having PDF as file extension. I would guess those scripts won't detect those stuff as pdf files.
     
  4. eva2000

    eva2000 Administrator Staff Member

    44,750
    10,205
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,816
    Local Time:
    11:46 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    that is tricky and for xenforo probably best to ask on xenforo forum as data uploaded is going to have a database entry along with file in filesystem

    The trick i learned long ago is, never allow users to upload large attachments as forums aren't file storage systems. I always limit upload attachments to no more than 1MB. If they want to upload larger, use a 3rd party service and link to it :) Otherwise, hosting large attachments will end up costly in the long run. One Xenforo forum owner had 4TB - yes 4 terabytes of attachments to deal with ! You can imagine how costly that is to store + backup !
     
  5. sepulchre

    sepulchre Member

    163
    22
    18
    Dec 22, 2014
    Ratings:
    +28
    Local Time:
    3:46 PM
    4TB? Holy... :D

    I know I can limit them to low numbers, which I did. But then they can't be bothered to upload those files on 3rd party sites. It is either me allowing it or losing all the content. And since my target audience is in average older people, they are also not good with the internet. 2 days ago I had to explain to one of them in pms how to open PDF files on her phone (it came out she was clicking on the avatar of the uploader and not on the PDF attachment icons...)

    On XF I pretty much know the answer... "Not without custom development". As vague as an answer can be but will try on there too.

    I thought since people deal with the server-side things on here and since many of you are crazy about optimizations, I thought I give it a try here. But it seems when it comes to disk usage not many people are interested in that.

    Thanks for the answers though, always appreciated.