I use GS with DjVu driver, as in this example:
gs %gs_args% -dProvideUnicode -dExtractText -sDEVICE=djvusep -o out.sep in.ps
and noticed issue, that with some files text is not correctly extracted (I get question marks in clipboard on copying text from generated file).
I thought it’s some issue with encoding, and removed -dProvideUnicode switch, but then text is not extracted at all, and I assume that -dExtractText flag, specific only to this driver, needs it to function properly.
Trying to run single page PDF file (that generated in.ps through ps2write device), with ps2ascii gives also no text. But other tools like pdfminer, xpdf, extract correct text. Also PDF viewers like SumatraPDF that uses mupdf, or Acrobat, extract the text as expected.
Does anyone maybe knows something about these undocumented switches, and what could be the problem here?
Update: This only happens if I go through ps2write route. If instead I use PDF directly there is no issue.
Here is encoding info from the PDF file:
c:\temp>pdf-parser -s encoding sample.pdf
obj 11 0
Type: /Font
Referencing: 12 0 R, 20 0 R
<<
/BaseFont /XQKNMY+TT14112O00
/FontDescriptor 12 0 R
/Type /Font
/FirstChar 32
/LastChar 144
/Widths [
253 0 0 0 0 0 0 0 293 293 0 0 220 313 220 0
0 467 467 0 0 0 467 0 467 467 0 0 0 0 0 0
0 680 0 0 0 653 0 773 760 0 0 740 0 833 0 0
0 0 0 480 613 0 680 0 0 0 0 0 0 0 0 0
0 407 513 414 500 414 320 447 513 227 0 467 227 773 513 513
513 0 333 367 293 487 467 667 460 414 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
220]
/Encoding 20 0 R
/Subtype /Type1
>>
obj 20 0
Type: /Encoding
Referencing:
<<
/Type /Encoding
/BaseEncoding /WinAnsiEncoding
/Differences [
144/quoteright]
>>
This isn’t really a Ghostscript question. The djvu device is decidedly non-standard in a Ghostscript build. I can’t tell you anything about the switches, because they are specific to the DejaVu device.
If all you want to do is extract the text from a file you could use the txtwrite device (with recent versions of Ghostscript).
If you use a PDF file then a ToUnicode CMap may be present in the file and can be used to get Unicode information about the text. PostScript does not contain ToUnicode CMaps and so the Unicode information is NOT available from the PostScript file. I would imagine this is why the ps2write output can’t have text extracted from it by the device.