Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active June 29, 2021 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/ee7d21b2b6c232a60bb673d9aca3bdac to your computer and use it in GitHub Desktop.
Save aspose-com-gists/ee7d21b2b6c232a60bb673d9aca3bdac to your computer and use it in GitHub Desktop.
Convert PUB to HTML XHTML HTML5 Programmatically using C#
string fileName = "1.pub";
MemoryStream stream = new MemoryStream();
// Load input PUB file
Aspose.Pub.IPubParser parser = Aspose.Pub.PubFactory.CreateParser(fileName);
// Parse the input publisher file
Aspose.Pub.Document doc = parser.Parse();
// Convert the PUB file to PDF and save result in a MemoryStream
Aspose.Pub.PubFactory.CreatePdfConverter().ConvertToPdf(doc, stream);
// Load input PDF file from the MemoryStream
Aspose.Pdf.Document document = new Document(stream);
// Initialize HtmlSaveOptions class object
Aspose.Pdf.HtmlSaveOptions options = new HtmlSaveOptions();
// Save output HTML webpage
document.Save("Output.html", options);
string fileName = "1.pub";
MemoryStream stream = new MemoryStream();
// Load input PUB file
Aspose.Pub.IPubParser parser = Aspose.Pub.PubFactory.CreateParser(fileName);
// Parse the input publisher file
Aspose.Pub.Document doc = parser.Parse();
// Convert the PUB file to PDF and save result in a MemoryStream
Aspose.Pub.PubFactory.CreatePdfConverter().ConvertToPdf(doc, stream);
// Load input PDF file from the MemoryStream
Aspose.Pdf.Document document = new Document(stream);
// Initialize HtmlSaveOptions class object
Aspose.Pdf.HtmlSaveOptions options = new HtmlSaveOptions();
// Set Html document type
options.DocumentType = HtmlDocumentType.Xhtml;
// Save output HTML webpage
document.Save("Output.html", options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment