简体   繁体   English

如何使用 JavaScript 在 Adobe Acrobat Pro DC 中根据关键字删除 PDF 页面?

[英]How to delete PDF pages based on keywords in Adobe Acrobat Pro DC using JavaScript?

Each day I am working with a PDF document that is about 100 pages, with most pages that just read "No items to display".每天我都在处理大约 100 页的 PDF 文档,其中大多数页面只显示“没有要显示的项目”。 I normally use the "Organize Pages" feature in Adobe Acrobat Pro DC to manually delete those pages.我通常使用 Adobe Acrobat Pro DC 中的“组织页面”功能来手动删除这些页面。 Is there a JavaScript code I can run that will delete the pages that read "No items to display"?是否有我可以运行的 JavaScript 代码将删除“没有要显示的项目”的页面? Or at least if a page has the word "display" it will be deleted?或者至少如果一个页面有“显示”这个词,它会被删除?

I am using Adobe Acrobat Pro DC Version 21.0我正在使用 Adobe Acrobat Pro DC 21.0 版

You will need the Acrobat JavaScript documentation for the exact syntax.您将需要 Acrobat JavaScript 文档以了解确切的语法。

What you can do is parse the document with the getNthWord() method.您可以做的是使用getNthWord()方法解析文档。 You will then compare the fragments, and see if you can assemble your text;然后,您将比较这些片段,看看您是否可以组合您的文本; to verify that they really do match together, you will compare their coordinates.要验证它们是否确实匹配在一起,您将比较它们的坐标。 If the condition is fulfilled, create a table (aka array) with the page numbers to be deleted.如果满足条件,则创建一个包含要删除的页码的表(又名数组)。

When you have gone through all pages, loop through that array (from high numbers to low) and delete the according pages.当您浏览完所有页面后,循环遍历该数组(从高数字到低数字)并删除相应的页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM