Converting a Publisher file doesn’t have to involve Visual Studio or a single line of C#. When you just need a PDF of last year’s brochure, or you’re moving hundreds of PUB files off a shared drive, a command-line tool gets the job done faster.
Aspose.PUB.Convert is a .NET tool, free to install, that converts Microsoft Publisher files from a terminal. In this article, you’ll learn how to install it, convert PUB files from the command line to PDF, Word, EPUB, images, and other formats, and automate bulk conversions with PowerShell and Bash scripts. It works on Windows, Linux, and macOS, and it doesn’t need Microsoft Publisher.
What Is Aspose.PUB.Convert?
Aspose.PUB.Convert is a command-line application built on Aspose.PUB for .NET. It’s distributed as a .NET tool on NuGet, so you install it with one dotnet command and run it from any folder.
The tool is a good fit when you want to:
- Convert files without programming. IT administrators, designers, and office staff can convert PUB files with a single command.
- Migrate archives. Microsoft ended support for Publisher in October 2026, and a short script converts a whole folder of publications to PDF or DOCX.
- Automate workflows. Scheduled tasks, cron jobs, and build pipelines can call the tool and check its exit code.
Install Aspose.PUB.Convert
The tool needs the .NET SDK. Once the SDK is installed, run the following command:
dotnet tool install --global Aspose.PUB.Convert
Check that the installation works by printing the version:
Aspose.PUB.Convert --version
Aspose.PUB Convert Micro Application 26.10.0
Fix the “You must install or update .NET” Error
Aspose.PUB.Convert is built for an older .NET runtime, and version 26.10 asks for .NET 7. If your computer only has a newer version, such as .NET 8 or later, the tool stops with this message:
You must install or update .NET to run this application.
Framework: 'Microsoft.NETCore.App', version '7.0.0' (x64)
Tell .NET to run the tool on the newest runtime available by setting the DOTNET_ROLL_FORWARD environment variable to Major.
In PowerShell:
$env:DOTNET_ROLL_FORWARD = "Major"
In Bash on Linux or macOS:
export DOTNET_ROLL_FORWARD=Major
These commands apply to the current terminal session. To make the setting permanent, add it to your system environment variables or to your shell profile, such as ~/.bashrc.
Command-Line Options
Aspose.PUB.Convert supports the following options:
| Option | Required | Description |
|---|---|---|
-i, --input | Yes | Path to the PUB file to convert |
-o, --output | Yes | Path of the converted file |
-f, --format | No | Output format. If you leave it out, the tool uses the extension of the output file |
-l, --license | No | Path to your Aspose.PUB for .NET license file |
-v, --verbose | No | Prints each stage of the conversion |
--help | No | Shows the list of options |
--version | No | Shows the version of the tool |
Convert a PUB File to PDF from the Command Line
Pass the Publisher file to -i and the name of the PDF file to -o:
Aspose.PUB.Convert -i brochure.pub -o brochure.pdf
The tool sees the .pdf extension and creates a PDF document. Paths can be relative or absolute, so this works too:
Aspose.PUB.Convert -i "C:\Files\Newsletters\winter-2025.pub" -o "C:\Files\PDF\winter-2025.pdf"
Put paths in quotes when they contain spaces.
Convert PUB to Word, EPUB, Images, and Other Formats
Changing the output format only takes a different file extension. The following commands convert the same publication to a Word document, an e-book, and an image:
Aspose.PUB.Convert -i brochure.pub -o brochure.docx
Aspose.PUB.Convert -i brochure.pub -o brochure.epub
Aspose.PUB.Convert -i brochure.pub -o brochure.png
The tool supports these output formats:
| Category | Extensions |
|---|---|
| Documents | .pdf, .xps, .doc, .docx |
| Spreadsheets | .xls, .xlsx, .csv |
| Presentations | .pptx |
| Web and e-books | .html, .mhtml, .epub |
| Images | .jpg, .jpeg, .png, .tiff, .tif, .gif, .bmp, .svg |
| Other | .tex (LaTeX) |
If the output file needs a different extension, set the format explicitly with -f:
Aspose.PUB.Convert -i brochure.pub -o brochure.out -f docx
Show Conversion Details
Add -v to see what the tool is doing. It’s useful for large files and for troubleshooting:
Aspose.PUB.Convert -i brochure.pub -o brochure.png -v
Initialization
PreProcessing
Processing MS Publisher file
Conversion complete. Total duration : 5 s
Batch Convert PUB Files with PowerShell
The tool converts one file per call, so a short loop handles a whole folder. The following PowerShell script converts every PUB file in a folder to PDF and reports any file that fails:
$inputDir = "C:\Files\Publications"
$outputDir = "C:\Files\PDF"
New-Item -ItemType Directory -Force -Path $outputDir | Out-Null
Get-ChildItem -Path $inputDir -Filter *.pub | ForEach-Object {
$output = Join-Path $outputDir ($_.BaseName + ".pdf")
Aspose.PUB.Convert -i $_.FullName -o $output
if ($LASTEXITCODE -eq 0) {
Write-Host "Converted: $($_.Name)"
} else {
Write-Warning "Failed: $($_.Name) (exit code $LASTEXITCODE)"
}
}
A damaged file doesn’t stop the script. The tool prints the reason for the failure, the script logs a warning, and the loop moves on to the next file:
Aspose.PUB Convert failure: OLE stream is too short
WARNING: Failed: broken.pub (exit code 4)
Converted: christmas.pub
Converted: florist-flyer.pub
Converted: halloween-flyer.pub
Change ".pdf" to ".docx", ".epub", or any other supported extension to produce a different format.
Batch Convert PUB Files with Bash on Linux and macOS
On Linux and macOS, a Bash for loop does the same work. This script converts every PUB file in the publications folder to EPUB:
#!/bin/bash
mkdir -p epub
for file in publications/*.pub; do
name=$(basename "$file" .pub)
if Aspose.PUB.Convert -i "$file" -o "epub/$name.epub"; then
echo "Converted: $name"
else
echo "Failed: $name (exit code $?)" >&2
fi
done
Save the script as convert.sh and run it with bash convert.sh. If the tool reports a missing .NET version, set DOTNET_ROLL_FORWARD=Major first, as described in the installation section.
Exit Codes for Scripts
Aspose.PUB.Convert reports the result of each run through its exit code. Scripts and pipelines can use it to detect problems:
| Exit code | Meaning |
|---|---|
0 | The conversion succeeded |
1 | A required option is missing or an option is invalid |
2 | The input file wasn’t found |
3 | The output format isn’t supported |
4 | The PUB file couldn’t be read, for example because it’s damaged |
Apply a License
Without a license, the tool adds an evaluation notice to every converted file. Pass the path of your license file with -l to remove it:
Aspose.PUB.Convert -i brochure.pub -o brochure.pdf -l Aspose.PUB.NET.lic
Note: If the license file can’t be found, the tool prints an error but still converts the file in evaluation mode and returns exit code 0. Check the console output, or open one converted file, to confirm the license is applied.
To try the tool without evaluation notices, request a free temporary license.
Update or Remove the Tool
Get the latest version of Aspose.PUB.Convert with:
dotnet tool update --global Aspose.PUB.Convert
To remove it from your computer, run:
dotnet tool uninstall --global Aspose.PUB.Convert
Convert PUB Files Online
For a one-off conversion on a computer without .NET, use the free Aspose PUB converter in your browser. Upload a Publisher file, pick the output format, and download the result.
Learning Resources
Explore more ways to work with Publisher files:
Conclusion
Aspose.PUB.Convert turns a Publisher file into any of 18 formats, including PDF, Word, EPUB, and images, with a single command. Install it as a .NET tool, set DOTNET_ROLL_FORWARD on newer .NET versions, and wrap it in a PowerShell or Bash loop to convert whole folders. The exit codes make it easy to use in scheduled jobs and pipelines. If you need more control over the conversion, use the Aspose.PUB for .NET library in your own code. For questions, visit our free support forum.
Frequently Asked Questions
How do I convert a PUB file from the command line?
Install the tool using dotnet tool install --global Aspose.PUB.Convert, then run Aspose.PUB.Convert -i input.pub -o output.pdf. The extension of the output file sets the format.
Which formats can Aspose.PUB.Convert create?
The tool converts PUB files to PDF, XPS, DOC, DOCX, XLS, XLSX, CSV, PPTX, HTML, MHTML, EPUB, TEX, SVG, JPG, PNG, TIFF, GIF, and BMP.
How do I fix the “You must install or update .NET” error?
The tool is built for an older .NET runtime. Set the DOTNET_ROLL_FORWARD environment variable to Major so that it runs on the newer .NET version installed on your computer.
Can I convert a folder of PUB files at once?
Yes. Loop through the files with a PowerShell or Bash script and call Aspose.PUB.Convert for each one, as shown in this article.
Does Aspose.PUB.Convert work on Linux and macOS?
Yes. It’s a .NET tool, so it runs on Windows, Linux, and macOS wherever the .NET SDK is installed.
Do I need Microsoft Publisher installed?
No. The tool reads PUB files on its own, so you don’t need Microsoft Publisher or Microsoft Office.
