opening a large pdf files on web

后端 未结 5 1504
终归单人心
终归单人心 2021-01-15 12:56

I have a 27MB pdf file which is hosted in web. When I try to open it, it takes times to open it. So Is there any way where I can view this large pdf file a bit fast. I guess

5条回答
  •  孤城傲影
    2021-01-15 13:56

    What you need to do to your PDF is to make them "web optimized". The technically more correct term is to make them "linearized":

    • Acrobat + Distiller and a lot of other tools can do that.
    • Ghostscript also ships an additional PostScript-written helper utility named pdfopt.ps which can do this. Simply run:
      gs -q -dNODISPLAY -P- -dSAFER -dDELAYSAFER -- /path/to/pdfopt.ps input.pdf optimized.pdf, or if you are on Windows:
      gswin32.exe -q -dNODISPLAY -P- -dSAFER -dDELAYSAFER -- c:/path/to/pdfopt.ps input.pdf optimized.pdf

    Normally pdfopt.ps should be installed together with your Ghostscript in the installation path's lib/ subdirectory. If not, you can download pdfopt.ps from the Ghostscript Git repository.

    Linearization re-organizes the PDF internally, so that (a copy of) its internal ToC of PDF objects (in technical terms: its "xref table") is put close to the beginning of the file (instead of its end), plus some more changes.

    That way, a spec-conforming PDF reader will be able to start rendering the first page before the rest of the file has been loaded. It will even be possible to jump to the last page and view it before the middle pages are downloaded, if you are accessing the PDF over the web using HTTP-based protocols. But then, the web server is required to support the HTTP "byte range" requests (otherwise this will not work even for linearized PDFs).

    You can read some more details about PDF linearizations in the official PDF-1.7 ISO standard spec, available on the Adobe website

    • in its (normative) Annex F, "Linearized PDF", starting on page 683, and
    • in its (informative) Annex G, "Linearized PDF Access Strategies", starting on page 703.

    An example of a linearized PDF can be found here


    Update (2013-2-15)

    Since release 9.07 of Ghostscript, linearized ("web optimized") PDF output can be generated directly (without the 2-step approach outlined above) by adding the following switch to the commandline:

    -dFastWebView=true
    

    Since the pdfopt.ps file is now redundant, it has been removed from the current Ghostscript source repository.

提交回复
热议问题