最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

scaling - Resize pages with GhostScript only if page size is too large - Stack Overflow

programmeradmin3浏览0评论

I process prints and PDF files on a server. It sometimes happens that users upload very large pages (A1 or A0). Conversion with GhostScript then takes a very long time and very large amounts of data are created. For further processing, the pages should never be larger than A3. I would now like to ensure that pages that are larger than A3 are automatically scaled to A3. One possibility would be to check how large the pages are before GhostScript processes them. However, this is an additional processing step that costs unnecessary time, especially with large print data. It could also be problematic if it is a document with mixed page formats. A4 pages and A3 pages should not be scaled. But all pages larger than A3 should be automatically scaled to A3. Is there a possibility that GhostScript has this behaviour? Unfortunately, I have not found anything about this via search engines or in the GhostScript documentation. But maybe there is a trick?

I process prints and PDF files on a server. It sometimes happens that users upload very large pages (A1 or A0). Conversion with GhostScript then takes a very long time and very large amounts of data are created. For further processing, the pages should never be larger than A3. I would now like to ensure that pages that are larger than A3 are automatically scaled to A3. One possibility would be to check how large the pages are before GhostScript processes them. However, this is an additional processing step that costs unnecessary time, especially with large print data. It could also be problematic if it is a document with mixed page formats. A4 pages and A3 pages should not be scaled. But all pages larger than A3 should be automatically scaled to A3. Is there a possibility that GhostScript has this behaviour? Unfortunately, I have not found anything about this via search engines or in the GhostScript documentation. But maybe there is a trick?

Share Improve this question asked Mar 20 at 8:40 Steffen UrbanSteffen Urban 1 1
  • Clearly the media size request must be checked by something before scaling is applied. Can you get Ghostscript to do this ? Yes, but you will need to do some programming. you will need to modify the code in ghostpdl/Resource/Init/pdf_main.ps. At about line 504 that calls NewPDF_FitPage (if PDFFitPage is known), you would want to additionally check the 'Box' size, and if it is more than A3, set the page device PageSize to A3 and call NewPDF_FitPage. You then need to recompile GS (if using ROM file system) or point it to the modified file using -I. – KenS Commented Mar 20 at 9:33
Add a comment  | 

1 Answer 1

Reset to default 0

There are many odd, old and wrong "Questions and Answers" (often repeated) throughout StackOverflow, regarding how GhostScript can be used to solve a programmers PDF dilemmas.

Firstly GhostScript has served programmers well for over 36 years and is a core element of many applications. Updated daily and recompiled frequently.

One of the reasons it is a "GoTo" part of many applications, is its efficiency to produce a more optimised copy of poor / slow or bloated PDF.

But it is NOT a magic silver bullet, as PDF is a very inefficient way to put letters or images on a virtual page.

The question wrongly assumes changing PDF scale to smaller, will make it faster or easier and actually often the reverse is the case.

Without me writing reams of PostScript code, just to prove the point. I can use multiple single commands to draft a test response.

We have a multipage file with one undesired oversized page. Page 2 at 1261.41 exceeds 1191 as a desired maximal A3 length.

We can extract a page with an image or text or both and reduce its scalar values which correctly does not change any of the internals descriptions. We simply just transform their scales.

We now replace the second page amongst it former brethren by merge, and compare the files byte size, not surprisingly, the new file (232611 bytes) is bigger than the old (232115 bytes).

All things being equal, this is a good example of how PDF cannot be reduced in bytes by altering scalars.

The common reasons to see a reduction in PDF byte size is to remove the contents by destroy fonts or images and/or use inappropriate compressions (many online services will do that easily.)

GhostScript does its dandiest not to degrade a source components stated quality. So the new build will generally be better than the old one, and bigger is better as far as PDF goes.

发布评论

评论列表(0)

  1. 暂无评论