Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save aspose-com-gists/a747b196d7634d4b4740ee9e4526e94b to your computer and use it in GitHub Desktop.

Select an option

Save aspose-com-gists/a747b196d7634d4b4740ee9e4526e94b to your computer and use it in GitHub Desktop.
Edit PUB document metadata and write TIFF conversion output to a stream with Aspose.PUB for .NET.

Working with PUB Documents Examples

Edit PUB document metadata and write TIFF conversion output to a stream with Aspose.PUB for .NET.

Examples

  • Edit metadata in memory: Example-EditMetadata.cs.
  • Write TIFF output to a file stream: Example-WriteOutputToStream.cs.

Both examples use tests-data/Aspose.PUB/halloween-flyer.pub. The metadata example changes the parsed document in memory without saving a PUB file. The stream example saves halloween-flyer_out.tiff under tests-out/Aspose.PUB.Net/WorkingWithDocuments/.

Related Documentation

Related Resources

Requirements

  • .NET 5.0+, .NET Core, or .NET Framework
  • Aspose.PUB for .NET library
Aspose.PUB for .NET – Working with PUB Documents Examples
// Edit the metadata of a parsed PUB document in memory
// Learn more: https://docs.aspose.com/pub/net/programming-with-documents/
// Parse the input Publisher document.
string fileName = Path.Combine(DataDir, "halloween-flyer.pub");
IPubParser parser = PubFactory.CreateParser(fileName);
Document document = parser.Parse();
// Update document metadata. These changes do not save a PUB file.
document.DocumentSummaryInfo.SetCategory("category");
document.DocumentSummaryInfo.SetCompany("company");
document.DocumentSummaryInfo.SetLanguage("language");
document.SummaryInfo.SetComments("comments");
document.SummaryInfo.SetKeywords("keywords");
document.SummaryInfo.SetLastAuthor("last author");
document.SummaryInfo.SetTitle("title");
document.SummaryInfo.SetSubject("subject");
// Convert a PUB document to TIFF using an output stream
// Learn more: https://docs.aspose.com/pub/net/programming-with-documents/
// Parse the input Publisher document.
string fileName = Path.Combine(DataDir, "halloween-flyer.pub");
IPubParser parser = PubFactory.CreateParser(fileName);
Document doc = parser.Parse();
// Write TIFF output to a file stream and close it after conversion.
string outPath = Path.Combine(OutputDir, "halloween-flyer_out.tiff");
using (FileStream outputStream = File.Create(outPath))
{
PubFactory.CreatePubConverter().ConvertToFormat(doc, outputStream, PubExportFormats.Tiff);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment