I'm trying to copy/paste a bunch of Vietnamese text from a PDF document to Notepad++ (or anything, nothing works). The pasted text is different than the source text. What would be the best way to go about fixing this?

For example:

Source Text: (See screenshot for source text) enter image description here

Pasted Text: Papaya Salad ~ GÕi ñu ñû Tôm

Thanks so much.

Edit: It appears that if the source is a Word document it copies & pastes as expected. PDF is the issue here.

  • Could the font used in the PDF be different per chance, causing a few characters to be defined differently? – jay Jan 19 '12 at 22:54
  • @jay That would be interesting.. Unfortunately this is a client supplied PDF, I have no way of changing the font. Time to require word documents in the future... Thanks – Mahdi.Montgomery Jan 19 '12 at 23:00
  • Try converting the PDF to Word and see what you get – jay Jan 19 '12 at 23:05

It is because the encoding used in the PDF is arbitrary.

Acrobat File properties

From Some PDF in Vietnamese I found in the intertubes

"Encoding:Custom" probably means a (random seeming) encoding made up for it's own convenience by the program that produced this PDF.

"Embedded Subset" means The program didn't need a huge number of characters from this font so it just picked the few it needed and arranged them in seemingly random order (maybe the order the program encountered them in the text) and the newly invented encoding is based on this ordering.

Its not really "characters". Basically the PDF no longer has any universally meaningful information about "which character" it has. It just has an indexed bunch of shapes and a list of positions and sizes where it displays those indexed shapes.

Wikipedia says

CID-keyed fonts may be made without reference to a character collection by using an "identity" encoding, such as Identity-H (for horizontal writing) or Identity-V (for vertical). Such fonts may each have a unique character set, and in such cases the CID number of a glyph is not informative; generally the Unicode encoding is used instead, potentially with supplemental information.

So you might try to see if it makes sense in say UTF-16 BE encoding.

  • Well that's inconvenient. My PDF has: "Encoding: Ansi", "Encoding: Ansi", "Encoding: Identity-H". I assume there's no way to change this in the compiled PDF? Thanks! – Mahdi.Montgomery Jan 19 '12 at 23:06
  • @Mahdi.Montgomery: It is inconvenient. If you can work out what "Identity-H" is (and whether it's consistent from PDF to PDF) you could probably work out a definition you could feed to an encoding converter such as iconv which could then convert your extracted text. Most of us would probably not find it worthwhile. – RedGrittyBrick Jan 19 '12 at 23:16
  • I find it much more time effective to send an annoying email. Thanks again. – Mahdi.Montgomery Jan 19 '12 at 23:20

I found a solution that worked for me - though cannot explain why. When I opened the PDF in Acrobat, I was unable to copy and paste the Vietnamese characters. However, if I opened the PDF in the Preview App Version (I have version 5.5.3 (719.31)) on my Mac, I could copy and paste with no problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.