今天有使用者問我,她在網頁上開啟了某個 PDF 檔案,但底色的色塊都消失了,導致有些深色色塊前置的文字,因為文字設定成白色,這些白字全被預設的白色底色吃光光。
測試了一下,發現是一個 Google Chrome 瀏覽器獨有的問題。在以下瀏覽器測試都正常:
- Microsoft Edge
- Safari
- Mozilla Firefox
目前得到的解法有:
- 使用 Chrome 以外的瀏覽器觀看該份 PDF 檔
- 硬是要用 Chrome 看,就安裝 Chrome 的擴充套件 Adboe Acrobat Extension
- 把檔案另存下來到電腦本機,用 Adobe Reader 觀看
上網查了一下,依據 "Issue 438421: Part of PDF Renders blank in Chrome",看起來問題是出自於這段:
"The image obj "18 0 obj" using run length encoding and specifies /BitsPerComponent to 1.
In PDF standard 8.9.5.1, a RunLengthDecode filter has to conform to 8-bit samples.
Pdfium checks the filter type and set /BitsPerComponent to 8 for RunLengthDecode filter, which makes the figure not decoding properly.This issue is due to the document not conforming to the standard. So either we loose the compatibility check like pdfium used to be (which will suffer security issue), or keep it as it is now."
「文件中的圖片物件“18 0 obj”使用運行長度編碼 (run length encoding, RLE),將 /BitsPerComponent 指定為 1。
在 PDF 標準 8.9.5.1 中,解碼器 (RunLengthDecode filter) 必須符合 8 位元取樣。
Pdfium 檢查過這個 filter 類型,並為解碼器設定 /BitsPerComponent 為 8,這會導致圖片無法正確解碼。
這個問題是因為文件不符合標準。因此,我們要嘛就像 pdfium 過去那樣放寬相容性檢查(會有安全性議題),要嘛就保持現在的狀態。」
我自己測試了一下,在 Illustrator 另存 PDF 檔時,在「一般」頁籤選擇將「標準」降為 "PDF/X-3:2003"(原本是「無」),連帶「相容性」會從 "Adboe 7 (PDF 1.6)" 自動降至 Adboe 4 (PDF 1.3)。這樣乍看之下檔案就沒問題了,不過不知道增減 PDF 標準與相容性,會不會對內容造成其他影響。