使用FPDF缩小生成的pdf的大小[关闭]

I'am generating pdf for every pages in a pdf file using FPDF. Its working properly. But the main problem is with the file size. Some files have size of more than 2Mb.I want to limit the size. Can i limit the size within 300 kb? Any help will be appreciated.

Typically PDFs are large because they contain large images or because they contain large fonts.

So the solution is typically to reduce the resolution of the images and to avoid the fonts getting embedded.

If FPDF will allow you to do this then this will likely solve your problem.

If not then you will need to post-process your PDF using another library to unembed the fonts and resample the images.

ABCpdf will do this using the ReduceSize operation. No doubt other libraries will allow something similar.

I work on the ABCpdf .NET software component so my replies may feature concepts based around ABCpdf. It's just what I know. :-)

The best way is to compress pdf file is that first you generate the pdf and then use any tool to compress the pdf file. As far as my experience is concerned, there is no other way to compress pdf file.