Почему PDF-файлы, созданные из MS Word, такие большие?

8758
Borek Bernard

Я создал простой документ MS Word, содержащий только это предложение:

Это небольшой документ.

Ничего больше. Затем я сохранил этот документ в формате DOCX и PDF. Вот размеры файлов:

DOCX: 12 кБ
PDF: 89 кБ

Технически это различие огромно, и оно действительно начинает меня беспокоить, когда в основном текстовые документы, размер которых в DOCX составляет десятки килобайт, начинают генерировать файлы PDF размером сотни килобайт . Что такого неэффективного в формате PDF? Или просто Word использует какой-то ужасный алгоритм вывода?

Кстати, настройки вывода PDF были установлены для создания наименьшего возможного файла:

Параметры вывода PDF

70
Я предполагаю, что PDF-файл встраивает шрифт, который необходим, чтобы документ был действительно переносимым. AFH 8 лет назад 28
Вы можете открыть свойства, чтобы увидеть, встроен ли шрифт или нет phuclv 8 лет назад 0
Можете ли вы добавить ссылку на `pdf` и, возможно, тоже` docx`? Hastur 8 лет назад 0
Да, подмножество шрифтов встроено. Это может быть так. Я пытался повторить одно и то же предложение несколько сотен раз, и размер файла PDF вырос только на 4 КБ, что примерно так. (DOCX остался на 12 КБ, что неудивительно, поскольку это сжатый формат, а повторный текст вряд ли займет новые байты.) Borek Bernard 8 лет назад 2
Параметр «Минимальный размер (публикация в Интернете)», вероятно, влияет только на качество встроенных изображений, а не шрифтов. Arjan 8 лет назад 0
@AFH Пятно на! Интересно, будут ли в него также встраиваться обычные шрифты, такие как Arial? MonkeyZeus 8 лет назад 0
@AFH Он не встраивает Arial. http://i.stack.imgur.com/aUZgt.png MonkeyZeus 8 лет назад 1
Думая об этом с точки зрения сложности Колмогорова, Microsoft Word больше, чем ваш обычный просмотрщик PDF, на несколько сотен килобайт. hobbs 8 лет назад 1
Я думаю, что реальный вопрос заключается в том, почему ваш формат текстовой обработки намного больше, чем эквивалентный LaTeX ... :-p Toby Speight 8 лет назад 8
Кроме того, помните, что DOCX - это просто zip-файл, поэтому у вас есть встроенное сжатие на уровне документа. У PDF есть некоторые методы внутреннего сжатия (потоки), но есть много преамбул (токенов / имен), окружающих те, к которым не применяется сжатие. Chris Haas 8 лет назад 1

3 ответа на вопрос

103
rene

If you open the PDF in notepad++ you'll find:

9 0 obj <</Filter/FlateDecode/Length 79100/Length1 171804>> stream xœì} XTGºvÕ9½/t7Ðl ..... many more bytes ... ëH| endstream endobj 10 0 obj 

and that object is referenced here at the end in the /FontFile2 instruction:

6 0 obj <</Type/FontDescriptor/FontName/ABCDEE+Calibri/Flags 32/ItalicAngle 0/Ascent 750/Descent -250/CapHeight 750/AvgWidth 521/MaxWidth 1743/FontWeight 400/XHeight 250/StemV 52/FontBBox[ -503 -250 1240 750] /FontFile2 9 0 R>> endobj 

The Fonts used by the Word document gets embedded into the PDF so the pdf is self-contained.

I used this slide-deck to decypher the PDF instructions.

If you want to prevent the fonts being embedded in the PDF file make sure your Word document makes use of one of the 14 standard typefaces available in PDF viewers, (source Wikipedia)

  • Times New Roman > Times (v3) (in regular, italic, bold, and bold italic)
  • Courier New > Courier (in regular, oblique, bold and bold oblique)
  • Arial > Helvetica (v3) (in regular, oblique, bold and bold oblique)
  • Symbol > Symbol
  • Wingdings > Zapf Dingbats
Связанный: http://superuser.com/questions/607840/how-can-i-save-a-word-document-as-a-pdf-without-any-embedded-fonts Borek Bernard 8 лет назад 6
Примечание: [связанная слайд-колода] (http://www.adobe.com/content/dam/Adobe/en/technology/pdfs/PDF_Day_A_Look_Inside.pdf) (презентация Powershell) стоит прочитать. Очень подробно. Не пропустите комментарии, где он объясняет структуру PDF nixda 8 лет назад 2
2
Cody Gray

This has happened to me many times in Microsoft Word when trying to export a simple manuscript to PDF. A 5–8 page Word document, ~50 KB in size, will end up as a 10+ MB PDF file, which is far too large to reasonably email to someone.

Rene's answer is on the right track—the problem is that fonts get embedded into the document—but just using one of the standard typefaces won't necessarily solve the problem.

All of my documents were in Times New Roman, using nothing fancier than bold and italics. Or so I thought. It turns out that I have automatic kerning enabled in my default template (for obvious reasons). When exporting to PDF, Word was actually embedding each of those ligatures as a separate font object into the document, bloating it beyond all belief.

The fix is simple, you just have to remember to do it each time:

  1. Select all of the text in the document.
  2. Format → Font → Advanced
  3. Uncheck "Kerning for fonts"

Interestingly, you can leave ligatures, contextual alternatives, and other advanced typography features enabled; they have no perceptible effect on the size of the resulting PDF.

Re-export the document as a PDF, and it's down to a hundred or so KB. Unfortunately, the kerning is sub-par, so I wouldn't recommend printing this way, but it works fine for emailing a document.

-3
Ben Sandeen

To give a less technical answer that may help is that PDFs use vectors (i.e.: mathematical equations) to describe everything you see. All the curves and lines are defined by mathematical equations, and so there will necessarily be a lot of information to hold, particularly when you have images in your documents.

The benefit of this is that you can theoretically zoom in infinitely close without losing any resolution or detail, because the lines and curves have no width, so they can scale with your zoom.

Just like how Google's recent font change reduced the size of the logo from ~14KB to ~300B, simpler fonts will likely help reduce your file size.

Эта аналогия не работает. Совсем. Изменение логотипа Google было связано не только с шрифтом, но и с градиентами на плоскую поверхность, что делает разницу в размере. Кроме того, экспорт документа в большое растровое изображение будет намного больше, чем шрифт + текст. Математические уравнения, как вы вводите в заблуждение, представляют собой просто целочисленные пары координат, которых на глиф может быть несколько десятков. И поскольку это шрифт, его не нужно повторять для каждой буквы. Joey 8 лет назад 4

Похожие вопросы