PUB file opener
Read PUB files. Open Publisher with API for .NET. Explore our PUB Viewer and .NET API Solution today!
Viewing PUB files made easy: no MS Publisher needed!
Microsoft Publisher (.pub) files are commonly used for creating newsletters, brochures, and flyers. While popular, they can be a challenge to open without the Publisher software.
This is where a cross-platform PUB Viewer application comes in handy. It lets you view the content of PUB files – perfect for situations like presentations or reviews where you just need to see the information. This will leyt you gain insights into file size, dimensions, fonts used, number of fields, and color schemes.
Apart from that this tool goes beyond simple viewing, providing valuable details about the PUB document itself . Here you will get the .NET API Solution that lets you view the MS Publisher document’s properties such as size, width, height, names of the used fonts, the number of fields, and colors.
Read Publisher files on .NET
To view .pub files properties you will need to take the next steps:
- Integrate .NET PUB API, which works not only with single-page documents but also supports multipage .pub files.
- Upload your PUB file using CreateParser() Method of PubFactory Class.
- Parse the document via Parse() Method of IPubParser Interface.
- Print document properties .
Get Started with .NET PUB API
There are two ways to get the product installed:
- Install from the command line as
nuget install Aspose.PUB
or via Package Manager Console of Visual Studio withInstall-Package Aspose.PUB
. - Alternatively, get the offline MSI installer or DLLs in a ZIP file from downloads .
.NET Code to Read PUB files properties
// Load PUB file
var parser = PubFactory.CreateParser("sample.pub");
// Parse file
var doc = parser.Parse();
// Print document properties
Console.WriteLine($"Page width: {GetInchesString(doc.Width)}");
Console.WriteLine($"Page height: {GetInchesString(doc.Height)}");
Console.WriteLine($"Field count: {doc.FieldCount}");
string fontNames = GetCollectionString(doc.FontNames);
if (!string.IsNullOrEmpty(fontNames))
{
Console.WriteLine($"Fonts used in document: {fontNames}");
}
string colors = GetCollectionString(doc.Colors);
if (!string.IsNullOrEmpty(colors))
{
Console.WriteLine($"Colors used in document: {colors}");
}
To see the full code ReadPubDocument.cs example go the Aspose.PUB.Examples.sln solution, in the net-examples of the Aspose.PUB Documentation where you can also find other examples on how to use the library.
// Description of invoked methods:
private string GetInchesString(uint size)
{
double value = (double)size / EMUsesInOneInch;
return Convert.ToString(value) + " inches";
}
private string GetCollectionString(ICollection array)
{
if (array.Count == 0)
{
return null;
}
StringBuilder sb = new StringBuilder();
int num = -1;
IEnumerator enumerator = array.GetEnumerator();
while (enumerator.MoveNext())
{
num++;
sb.Append(GetObjectStirng(enumerator.Current));
if (num < (array.Count - 1))
{
sb.Append(", ");
}
}
return sb.ToString();
}
private string GetObjectStirng(object value)
{
if (value is Color)
{
Color colorVal = (Color)value;
return $"RGB({colorVal.R}, {colorVal.G}, {colorVal.B})";
}
return value.ToString();
}
FAQ
1. How can I view Microsoft Publisher files?
Publisher files can be opened by little software that is not free. But to view the content of the file online you can use a cross-platform Viewer application.
2. Can I open a Publisher File in Word?
To open PUB files in MS Word you need to them. You can do it online using the web Converter application.
3. Is the functionality free?
The cross-platform app is free, when for the API solution you can get a free Trial and then buy the product if needed.
Support and Learning Resources
- Learning Resources
- Documentation
- Source Code
- API References
- Product Support
- Free Support
- Paid Support
- Blog
- Release Notes
- Why Aspose.PUB for C++?
- Customers List
- Success Stories