Forgot password?
 Create new account
View 197|Reply 4

PDF调整页边距?

[Copy link]

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

hbghlyj Posted at 2022-11-27 22:45:18 |Read mode
Last edited by hbghlyj at 2023-5-3 22:44:00例如residue.pdf的第6页最下的公式超出页边距了, 但是使用PDF编辑工具可以把那个公式拖上来, 显示是完整的, 说明它是保存在PDF里的, 但是被bounding box截掉了, 不能显示. 如何调整页边距呢?
Screenshot 2022-06-01 at 17-22-50 KaTeX – The fastest math typesetting library .png
使用4#的方法:
  1. "D:\cpdf\cpdf.exe" -mediabox "0 -40 612 752" residue.pdf -o resized.pdf
Copy the Code

$type resized.pdf (128.55 KB, Downloads: 34)
可以使第6页最下的公式完整显示.
Screenshot (2).png
相关问题:
Bash Script to Scale and Resize PDFs using Ghostscript
How to scale the page content of PDF files (with open source commandline tools)?
"Place" Letter Sized PDF to Larger pdf at specific position

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

 Author| hbghlyj Posted at 2022-11-27 23:34:25

PDF bounding box术语介绍

PDF 页面的 /CropBox(在 /MediaBox 内)决定了整个页面信息的哪一部分PDF 查看器应该对用户(或打印机)可见。 400px-PDF_BOX_01.svg[1].png

来自StackOverflow:
When converting first page of a PDF into an image using Ghostscript, sometimes I get "extra" space. Why?

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

 Author| hbghlyj Posted at 2023-1-8 18:53:16

查看metadata

pdftk使用dump_data选项
  1. D:\PDFtk\bin\pdftk.exe 1.pdf dump_data output 1.txt
Copy the Code

输出到D:\PDFtk\bin\1.txt
最后几行为
NumberOfPages: 1
PageMediaBegin
PageMediaNumber: 1
PageMediaRotation: 0
PageMediaRect: 0 0 612 792
PageMediaDimensions: 612 792

也可以使用其它工具, 如pdfinfo和exiftool, 见 GNU/Linux Desktop Survival Guide Properties of a PDF (MetaData)
  1. pdfinfo -box 1.pdf
Copy the Code

输出的最后几行为
Page size:      612 x 792 pts (letter)
Page rot:       0
MediaBox:           0.00     0.00   612.00   792.00
CropBox:            0.00     0.00   612.00   792.00
BleedBox:           0.00     0.00   612.00   792.00
TrimBox:            0.00     0.00   612.00   792.00
ArtBox:             0.00     0.00   612.00   792.00
File size:      77415 bytes
Optimized:      no
PDF version:    1.5

  1. gs -sDevice=bbox 1.pdf
Copy the Code

输出
Processing pages 1 through 1.
Page 1
%%BoundingBox: 72 42 612 721
%%HiResBoundingBox: 72.125998 42.119999 611.999981 720.215978

为什么ghostscript输出的 BoundingBox 信息是不同的,见stackoverflow.com/questions/43042210/

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

 Author| hbghlyj Posted at 2023-1-8 20:37:57
ghostscript太复杂, 尝试了很多次, 没有成功.
刚才参考此帖, 用 coherent pdf 成功调整了页边距
  1. "D:\cpdf\cpdf.exe" -mediabox "50 0 690 792" 1.pdf -o resized.pdf
Copy the Code

原PDF (右边有一截超出了页边距) $type 1.pdf (75.6 KB, Downloads: 34)
调整后的PDF $type resized.pdf (75.41 KB, Downloads: 33)

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

 Author| hbghlyj Posted at 2023-1-8 20:51:46
hbghlyj 发表于 2023-1-8 13:37
ghostscript太复杂, 尝试了很多次, 没有成功.
  1. D:\gs9.54.0\bin\gswin32.exe -o resized.pdf -sDEVICE=pdfwrite -c "/MediaBox [50 0 690 792]" -f 1.pdf
Copy the Code

产生的PDF看上去和原PDF一样, 没有任何效果

手机版Mobile version|Leisure Math Forum

2025-4-20 22:00 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list