12

Is there any way to convert text to paths? I tried to use Inkscape, but it has some troubles with reading a PDF file.

The PDF is produced by pdflatex (I can't use dvips) with the beamer class and the beamerposter package.

Basically, I understand that Type1 fonts should be enough, however people in our print office require paths instead of text.

egreg
  • 1,121,712
morph
  • 717
  • You can also use dvips with beamer! –  Jul 18 '11 at 18:39
  • no, beamerposter has some problems with dvips and don't produce correct file – morph Jul 18 '11 at 18:44
  • well, I don't know why, hovewer all tips were too much complicated or don't work... In fact, different printer solved my problem... Anyway, my question should be deleted... – morph Jul 20 '11 at 18:14

4 Answers4

3

Try

pdftops -level3 myfile.pdf myfile.ps

(note pdftops not pdf2ps) and then use ghostscript to convert back to pdf with a command something like:

gswin32c -q -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -dNOPAUSE -dPDFSETTINGS=/prepress -dAutoRotatePages=/None -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -sOutputFile=myfile-curves.pdf -c "/show { true charpath currentpoint /jy exch def /jx exch def fill jx jy moveto} bind def /ashow {exch pop exch /j_ax exch def show /j_ax {0} def } bind def /widthshow { show pop pop pop} bind def /awidthshow {ashow pop pop pop} bind def" -f myfile.ps
Display Name
  • 46,933
Lev Bishop
  • 45,462
2

Works also with package beamerposter

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage{pst-text}
\DeclareFixedFont{\RM}{T1}{ptm}{b}{n}{2cm}

\begin{document}

\begin{frame}{News}{}
\pscharpath{\RM Japan won}\par\pause
\pscharpath[fillstyle=solid,fillcolor=red!70]{\RM the World}\par\pause
\pscharpath[fillstyle=solid,fillcolor=blue!70]{\RM Cup}\par\pause
\end{frame}

\end{document}

enter image description here

An alternative with less possibilities for filling is to use an outline font like Biolinum:

\documentclass{beamer}
\usepackage{fontspec}
\setsansfont{Linux Biolinum O}
\newfontface\Outline{Linux Biolinum Outline O} 
\begin{document}

\begin{frame}{News}{}
\fontsize{40}{42}\selectfont\Outline
Japan won\par\pause
the World\par\pause
Cup\par\pause
\end{frame}
\end{document}

This needs a lualatex or xelatex run!

enter image description here

2

I assume you want to convert the entire document into outlines, in this case you can use pdf2ps utility to convert the PDF to outlined PS file, and you can then use ps2pdf to convert it back to PDF (both utilities from Ghostscript).

$ pdffonts test.pdf 
name                                 type              emb sub uni object ID
------------------------------------ ----------------- --- --- --- ---------
PEUCZM+Amiri-Regular                 CID TrueType      yes yes yes     18  0
$ pdf2ps test.pdf 
$ ps2pdf test.ps
$ pdffonts test.pdf 
name                                 type              emb sub uni object ID
---

1

Solution 1

You can use Foxit PhantomPDF (see here):

  1. Select the text you want to convert (Tip: Use Edit Object > Text to only select text)
  2. Right click and press the "Convert to shape object" button at the bottom.

Solution 2

Adobe Acrobat also can do this (see this blog post):

  1. When you have opened the document you want to work with, look at the right side, and in the Tool panel click More Tools button.
  2. Now from here type in the Search bar Preflight and click on Preflight next to Print Production.
  3. In the now open Window, select Profiles.
  4. Make sure you have pressed the green bars button next to the Search field
  5. Enter Convert fonts into the field.
  6. Select any of the Convert fonts to outlines profiles and press the Analyze and fix button.

Solution 3

Alternatively if you don't want to use these proprietary tools you can use the mat2 metadata removal tool, which will also convert all text to paths.

  1. After installation, call it with mat2 /path/to/file.pdf.
  2. The now created file /path/to/file.cleaned.pdf should have all text converted to paths.

Solution 4

Another way is to convert each page the document to an individual SVG file and then reconvert and recombine those (taken from this StackOverflow post).

Convert pages to SVG:

import os, math

import cairo import poppler

def convert(inputname, base=None): '''Converts a multi-page PDF to multiple SVG files.

:param inputname: Name of the PDF to be converted
:param base: Base name for the SVG files (optional)
'''
if base is None:
    base, ext = os.path.splitext(os.path.basename(inputname))

# Convert the input file name to an URI to please poppler
uri = 'file://' + os.path.abspath(inputname)

pdffile = poppler.document_new_from_file(uri, None)

pages = pdffile.get_n_pages()

# Prefix the output template with zeros so that ordering is preserved
# (page 10 after page 09)
output_template = ''.join([
    base,
    '_',
    '%0',
    str(math.ceil(math.log10(pages))),
    'd',
    '.svg'
])

# Iterate over all pages
for nthpage in range(pages):
    page = pdffile.get_page(nthpage)

    # Output file name based on template
    outputname = output_template % (nthpage + 1)

    # Get the page dimensions
    width, height = page.get_size()

    # Open the SVG file to write on
    surface = cairo.SVGSurface(outputname, width, height)
    context = cairo.Context(surface)

    # Now we finally can render the PDF to SVG
    page.render_for_printing(context)
    context.show_page()

    # Free some memory
    surface.finish()

Assembling the SVGs into a PDF:

import rsvg
import cairo

def convert_merge(inputfiles, outputname): # We have to create a PDF surface and inform a size. The size is # irrelevant, though, as we will define the sizes of each page # individually. outputsurface = cairo.PDFSurface(outputname, 1, 1) outputcontext = cairo.Context(outputsurface)

for inputfile in inputfiles:
    # Open the SVG
    svg = rsvg.Handle(file=inputfile)

    # Set the size of the page itself
    outputsurface.set_size(svg.props.width, svg.props.height)

    # Draw on the PDF
    svg.render_cairo(outputcontext)

    # Finish the page and start a new one
    outputcontext.show_page()

# Free some memory
outputsurface.finish()

Kippi
  • 11