Skip to the page

How to use Microsoft’s free script to turn .pub files into PDFs

Microsoft has a free script that turns many Publisher files into PDFs. A script is a small file that tells your computer what to do. You start it by typing a few lines, and we show you which ones.

The script only works if you still have Publisher. If your Publisher is gone, you can turn a whole folder into PDFs here, and you don’t have to type anything.

Written by the people who make PublishAgain. Updated .

Is the script right for you?

If you have Publisher, it’s the best way to make your PDFs. Publisher made your files, so it knows just how they should look. But the script is made for people who are used to computers, so pick the way that fits you.

Microsoft’s script
It’s free. You need Windows and a working Publisher, and you type a few lines.
A folder on our site
You don’t need Publisher, and you don’t type anything. You can look at all the PDFs for free, and you pay one time to save them. Choose a folder.
LibreOffice
It’s a free program that can read .pub files. You don’t need Publisher, but you type one long line. Some pages may come out wrong.
One file at a time
In Publisher, choose File, then Save As, and pick PDF. If you have only ten files, this is the easy way.

Get ready

  • Make a copy of your folder, and use the copy.
  • Are the files in OneDrive? Right-click the folder and choose “Always keep on this device”. Then wait for the green check marks.
  • Try it with five files before you do them all.

Run the script

  1. Download it from Microsoft

    The link is on Microsoft’s page about the end of Publisher. Look for the part about changing many files. The script is called Convert-PubFileToPDF.ps1, and it goes to your Downloads folder.

  2. Close Publisher

    Then open the Start menu, type PowerShell, and open Windows PowerShell. You get a window where you can type.

  3. Paste these three lines, one at a time

    Press Enter after each one. The first line goes to your Downloads folder. The second one tells Windows that you trust the script. The third one lets scripts run, but only in this window.

cd "$HOME\Downloads"
Unblock-File .\Convert-PubFileToPDF.ps1
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process

Now start the script with the next line. Put the name of your own folder between the quote marks. The word -Recurse means “look in the folders inside it too”. If you don’t want that, leave it out.

.\Convert-PubFileToPDF.ps1 -Filter "C:\Newsletters\*.pub" -Recurse

When it’s done, it shows you which files worked and which ones didn’t. It can take a long time. One church said on Microsoft’s forum that it took about six hours to do all of its files.

If you see an error

“The term … is not recognized”
The line has to start with a dot and a backslash, like this: .\ Check that they are there. Also check that you pasted the line that starts with cd first.
“Running scripts is disabled”
Paste the Set-ExecutionPolicy line again in the same window. Windows forgets it when you close the window. If it still doesn’t work, your IT person may have turned scripts off. Microsoft’s page about this setting can help them.
It says the PDF is already there
The script won’t save over an old PDF. Move the old one to another folder and run the script again.
It stops and nothing happens
Look behind your other windows. Publisher may be asking you something, like where a picture is. Answer it, and the script goes on.

If you don’t have Publisher

You can do it right in your browser. Go to our page for folders and choose your folder. We look in the folders inside it too, and make a PDF of every .pub file. You can do up to 500 files at a time. The files stay on your computer.

The start page of the PublishAgain editor. Below the box for opening a .pub file it says: Have a whole folder of old files? Turn them all into PDFs.
You can also start from the editor. The link is below the yellow button.

You see a picture of each PDF for free, and we mark the ones you should check. When you’re happy with them, you pay one time and save them all. You get one download, with the PDFs in the same folders as before. It also has a list called “Please check.txt”, if there are files that need a look.

The free way without Publisher

LibreOffice is a free office program. You can get it from libreoffice.org. Install it, and close it before you start.

  1. Open your folder in File Explorer

    Click on the long box at the top that shows where you are. Type cmd and press Enter. A black window opens.

  2. Paste this line and press Enter

    It makes a PDF of each .pub file in that folder. The PDFs go into a new folder called PDF.

for %f in (*.pub) do "C:\Program Files\LibreOffice\program\soffice.com" --headless --convert-to pdf --outdir PDF "%f"

On a Mac, open Terminal. Type cd and a space, drag your folder onto the window, and press Enter. Then paste this line:

/Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to pdf --outdir PDF *.pub

LibreOffice’s help page tells you what each part of the line does.

Look at your PDFs

No way is perfect, so open some of the PDFs and look at them. Start with the ones that matter most, like forms and certificates. Are all the words there? Do the tables look right? If one is wrong and you still have Publisher, make that PDF again in Publisher.

What we tried

We didn’t run Microsoft’s script. The steps come from Microsoft’s pages, and the help with errors also comes from people on its forum. We tried LibreOffice 26.8 on a Linux computer, and not on Windows or a Mac. It made PDFs of all eight files we gave it. Flyers looked good, but some lists lost their dots, and the rows in one table ran into each other. Read more about that test.

Questions people ask

Does the script work without Publisher?

No. It opens each file in Publisher and saves it as a PDF. So you need a Publisher that still opens and still has its license.

Does it change my .pub files?

Microsoft made it to save new PDF files. We haven’t run it ourselves, so make a copy of your folder first and use the copy.

Can I delete the .pub files after that?

Please keep them. A PDF is good for reading and printing, but it’s hard to change. You will want the .pub file when you make next year’s copy.

What about files with a password?

Open them in Publisher and take the password off first. Do that while you still have a Publisher that works.

Is Publisher already gone?

It’s free to open a file and look at it. When you want to print, you pay one time.

$79 one time. The price goes up to $159 on December 27. No monthly fees.

Are your files on this computer?

Pick a file you know well. Then you can see right away if it looks good.

Are they on another computer?

Send yourself the link. Then open the email on that computer.

Or type publishagain.com on your computer.