【问题标题】:PDF - Edit raw text without special paid toolPDF - Edit raw text without special paid tool
【发布时间】:2022-12-19 09:05:49
【问题描述】:

Is there a way to edit the raw text from a PDF without any special paid software? So there are PDFs with highlightable text. I assume that the text is stored somewhere in the file.

I tried to just drag & drop a PDF into vscode but it just showed me unknown characters; even a little of meta text but if I edit the meta-infos, the file gets mostly corrupted. Apart from that, I could not find any of the text contents of my desired PDF in vscode-editor.

Does someone know if there is a solution like inspecting and changing the source code somehow without a special software? I want to edit the contents; not the meta-infos.

(I use macOS)

【问题讨论】:

  • all text is hard placed on the page (x,y coord), so editing text involves a lot of repositioning words.
  • But how am I able to edit it like this in the first place?
  • because PDF is a text format, maybe compressed
  • You did not answer my question :( How do I edit it? With which tool? As I said, opening it with Visual Studio Code did not work :/

标签: macos pdf visual-studio-code pdf-generation edit


【解决方案1】:

The text you see on a pdf page can be constructed in dozens of different ways, actually there are millions of users, using potentially hundreds if not thousands of different methods.

Update The question is MacOS but for native cross platform you need to work in mime text/pdf to be universally useful. But by way of example how thats possible specifically in windows its possible to write line by line using say cmd here is a sn-p of what was a few dozen lines :-)

echo %%PDF-1.0>demo.pdf
echo %%µ¶µ¶>>demo.pdf
echo/>>demo.pdf

for %%Z in (demo.pdf) do set "FZ1=%%~zZ"
echo 1 0 obj>>demo.pdf
echo ^<^</Type/Catalog/Pages 2 0 R^>^>>>demo.pdf
echo endobj>>demo.pdf
echo/>>demo.pdf

For the fuller "Feature Creep"ing of now over more than a 100 lines and counting see
https://github.com/GitHubRulesOK/MyNotes/raw/master/MAKE-PDF.cmd

However although plain text could be the simplest it is rarely used except to prove a conceptual point that it is possible. The rest of the time "Special Software" as you call it (a pdf generator/editor) will be used to compress the file objects, most frequently as different optimal binary streams.

So some text may be scanned pixels whilst other text may be line shapes that look like letters, or at other times plain letters without fonts but a named style, or even letters with the font included (embedded) in the file (the preferred option).

In many ways each page may be built different to the others and thus no two pdfs generally will use the same structure unless like a bank statement using a format that does not change much from month to month, even if the balance wobbles about.

So in summary the tool that will work best is the one that covers every single permutation that Adobe dreamed of, and still keep the result a valid Adobe PDF.

Thus Acrobat PRO 3D is on my shelf (even if not used from one year to the next)

There are many cheaper editors and ones I will use more often for small mods are Tracker Xchange and FreePDF PRO and both have different limitations.

Your choices for MacOS will be more limited thus search for the best you are willing to pay for.

【讨论】:

  • Thank you, I see your point with there beeing many possibilities. I was hoping to edit the PDF like a HTML-file (I'm clearly not that deep into understanding how PDF works). But you don't know a techy solution with changing source code (if possible), or are there only applications that do this entirely for you without beeing able to do that in a coding-like way?
  • Gonna check it out! Apache PDFBox also looks interesting to manipulate PDF, it seems to work with Java
猜你喜欢
  • 2017-03-09
  • 1970-01-01
  • 2020-05-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-27
  • 2022-12-02
  • 1970-01-01
相关资源
最近更新 更多