Tim Kober
Tim Kober

Reputation: 11

How to convert a cairo-pdf to eps without converting fonts to outlines

We use cairo to write pdf-files. The results are great, the files are editable so we can extract text via copy & paste or even open and edit the files in Adobe Illustrator and Inkscape to change the font properties.

But as soon as we convert the PDF to EPS all fonts are converted to outlines.

My favourite tools are pdftops and gs and this is the way I tried it:

gs -sDEVICE=eps2write -dLanguageLevel=3 -dEmbedAllFonts=true -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.eps input.pdf

and

pdftops -eps -level3 input.pdf output.eps

In addition I tried ps2eps, ps2epsi, epspdf and Inkscape via command line, but the result was always the same and all fonts are converted to outlines.

We are using the Dejavu-fonts and the font embedding seems to be OK:

$ pdffonts input.pdf

name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
JTFVDF+DejaVuSans-Bold               TrueType          WinAnsi          yes yes yes      5  0
BTWYHK+DejaVuSansCondensed-Bold      TrueType          WinAnsi          yes yes yes      6  0
VIBPBS+DejaVuSans-Oblique            TrueType          WinAnsi          yes yes yes      7  0
TKGUZX+DejaVuSansCondensed           TrueType          WinAnsi          yes yes yes      8  0

Any idea how to produce EPS-files with editable Fonts?

Here is my file: https://www.dropbox.com/s/11afckra7i8trdq/input.pdf?dl=0

Upvotes: 1

Views: 1305

Answers (1)

KenS
KenS

Reputation: 31199

Ghostscript's eps2write device doesn't convert fonts to outlines. BTW how do you know the fonts are being converted to outlines ?

I'll grab the example file you supplied (kudos! a load of people don't do that) and report back shortly, I can think of 2 possibilities offhand:

  • The file contains transparency. Cairo has something of a habit of creating PDF files which contain transparency operations that don't actually do anything (like setting alpha to 100%). You can't represent PDF transparency in PostScript, so the whole page gets rendered to an image.
  • The file is an image (or similar) with text on top in text rendering mode 3 (neither stroke nor fill). Although the actual text is invisible, Acrobat and other applications will often allow you to cut/paste it. However, PostScript doesn't have a mode for doing this, and since the text doesn't make any marks, it usually just gets dropped.

[Later]

Hmm, complex file. Decompressed this is > 11 MB....

Anyway, the page is in a transparency group:

9 0 obj
<<
  /Type /Page
  /Parent 1 0 R
  /MediaBox [ 0 0 720 720 ]
  /Contents 3 0 R
  /Group <<
    /Type /Group
    /S /Transparency
    /I true
    /CS /DeviceRGB
  >>
  /Resources 2 0 R
>>
endobj

However it looks like Ghostscript decided the transparency could be dropped as the page is not a complete bitmap.

The eps file I get out does not have the fonts converted to outlines, it embeds complete fonts, and it uses them, eg:

8 0 obj
<</BaseFont/ENTCOM+DejaVuSansCondensed-Bold/FontDescriptor 9 0 R/Type/Font
/FirstChar 32/LastChar 220/Widths[
313 0 0 0 0 0 0 0 0 0 0 0 0 374 0 0
0 0 0 0 0 626 626 626 0 0 0 0 0 0 0 0
0 696 686 660 747 615 615 738 753 334 0 697 573 896 753 765
659 765 693 648 614 730 696 993 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 730]
/Encoding 20 0 R/Subtype/TrueType>>
endobj
%%EndResource

9 0 obj
<</Type/FontDescriptor/FontName/ENTCOM+DejaVuSansCondensed-Bold/FontBBox[-362 -176 964 927]/Flags 4
/Ascent 745
/CapHeight 745
/Descent -176
/ItalicAngle 0
/StemV 144
/MissingWidth 540
/FontFile2 17 0 R>>
endobj
%%EndResource
%%BeginResource: file (PDF FontFile obj_17)
17 0 obj
<</Filter/ASCII85Decode
/Length1 6088/Length 7019>>stream
!!*'"!"ApY!!<3t:K&o%z!!!e-!!!""@r5Xnz!!!\J!!!)-@s2r:5.NBR!!!#S!!!("AoMC">68U0
!!!*T!!!##B5Dj*z!!!DJ!!!86BOtU_%6ag,!!!gs!!!!WBP:sc%JC""!!!,V!!!!EBPhj9z!!!f0
.....
Lots of data omitted
.....
!!)s8!!<3$zzzzzzz!!*'"!!6K:Z*:FC?Oo9l!$;IHze&!X4ze&!X4peC[h%QOi,!!*'*zz~>
endstream
endobj

So that's a TrueType font, which is later used:

10 0 0 10 0 0 cm BT
/R8 12.96 Tf
1 0 0 1 262.795 318.916 Tm
[(N)1(E)1(US)0.998415(T)79.0063(ADT)1.00218]TJ
126.609 339.675 Td
[(F)1(IN)1.00218(DO)0.998415(R)1.00218(F)0.998415(F)1.00218]TJ
-338.998 -203.387 Td
[(W)1(O)1(L)166.005(T)1(M)1(E)1(R)1(S)1(H)1(A)29.9863(US)1(E)1(N)1]TJ
373.499 -12.6809 Td
[(M)0.998415(IT)-21.9915(T)0.998415(E)1.00218]TJ
ET

It could be you are using an old version, I used the current version, 9.21. Failing that the obvious question would be 'why do you think the fonts are outlines ?'

Upvotes: 1

Related Questions