skip to content
 

Converting from one file type to another

Sometimes you can do this simply by opening the file in the appropriate program (e.g. libreoffice, The GIMP) and using Save As to save it in a different format.

How do I convert a document from...

  1. ps to pdf
  2. pdf to ps
  3. Word to pdf
  4. txt to tex
  5. tex/latex to html
  6. tex/latex to pdf
  7. .dvi to .ps
  8. .ps to ascii text
  9. .ps to various formats eg .fig
  10. .dvi to plain text
  11. .dvi to .pdf
  12. dos to unix (or how to remove the ^M characters in a file)
  1. How do I convert a document from ps to pdf
    To convert a document from ps to pdf use ps2pdf.

     

  2. How do I convert a document from pdf to ps
    To convert a document from pdf to ps use pdf2ps. Syntax is pdf2ps input.pdf output.ps

     

  3. How do I convert a document from Word to PDF
    Adobe Acrobat Pro (Windows) or Libreoffice (Linux).

     

  4. How do I convert a document from txt to tex
    To make a plain text file into a valid LaTeX document, add
    \documentclass{article}
    \begin{document}
    

    to the beginning, and

    \end{document}
    

    to the end. You can also use \section*{Heading 1} and \subsection*{Heading 2} to add headers. The Computing Service run a training course on LaTeX.

     

  5. How do I convert a document from tex/latex to html
    Use latex2html. Type latex2html file.tex or see the man pages for more options.

     

  6. How do I convert a document from tex/latex to pdf
    To convert TeX/LaTeX directly to PDF, pdflatex file.tex (produces file.pdf). Alternatively or if the file has pictures/figures in it, the below will work so long as the figures are of type eps (encapsulated postscript) since those are the only kind that dvips will really cope with. However .gif/.jpg files can usually be converted to .eps fairly easily with gimp.

     

    If you have a latex document called fred.tex then a recipe which works would be:

    # Run latex on it
      latex fred.tex
    # 2nd, 3rd time if there are forward references which need to be right
      latex fred.tex
      latex fred.tex
    
    # Convert to postscript.  -t specifies the paper type (not needed
    # normally, but otherwise the ps2pdf will guess letter size), -Ppdf
    # sets things up for conversion to pdf, -o says where the output will
    # go (a file in this case).
    
      dvips -t a4 -Ppdf -o fred.ps fred.dvi
    
    # Convert postscript to pdf
      ps2pdf fred.ps fred.pdf
    
    This should result in a .pdf file fred.pdf
    

     

  7. How do I convert a .dvi file to a .ps file

     

    dvips -o filename.ps filename.dvi
    

    This will produce filename.ps from filename.dvi. The .dvi part is optional. ie

    dvips -o filename.ps filename
    

    will work just as well.

     

  8. How do I convert a .ps file to a ascii text
    Use the command ps2ascii which will give you a text-only version of the ps file ie ps2ascii file.ps will output the ascii text on the screen, while ps2ascii file.ps file will save the output to a file called file.
    Use ps2ascii --help for more options.

     

  9. How do I convert a .ps file to other vector formats eg graphical for further processing
    Use the command pstoedit. Example usage to convert a .ps file called house.ps to a .fig file is
    
    	pstoedit -f fig house.ps house.fig
    
    

    The pstoedit website contains a complete list of supported formats.

     

  10. How do I convert my .dvi file to text
    First use dvips to convert the file to postscript, then use ps2ascii to convert the postscript to ascii text. You will lose the pictures and other graphics, but maintain the text of the document. This is sometimes useful if you accidentally delete the .tex file. ie to get the ascii from myfile.dvi into a file called myfile
    dvips -o myfile.ps myfile.dvi
    ps2ascii myfile.ps myfile
    

     

  11. How do I convert a document from .dvi format to .pdf

    Use dvipdf.

     

    But sometimes this produces a file in which the superscripts do not look right in acroread. Often when you magnify the file in acroread, the superscripts look correct, as they do when using xpdf to view the resultant .pdf file.
    A way to overcome this problem is to convert the .tex code directly to pdf with pdflatex or pdftex.

     

  12. dos to unix (or how to remove the ^M characters in a file)

     

    dos2unix is a very simple script which converts from DOS or Mac text formats to unix (the name is historical).

     

    usage is

      dos2unix file

    it replaces your file with the converted version. To keep the old file you could use dos2unix -n file newfile.

     

    It also removes Ctrl-Z which occurs at the end of some DOS files.

     

    You can go the other way with unix2dos.