PDFから取り出した文字が文字化けするときの対処法
この記事のポイント
- フォントの埋め込み方によって、取り出せないことがある
- 見た目は正しくても、文字データが別のコードのことがある
- 元のファイルから、PDFを作り直すと解決することが多い
PDFから、文字を取り出したら、意味不明な記号になっていた、空白だらけだった。そんな「文字化け」の、原因と対処法を、PDFから文字を抜き出す を使う前提で、説明します。
文字化けの、主な原因
- 文字の、埋め込み方:PDFは、文字を、特殊な方法で、保存していることがあります。その場合、取り出した文字が、元の文字と、対応しないことがあります。
- 特別なフォント:独自のフォントを使った、PDFで、起こりやすいです。
- 日本語の、縦書きや、特殊な書式:順番や、読み取りが、乱れることがあります。
- 画像の文字:スキャンしたPDFは、文字として、入っていません。
確かめる方法
- 別のPDFアプリや、ブラウザで、PDFを開きます。
- 文章を、選択して、コピーし、メモに、貼ってみます。
- そこでも、化けるなら、PDFそのものの、作りが、原因です。
対処法
- ページの区切りの、設定を変える:「入れる」と「入れない」で、結果が、違うことは、ほとんどありませんが、試してみます。
- ほかのツールや、アプリで、試す:PDFの作りによっては、別の方法で、読めることがあります。
- OCRを使う:PDFを、画像にして、文字認識(OCR)で、読み取ります。化けた文字より、読み取れることが多いです。
- 元のデータを、探す:PDFの、もとの、Wordや、Excelのファイルが、あれば、そちらから、文字を、取り出します。
OCRで、読み取る手順
- 「PDFを画像に変換」で、ページを画像にします。
- 「文字認識(OCR)」で、画像から、文字を、読み取ります。
- 結果を、元の文章と、見比べます。
OCRにも、誤りがあります。大事な内容は、必ず、元の文章と、確認してください。
化けやすい、内容
- 数式や、記号
- 縦書きの文章
- 表や、段組みの、複雑なレイアウト
- 古い資料や、特殊なフォント
つまずきやすい点
- 一部だけ、化けている:そのページ、またはその部分のフォントが、特殊です。
- 英数字は、読めるが、日本語が、化ける:日本語の、フォントの、埋め込みに、問題がある可能性があります。
- どれを、試しても、だめ:OCRが、最後の手段です。
よくある質問
文字化けを、自動で、直せますか?
このツールでは、できません。取り出す前の、情報が、失われていることが、あるためです。
見た目は、きれいなのに、なぜ化けるのですか?
PDFは、見た目を、再現するための、形式です。文字の、意味を、正しく、保存しているとは、限りません。
まとめ
文字化けは、PDFの作りが原因のことが多いです。OCRが、有効な対処法になります。
PDFから文字を抜き出すを使う(無料)あわせて使えるツール
- PDFを画像に変換:PDFの各ページを、JPEGまたはPNGの画像として保存します。
- PDFのページを抜き出し・削除:PDFから、必要なページだけを残す、または不要なページを消します。
- PDFを圧縮:PDFを、指定したサイズ以下に小さくします。提出先の容量制限に合わせたいときに。
同じツールの、ほかの解説
What to Do When Extracted PDF Text Is Garbled
Key points
- Depending on how fonts are embedded, extraction can fail
- The text data can differ from what's displayed
- Remaking the PDF from the original often solves it
You extracted text from a PDF and got meaningless symbols or lots of blanks. Here are the causes and fixes for such "garbled text", assuming you use Extract Text from PDF.
Main causes of garbled text
- How the characters are embedded: PDFs can store text in a special way. In that case the extracted characters may not correspond to the original ones.
- Special fonts: this happens easily with PDFs that use their own fonts.
- Vertical Japanese text and special formatting: the order and reading may be disturbed.
- Text in images: a scanned PDF does not hold text as text.
How to check
- Open the PDF in another PDF app or a browser.
- Select some text, copy it and paste it into a note.
- If it is garbled there too, the way the PDF is built is the cause.
What to do
- Change the page separator setting: "Include" versus "Do not include" rarely changes the result, but try it.
- Try another tool or app: depending on how the PDF is built, another method may read it.
- Use OCR: turn the PDF into images and read them with text recognition (OCR). It often reads better than the garbled text.
- Look for the source data: if you have the original Word or Excel file, extract the text from that.
Steps for reading with OCR
- Turn the pages into images with "PDF to Image".
- Read the text from the images with "Text Recognition (OCR)".
- Compare the result with the original text.
OCR also makes mistakes. For important content, always check against the original.
Content that tends to garble
- Formulas and symbols
- Vertical text
- Tables and complex multi-column layouts
- Old documents and special fonts
Common stumbling blocks
- Only part of it is garbled: the font on that page or part is special.
- Letters and digits are readable but Japanese is garbled: there may be a problem with how Japanese fonts are embedded.
- Nothing works: OCR is the last resort.
Frequently asked questions
Can garbled text be fixed automatically?
Not in this tool, because information from before extraction can be lost.
Why does it garble when it looks clean?
A PDF is a format for reproducing appearance. It does not necessarily store the meaning of the characters correctly.
Summary
Garbled text is often caused by how the PDF is built. OCR is an effective fix.
Use "Extract Text from PDF" (free)Tools that go well with this
- PDF to Images: Save each page of a PDF as a JPEG or PNG image.
- Extract or Delete PDF Pages: Keep only the pages you need, or remove the pages you don't.
- Compress PDF: Shrink a PDF to fit under a size you choose, for upload limits.