AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 32048
Accepted
MarkovCh1
MarkovCh1
Asked: 2011-03-26 16:55:35 +0800 CST2011-03-26 16:55:35 +0800 CST 2011-03-26 16:55:35 +0800 CST

重新编号 PDF 的页面

  • 772

我想编辑扫描的 PDF 的元数据以将自定义页码分配给不同的页面。例如,现在第 1-3 页是什么,我可能想调用 i、ii 和 iii,而第 4-10 页是什么,我想调用 1-7。我不想更改页面的实际顺序。

有没有一种方法可以使用免费工具来做到这一点;和 B)一种“批量”执行此操作的方法(因此,无需手动重新编号每页)。

software-recommendation
  • 9 9 个回答
  • 12005 Views

9 个回答

  • Voted
  1. Best Answer
    Martin Scharrer
    2011-04-10T09:36:30+08:002011-04-10T09:36:30+08:00

    这里是基于 LaTeX 的解决方案。它使用pdfpages包来包含扫描的 PDF(这里称为scan.pdf)。您可以使用启用该选项的hyperref包来设置您想要的 PDF 页面标签。pdfpagelabels它使用普通\thepage宏作为可以定义为小写罗马数字的标签。然后页面计数器被重置并变回正常数字。

    \documentclass[a4paper]{article}% or use 'letterpaper'
    \usepackage{pdfpages}
    \usepackage[pdfpagelabels]{hyperref}
    \begin{document}
    % Set lower case roman numbers (\Roman would be upper case):
    \renewcommand{\thepage}{\roman{page}}
    \includepdf[pages=1-3]{scan.pdf}
    % Back to normal (arabic) numbers:
    \renewcommand{\thepage}{\arabic{page}}
    % Reset page counter to 1:
    \setcounter{page}{1}
    \includepdf[pages=4-]{scan.pdf}
    \end{document}
    

    将上面的代码放入一个文件(例如scan_mod.tex)并编译它pdflatex:

    # pdflatex scan_mod
    

    这将产生scan_mod.pdf. 但是任何特殊注释包括。超链接将消失。这对扫描的 PDF 应该没有任何问题。

    如果您更频繁地需要这个,您可以编写一个脚本,该脚本接受罗马编号的页数和文件名作为参数,并使用上述代码创建一个临时文件,其中名称和数字是变量,然后编译。

    • 25
  2. Akihiro HARAI
    2013-09-19T19:51:25+08:002013-09-19T19:51:25+08:00

    您可以使用文本编辑器来做到这一点。

    • metadata - 如何更改 PDF 元数据中的内部页码?- 超级用户

    正如答案所说,使用文本编辑器打开一个 PDF 文件,搜索/Catalog条目,然后附加一个如下命名的条目/PageLabels:

    /PageLabels << /Nums [
    0 << /P (cover) >> % labels 1st page with the string "cover"
    1 << /S /r >> % numbers pages 2-6 in small roman numerals
    6 << /S /D >> % numbers pages 7-x in decimal arabic numerals
    ]
    >>
    

    请注意,页面索引(物理页码)以 . 开头0。

    当然,您可以使用脚本语言自动执行此操作。

    PDF 标准 - 页面标签有详细的规范。

    • 11
  3. CherryBerry
    2014-08-15T22:16:02+08:002014-08-15T22:16:02+08:00

    jPDF Tweak是一个开源图形实用程序,它提供页码(正确的术语是“页标签”)和许多其他初学者到高级 PDF 编辑功能。它在 Ubuntu 和其他操作系统上运行。

    文档页面提供了分步说明。

    • 9
  4. DG'
    2019-01-14T13:00:54+08:002019-01-14T13:00:54+08:00

    有一个小的 python 脚本,可以完成这项工作:https ://github.com/lovasoa/pagelabels-py

    在您的情况下,请致电:

    ./addpagelabels.py --delete file.pdf
    ./addpagelabels.py --startpage 1 --type 'roman lowercase' file.pdf
    ./addpagelabels.py --startpage 4 --type arabic file.pdf
    
    • 6
  5. Wilsonzaizai
    2011-03-26T21:58:59+08:002011-03-26T21:58:59+08:00

    有一个名为 PDF Mod 的工具,它是一个重新排列 PDF 页面的免费工具。

    它可以从 Ubuntu 10.10 及更高版本的 Ubuntu 软件中心安装。

    在 Ubuntu 9.10 或 10.04 中安装:

    安装 将 ppa 添加ppa:pdfmod-team/ppa到您的软件源(这里是如何做到这一点)并从软件中心安装 pdfmod

    改编自:http ://www.webupd8.org/2011/03/edit-pdf-documents-in-linux-with-pdf.html

    祝你好运:D

    • 3
  6. sdaau
    2011-10-14T16:24:08+08:002011-10-14T16:24:08+08:00

    刚刚找到了一个可以ghostscript用于此目的的指针,在这里:pdftk - 添加和编辑书签到 pdf - Unix 和 Linux - 堆栈内存溢出 #18600;它指的是链接:

    • [其他] 如何通过 ghostscript/pdfwrite/pdfmark 生成书签 - Ubuntu Forums
    • Ghostcript PDF 参考和提示 — Milan Kupcevic

    但是,以上处理的是书签——而不是逻辑分页。从pdfmarkReference.pdf可以看出,所需的“命令”是 ' /Label'(或 ' /PAGELABEL')——它进一步引用了PDFReference.pdf第 8.3.1 章“页面标签”。不幸的是,那一章没有必要解释 pdfmarks 如何与页面标签一起使用 - 但这篇文章确实:

    • [gs-bugs] [错误 691889] 带有“/PAGELABEL pdfmark”操作符的 pdfwrite 不适用于多页

    /PAGELABEL pdfmark 没有任何 /Page 键,因此只能为“当前”页面设置标签(因此,一次只能设置一页)。由于您在一开始就调用它,因此应该为第一页设置一个标签,并且只为它设置一个标签。

    同一页面的多个 /PAGELABEL:pdfmark 参考说最后一个生效,所以你的第一个命令行的结果是好的。请注意 /Page 键被忽略。

    如何从 PostScript 设置页面标签?我可以想到2种方法:

    (A) 100% 记录的方式:

    发出 /PAGELABEL 作为每个页面的一部分。

    (B) 记录较少的方式:...

    gswin32c -sDEVICE=pdfwrite -sOutputFile=50pages.pdf -dNOPAUSE
    
    GS>[/_objdef {pl} /type /dict /OBJ pdfmark
    GS>[{pl} <</Nums [0 <</P (Page ) /S /r /St 10>> 2 <<>>]>> /PUT pdfmark
    GS>[{Catalog} <</PageLabels {pl}>> /PUT pdfmark
    GS>50 { showpage } repeat
    GS>quit
    

    ...并在该线程中进一步:

    至于做这项工作;由于原始文件是 PDF 文件,您可以单独运行文件中的每一页。因此,您可以为第 1 页设置 PAGELABEL pdfmark,从原始文件运行第 1 页,为第 2 页设置 PAGELABEL,从原始文件运行第 2 页等等。

    因为标签(如 SaGS)表示应用于当前页面,所以这应该为输出 PDF 文件中的每个页面正确设置标签。(警告:我实际上还没有尝试过)

    编辑:只是为了显示这一点-如果您将其保存为pdfmarks文件:

    [ /Label (-1) /PAGELABEL pdfmark
    showpage
    [ /Label (0) /PAGELABEL pdfmark
    showpage
    [ /Label (1) /PAGELABEL pdfmark
    showpage
    

    ...你打电话给:

    gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=outfile.pdf infile.pdf pdfmarks
    

    ...然后您将在末尾附加三个空白页面,分别infile.pdf标记为 -1、0 和 1 :)

     

    好吧,也许这有助于获得一个更简单的gs脚本来重新编号页面:)
    干杯!

     

    EDIT2:知道了,我想 - 使用与gs上面相同的命令 - 下面是pdfmarks脚本的内容,它将重新编号 infile.pdf,所以它以 -1、0、1 开头......它基本上是一个修改后的例子PDF参考(见评论更多):

    % Type name (Optional) The type of PDF object that this dictionary describes; if present, must be PageLabel for a page label dictionary.
    % S name (Optional) The numbering style to be used for the numeric portion of each page label:
    %       D Decimal arabic numerals
    %       R Uppercase roman numerals
    %       r Lowercase roman numerals
    %       A Uppercase letters (A to Z for the first 26 pages, AA to ZZ for the next 26, and so on)
    %       a Lowercase letters (a to z for the first 26 pages, aa to zz for the next 26, and so on)
    % P text string (Optional) The label prefix for page labels in this range.
    % St integer (Optional) The value of the numeric portion for the first page label in the range. Subsequent pages will be numbered sequentially from this value, which must be greater than or equal to 1. Default value: 1.
    
    % renumber first 25 pages - push each by 10, and add prefix:
    % [/_objdef {pl} /type /dict /OBJ pdfmark
    % [{pl} <</Nums [0 <</P (Page ) /S /D /St 10>> 25 <<>>]>> /PUT pdfmark
    % [{Catalog} <</PageLabels {pl}>> /PUT pdfmark
    
    [/_objdef {pl} /type /dict /OBJ pdfmark
    [{pl} <</Nums [ 0 << /P (-1) >>         % just label -1 (no style) for pg 0;
                    1 << /P (0) >>          % just label  0 (no style) for pg 1;
                    2 << /S /D /St 1 >>     % decimal style, start from 1, for pg2 and on.
                    ]>> /PUT pdfmark
    [{Catalog} <</PageLabels {pl}>> /PUT pdfmark
    
    • 3
  7. RolandiXor
    2011-04-09T21:36:30+08:002011-04-09T21:36:30+08:00

    Openoffice/Libreoffice 可以使用 pdf-import 扩展和分页宏来解决问题。

    这不是一个完美的解决方案,但它对我有用(除了使用 PDF Mod - 我强烈建议)。

    • 1
  8. lazyPower
    2011-04-09T17:28:31+08:002011-04-09T17:28:31+08:00

    还有另一个名为 PDFEdit 的应用程序 - 它托管在 source forge 上。 Source Forge 项目页面- 但这无济于事,因为它不是您需要的功能

    PDFEdit 中的文本编辑

    • 0
  9. loevborg
    2011-04-10T00:21:32+08:002011-04-10T00:21:32+08:00

    尝试pyPdf,一个用于操作 PDF 文档的 python 库。一些但不多的编程是必要的。

    您也可以查看PDFtk,尽管我没有检查它是否支持更改与单个页面关联的页码。两者都在 Ubuntu 中作为软件包提供。

    • 0

相关问题

  • 有哪些科学绘图软件可用?

  • 最好的思维导图软件是什么?

  • 服务器的最佳rootkit删除工具?

  • 从 Ubuntu 连接到 Windows 的最佳远程桌面工具是什么?[关闭]

  • 是否有 Paint.NET 替代方案?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    我需要什么命令来解压缩/提取 .tar.gz 文件?

    • 8 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Marko Smith

    如何使用命令行将用户添加为新的 sudoer?

    • 7 个回答
  • Marko Smith

    更改文件夹权限和所有权

    • 9 个回答
  • Martin Hope
    EmmyS 我需要什么命令来解压缩/提取 .tar.gz 文件? 2011-02-09 14:50:41 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve