# How to import an external pdf file leaving text as text?

When Importing in Mathematica (v10.3) a pdf file containing some text, the text is "vectorialized", meaning that it does not seem to be loaded as text, and re-exporting the imported file produces a file in which the text is not selectable.

Consider for example the following code:

Export["test.pdf",
Plot[x, {x, 0, 1}]
]
Export["test2.pdf",Import["test.pdf"]]


As you can test, while the text in test.pdf can be selected, the text in test2.pdf cannot, and opening it for example with Inkscape shows that it is not really exported as text.

How can I import the text in external pdf files as text?

• From the Docs: Import["test.pdf", "TextOutlines" -> False]. – Alexey Popkov Dec 1 '15 at 13:38
• @AlexeyPopkov somehow I missed that on the docs, thanks! – glS Dec 1 '15 at 13:44
• @AlexeyPopkov now that was useful for me, too (never needed before, but filed for future reference). How about answering anyway? Personally, I would be in favor of reopening, as this may be useful for others. – Yves Klett Dec 1 '15 at 18:26
• @YvesKlett I will post an answer if the question will be reopened. Actually I thought that this option is widely known (it is used in many answers on this site). But if an experienced user like you find it useful I think we should reopen the question! Also, not every PDF file can be imported correctly with this option, but it is another and quite long story... I'm voting to reopen. – Alexey Popkov Dec 1 '15 at 20:08
• Looking forward to your answer 😊 – Yves Klett Dec 1 '15 at 20:52

According to the Documentation page for PDF format (under the "Options" section) there is "TextOutlines" option which controls "whether to import characters as outlines". You should set it to False for importing text as characters instead of outlines:
Import["test.pdf", "TextOutlines" -> False]

ImportString[ExportString["αβγ", "PDF"], "PDF", "TextOutlines" -> False]

At the same time I seem to remember situations when Import correctly recognized Greek letters in PDF files NOT created by Mathematica. I guess that this is encoding issue.