{"id":28297,"date":"2020-03-04T16:52:30","date_gmt":"2020-03-04T21:52:30","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=28297"},"modified":"2020-03-04T16:52:30","modified_gmt":"2020-03-04T21:52:30","slug":"optimizing-pdf-file-size","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2020\/03\/04\/optimizing-pdf-file-size\/","title":{"rendered":"Optimizing PDF File Size"},"content":{"rendered":"<p><a href=\"https:\/\/pspdfkit.com\/blog\/2020\/optimizing-pdf-file-size\/\">Patrik Weiskircher<\/a>:<\/p>\n<blockquote cite=\"https:\/\/pspdfkit.com\/blog\/2020\/optimizing-pdf-file-size\/\">\n<p>However, [incremental saving] also causes the file size to grow and grow and never get smaller. This is especially noticeable if you work with a lot of images. And even if you remove an image, it still is included in the PDF; you only instruct your PDF viewer to not show it again.<\/p>\n<p>[&#8230;]<\/p>\n<p>Another nice feature of PDFs is that objects like fonts and images can be shared across pages &mdash; a feature that was specifically made in an effort to save on the size of files. This means you can have an image logo on each page and it is only included in the PDF file once.<\/p>\n<p>[&#8230;]<\/p>\n<p>So right before we start saving the document, we go through the entire PDF file and collect a list of all the reachable object numbers. Then, when saving the PDF, but before we write out an indirect object, we compare its objects number with the list we collected, and if the object isn&rsquo;t included, we simply don&rsquo;t write it out.<\/p>\n<\/blockquote>\n\n<p>I can&rsquo;t tell from this whether they coalesce duplicate objects or only garbage collect unreferenced ones.<\/p>","protected":false},"excerpt":{"rendered":"<p>Patrik Weiskircher: However, [incremental saving] also causes the file size to grow and grow and never get smaller. This is especially noticeable if you work with a lot of images. And even if you remove an image, it still is included in the PDF; you only instruct your PDF viewer to not show it again. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2020-03-04T21:52:33Z","apple_news_api_id":"1909671c-432a-424c-8496-1d80b496a9a7","apple_news_api_modified_at":"2020-03-04T21:52:33Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/AGQlnHEMqQkyElh2AtJappw","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[2],"tags":[288,31,1667,30,1666,138,345,1424],"class_list":["post-28297","post","type-post","status-publish","format-standard","hentry","category-technology","tag-garbargecollection","tag-ios","tag-ios-13","tag-mac","tag-macos-10-15","tag-optimization","tag-pdf","tag-pspdfkit"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/28297","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=28297"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/28297\/revisions"}],"predecessor-version":[{"id":28298,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/28297\/revisions\/28298"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=28297"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=28297"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=28297"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}