Embedded fonts in PDF: copy and paste problems

天大地大妈咪最大 提交于 2019-12-12 09:28:06

问题


When trying to copy and paste into a MS word document from a PDF document which has some sets of fonts embedded, the result is illegible.

Several symbols are changed or even disappear.

Using Adobe Acrobat I can check which specific fonts are embedded.

  • Would installing such fonts in Microsoft Word work it out?
  • If so, where can I get or even create those subsets of the fonts I need?
  • If not, how could I solve this problem?

回答1:


You should check your PDF document's fonts first with the help of the pdffonts utility. That is part of the XPDF package for Windows and can be used without installing, just from a DOS box.

In order to successfully extract text (or copy'n'paste it) from a PDF, the font should either use a standard encoding (not a Custom one), and it should have a /ToUnicode table associated with it inside the PDF.

pdffonts returns a few basic information items about the fonts used by your PDF.

Example output:

$ pdffonts -f 3 -l 5 sample.pdf
  name                      type          encoding     emb sub uni object ID
  ------------------------- ------------- ------------ --- --- --- ---------
  IADKRB+Arial-BoldMT       CID TrueType  Identity-H   yes yes yes     10  0
  SSKFGJ+ArialMT            CID TrueType  Custom       yes yes no      11  0

The command above asked for the fonts used in the page range 3 (first to check) to 5 (last page to check).

In the above case, both used fonts are embedded as subsets (indicated by the XYZABC+-prefixes to their names, as well as by the yes in the emb and the sub columns).

The font SSKFGJ+ArialMT uses a custom encoding, but the PDF has no /ToUnicode for this font, as indicated by the no entry for the column headed uni.

Hence it is not easy to extract text that is shown with this font (extraction would require manual reverse engineering -- but then you can also just "read" the PDF pages).

You should check first, if copy'n'pasting of text works if you use a simple text file as a target (not an MS Word document). If it doesn't, you can already forget about MS Word...


  • Would installing such fonts in Microsoft Word work it out?
  • Very likely: no. (I cannot give a definite answer without having myself access to the PDF in question.)
  • If so, where can I get or even create those subsets of the fonts I need?
  • You could extract the subsetted fonts from the PDF itself. (Funnily, my most popular StackOverflow answer deals with exactly that question -- I dunno why people seem to be so crazy about extracting fonts from PDF files other than for debugging purposes...)
  • If not, how could I solve this problem?
  • There is no solution other than doing this manually.

Update

You can, unfortunately, not get the exactly same info about the fonts used by a PDF via Acrobat or Adobe Reader. What you can get via Menu -> File -> Properties... is

  • the font names,
  • the subset info (but not the prefixes used for subset font names),
  • the encoding and
  • the font type.

But you do not get the info about the presence of a /ToUnicode table.




回答2:


My work-around is to save the PDF as a lossless or near lossless image such as .tiff format, then create a new PDF from the image and run OCR. Thus I lose no clarity/sharpness in the PDF image and get accurate OCR content that can be copied and pasted. And, yes, lots of folks do something similar with screenshots from protected PDFs to grab all the text (without the need to retype it). Simple non-expert scripts (such as Tornado's "Do It Again" freeware) and PDF generating software make it easy to process hundreds of pages quickly and accurately (at least as accurately as OCR from images can be from relatively high-res images - not screenshots of documents you are not zooming in on or otherwise capturing with tremendously low spatial resolution relative to the original document).




回答3:


Would installing such fonts in Microsoft Word work it out?

Not necessarily, this is because many at times the information regarding the font is not present inside the pdf. In other words, though a reader can render it fine from the binary, the ascii equivalent (possible if font data is present) is not available.

If not, how could I solve this problem?

Since the problem lies in ambiguous pdf standard (which allows removal of font information), one best practice would be OCR.

Solution:

When I ran into similar problems these are the steps I performed

  1. I converted the whole pdf file in to another pdf (with images as each slides). (I found it optimum if I first convert each slide into tiff using Adobe Acrobat. Then would recombine all these tiffs to make one single pdf). The purpose is to get a pure image (binary) based pdf.
  2. Then, run it through the inbuilt OCR of Adobe Acrobat ('Enhance' feature). This make Adobe generate a fresh set of meta data including all relevant font information. Save this PDF
  3. So, now I have a searchable pdf.


来源:https://stackoverflow.com/questions/29633504/embedded-fonts-in-pdf-copy-and-paste-problems

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!