How to convert Word to PostScript in C#
PostScript is a page description language that is an industry standard for outputting high-resolution text and graphics. From Version 6.11.2, Spire.Doc supports to convert doc/docx to a postscript file in both WinForm app and ASP.NET app. This article will demonstrate how to convert word to PostScript in C# and VB.NET.
Firstly, view the sample word document:

using Spire.Doc;
namespace Word
{
class Program
{
static void Main(string[] args)
{
Document doc = new Document();
doc.LoadFromFile("Sample.docx", FileFormat.Docx2010);
doc.SaveToFile("Result.ps", FileFormat.PostScript);
}
}
}
Imports Spire.Doc
Namespace Word
Class Program
Private Shared Sub Main(ByVal args As String())
Dim doc As Document = New Document()
doc.LoadFromFile("Sample.docx", FileFormat.Docx2010)
doc.SaveToFile("Result.ps", FileFormat.PostScript)
End Sub
End Class
End Namespace
Effective screenshot of the resulted PostScript file converted from .docx document:

Add a Cover Image when Converting Word to EPUB in C#, VB.NET
We already have the documentation introducing how to convert Word to EPUB. However, you may want to add a cover image to EPUB when creating an EPUB book from a Word document. The following code snippets will demonstrate the same.
Step 1: Create a Document instance and load a sample Word file.
Document doc = new Document();
doc.LoadFromFile("SampleWordFile.docx");
Step 2: Load a picture to DocPicture object.
DocPicture picture = new DocPicture(doc);
picture.LoadImage(Image.FromFile("CoverImage.jpg"));
Step 3: Add the picture to EPUB as cover image when creating EPUB from the Word document.
doc.SaveToEpub("output.epub", picture);
Output:

Full Code:
using Spire.Doc;
using Spire.Doc.Fields;
using System.Drawing;
namespace DOCTOEPUB
{
class Program
{
static void Main(string[] args)
{
Document doc = new Document();
doc.LoadFromFile("SampleWordFile.docx");
DocPicture picture = new DocPicture(doc);
picture.LoadImage(Image.FromFile("CoverImage.jpg"));
doc.SaveToEpub("output.epub", picture);
}
}
}
Imports Spire.Doc
Imports Spire.Doc.Fields
Imports System.Drawing
Namespace DOCTOEPUB
Class Program
Private Shared Sub Main(args As String())
Dim doc As New Document()
doc.LoadFromFile("SampleWordFile.docx")
Dim picture As New DocPicture(doc)
picture.LoadImage(Image.FromFile("CoverImage.jpg"))
doc.SaveToEpub("output.epub", picture)
End Sub
End Class
End Namespace
Convert ODT to DOC or DOCX and Vice Versa in C#, VB.NET
A file with the .ODT file extension is an OpenDocument Text document file. These files are most often created by the free OpenOffice Writer word processor program. ODT files are similar to the popular DOCX file format used with Microsoft Word. Both of the two file types can hold things like text, images, objects, and styles.
However, when you open an ODT document in Microsoft Word, the formatting of the ODT document may differ as a result of the two programs not sharing the same features. When converting ODT to DOCX or vice versa, the data and content will be converted successfully, but may not including the original formatting.
Following code snippets introduce how to convert ODT to DOC or DOCX and vice versa using Spire.Doc.
ODT to DOCX
To convert ODT to DOC, change the file extension and file format to .Doc in SaveToFile method.
using Spire.Doc;
namespace ODTtoDOCX
{
class Program
{
static void Main(string[] args)
{
Document doc = new Document();
doc.LoadFromFile("SampleODTFile.odt");
doc.SaveToFile("output.docx", FileFormat.Docx)
}
}
}
Imports Spire.Doc
Namespace ODTtoDOCX
Class Program
Private Shared Sub Main(args As String())
Dim doc As New Document()
doc.LoadFromFile("SampleODTFile.odt")
doc.SaveToFile("output.docx", FileFormat.Docx)
End Sub
End Class
End Namespace
DOCX to ODT
To convert Doc to ODT, load a .Doc file format document when loading the source file.
using Spire.Doc;
namespace DOCXtoODT
{
class Program
{
static void Main(string[] args)
{
Document doc = new Document();
doc.LoadFromFile("SampleODTFile.odt");
doc.SaveToFile("output.docx", FileFormat.Docx);
}
}
}
Imports Spire.Doc
Namespace DOCXtoODT
Class Program
Private Shared Sub Main(args As String())
Dim doc As New Document()
doc.LoadFromFile("SampleODTFile.odt")
doc.SaveToFile("output.docx", FileFormat.Docx)
End Sub
End Class
End Namespace
How to Convert Word to SVG (Scalable Vector Graphics) in C#
SVG (Scalable Vector Graphics) is an image file format and it has the advantage of be edited and indexed easily. It is widely used for interactivity and animation. Starts from Spire.Doc V5.8, Spire.Doc offers a method doc.SaveToFile() to enable developers to save the word document to SVG file format in C# easily. This article will focus on demonstrate how to convert word document to SVG with the help of Spire.Doc by using a simple line of code in C#.
Firstly, please view the original word document:

Step 1: Create a C# project in visual studio, then add a reference to Spire.Doc.dll and use the following namespace.
using Spire.Doc;
Step 2: Create a word instance and load the source word document from file.
Document doc = new Document();
doc.LoadFromFile("Sample.docx");
Step 3: Save the document to SVG file.
doc.SaveToFile("result.svg", FileFormat.SVG);
After running the code, we'll get the effective screenshot of the following result SVG file from word document:

Full codes:
using Spire.Doc;
namespace wordconversion.Case
{
class WordtoSVG
{
public WordtoSVG()
{
Document doc = new Document();
doc.LoadFromFile("Sample.docx");
doc.SaveToFile("result.svg", FileFormat.SVG);
}
}
}
How to convert Word to Word XML in C#, VB.NET
Simple introduction about Word XML
Word XML is a special XML format, which makes Word be able to manipulate the Word documents stored in XML format. It can be divided into two types: WordML(supported by Word 2003) and WordXML(supported by Word 2007). If external applications support Word XML and the generated data follow the Word XML structure, then the data can be processed by Word. In this way, Word XML has become the bridge between Word and other external applications, any XML- formatted document based on Word XML structure can be opened, edited and saved in Word.
Using C#/VB.NET to convert Word to Word XML via Spire.Doc
Spire.Doc enables users to convert word document to Word XML format easily by using the doc.SaveToFile() method. Now, please follow the detail steps below:
Note: Before start, please download Spire.Doc and install it correctly, then add Spire.Doc.dll file from Bin folder as the reference of your project.
This is the screenshot of the original word document:

Step 1: Create a new document instance.
Document doc = new Document();
Step 2: Load the sample word document from file.
doc.LoadFromFile("Spire.Doc for .NET.docx");
Step 3: Save the word document as Word XML format.
For word 2003:
doc.SaveToFile("DocxToWordML.xml", FileFormat.WordML);
For word 2007:
doc.SaveToFile("DocxToWordXML.xml", FileFormat.WordXml);
Effective screenshot:

Full codes:
using Spire.Doc;
namespace Convert_Word_to_Word_XML
{
class Program
{
static void Main(string[] args)
{
Document doc = new Document();
doc.LoadFromFile("Spire.Doc for .NET.docx");
doc.SaveToFile("DocxToWordML.xml", FileFormat.WordML);
//doc.SaveToFile("DocxToWordXML.xml", FileFormat.WordXml);
}
}
}
Imports Spire.Doc
Namespace Convert_Word_to_Word_XML
Class Program
Private Shared Sub Main(args As String())
Dim doc As New Document()
doc.LoadFromFile("Spire.Doc for .NET.docx")
doc.SaveToFile("DocxToWordML.xml", FileFormat.WordML)
'doc.SaveToFile("DocxToWordXML.xml", FileFormat.WordXml);
End Sub
End Class
End Namespace
C#/VB.NET: Convert RTF to PDF
RTF (Rich Text Format) is a cross-platform document developed by Microsoft in the 1980s. RTF can be opened by most word processors, and it is also convenient for editing. But when it comes to sharing and printing documents in daily work, it’s more recommended to convert the RTF to PDF for further processing. In this article, you will learn how to convert RTF to PDF programmatically using Spire.Doc for .NET.
Install Spire.Doc for .NET
To begin with, you need to add the DLL files included in the Spire.Doc for .NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.
PM> Install-Package Spire.Doc
Convert RTF to PDF in C# and VB.NET
Spire.Doc for .NET enables you to directly load a file with .rtf extension and then convert it to PDF with only three lines of code. The detailed steps are as follows.
- Create a Document instance.
- Load a sample RTF document using Document.LoadFromFile() method.
- Save the document as a PDF file using Document.SaveToFile() method.
- C#
- VB.NET
using Spire.Doc;
namespace RTFtoPDF
{
class Program
{
static void Main(string[] args)
{
//Create a Document instance
Document doc = new Document();
//Load a sample RTF document
doc.LoadFromFile("sample.rtf", FileFormat.Rtf);
//Save it to PDF
doc.SaveToFile("RTFtoPDF.pdf", FileFormat.PDF);
}
}
}

Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.
How to convert RTF to Image and reset image resolution
Spire.Doc has a powerful ability to operate RTF file formats in C# and VB.NET. By using Spire.Doc, developers can convert RTF to PDF, HTML and word documents in .doc, .docx. This article will show you how to convert RTF into image and then reset the image resolution.
Download and install Spire.Doc for .NET and then add Spire.Doc.dll as reference in the downloaded Bin folder though the below path: "..\Spire.Doc\Bin\NET4.0\ Spire.Doc.dll". Here comes to the details of how to convert RTF into PNG and reset image resolution in C#.
Step 1: Create a new document and load from file.
Document doc = new Document();
doc.LoadFromFile("sample.rtf", FileFormat.Rtf);
Step 2: Save the RTF to image
Image[] images = doc.SaveToImages(Spire.Doc.Documents.ImageType.Metafile);
Step 3: Traverse the elements in the list of images and save them into .Png format.
for (int i = 0; i < images.Length; i++)
{
Metafile mf = images[i] as Metafile;
Image newimage = ResetResolution(mf, 200);
string outputfile = String.Format("image-{0}.png", i);
newimage.Save(outputfile, System.Drawing.Imaging.ImageFormat.Png);
}
Step 4: Set the image resolution call the method: ResetResolution.
public static Image ResetResolution(Metafile mf, float resolution)
{
int width = (int)(mf.Width * resolution / mf.HorizontalResolution);
int height = (int)(mf.Height * resolution / mf.VerticalResolution);
Bitmap bmp = new Bitmap(width, height);
bmp.SetResolution(resolution, resolution);
using (Graphics g = Graphics.FromImage(bmp))
{
g.DrawImage(mf, Point.Empty);
}
return bmp;
}
Effective screenshot of the image before reset the image resolution:

The image after reset the image resolution:

Full codes:
using Spire.Doc;
using System.Drawing;
using System.Drawing.Imaging;
namespace RTFtoImage
{
class Program
{
static void Main(string[] args)
{
//Create a new document and load from file.
Document doc = new Document();
doc.LoadFromFile("sample.rtf", FileFormat.Rtf);
// save the RTF to image
Image[] images = doc.SaveToImages(Spire.Doc.Documents.ImageType.Metafile);
for (int i = 0; i < images.Length; i++)
{
Metafile mf = images[i] as Metafile;
Image newimage = ResetResolution(mf, 200);
string outputfile = String.Format("image-{0}.png", i);
newimage.Save(outputfile, System.Drawing.Imaging.ImageFormat.Png);
}
}
//set the image resolution by the ResetResolution() method
public static Image ResetResolution(Metafile mf, float resolution)
{
int width = (int)(mf.Width * resolution / mf.HorizontalResolution);
int height = (int)(mf.Height * resolution / mf.VerticalResolution);
Bitmap bmp = new Bitmap(width, height);
bmp.SetResolution(resolution, resolution);
using (Graphics g = Graphics.FromImage(bmp))
{
g.DrawImage(mf, Point.Empty);
}
return bmp;
}
}
}
How to Convert Word to PDF/A in C# ?
PDF/A is an ISO-standardized version of the Portable Document Format (PDF) specialized for the digital preservation of electronic documents. It is widely used for long term archiving for PDF format. This article mainly shows how to convert word document (doc and docx) to PDF/A in C# by using Spire.Doc.
Make sure Spire.Doc for .NET Version 5.0.26 (or above) has been installed correctly and then add Spire.Doc.dll as reference in the downloaded Bin folder though the below path: "..\Spire.Doc\Bin\NET4.0\ Spire.Doc.dll".
First, check the original word document that will be converted to PDF/A.
Here comes to the details of how developers convert word document to PDF/A directly by using Spire.Doc:
Step 1: Load a word document from the file.
Document document = new Document(); document.LoadFromFile(@"D:\test.docx",FileFormat.Docx);
Step 2: Sets the Pdf document's Conformance-level to PDF_A1B.
ToPdfParameterList toPdf = new ToPdfParameterList(); toPdf.PdfConformanceLevel = Spire.Pdf.PdfConformanceLevel.Pdf_A1B;
Step 3: Save word document to PDF
document.SaveToFile("result.Pdf",toPdf);
Please check the effective screenshot of the result PDF in PDF/A format.
C#: Convert HTML to PDF, XPS and XML
HTML is the standard format for web pages and online content. However, there are many scenarios where you may need to convert HTML documents into other file formats, such as PDF, XPS, and XML. Whether you're looking to generate a printable version of a web page, share HTML content in a more universally accepted format, or extract data from HTML for further processing, being able to reliably convert HTML documents to these alternate formats is an important skill to have. In this article, we will demonstrate how to convert HTML to PDF, XPS, and XML in C# using Spire.Doc for .NET.
- Convert HTML to PDF in C#
- Convert HTML String to PDF in C#
- Convert HTML to XPS in C#
- Convert HTML to XML in C#
Install Spire.Doc for .NET
To begin with, you need to add the DLL files included in the Spire.Doc for .NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.
PM> Install-Package Spire.Doc
Convert HTML to PDF in C#
Converting HTML to PDF offers several advantages, including enhanced portability, consistent formatting, and easy sharing. PDF files retain the original layout, styling, and visual elements of the HTML content, ensuring that the document appears the same across different devices and platforms.
You can use the Document.SaveToFile(string filename, FileFormat.PDF) method to convert an HTML file to PDF format. The detailed steps are as follows.
- Create an instance of the Document object.
- Load an HTML file using the Document.LoadFromFile() method.
- Save the HTML file to PDF format using the Document.SaveToFile(string filename, FileFormat.PDF) method.
- C#
using Spire.Doc;
using Spire.Doc.Documents;
namespace ConvertHtmlToPdf
{
internal class Program
{
static void Main(string[] args)
{
// Create an instance of the Document class
Document doc = new Document();
// Load an HTML file
doc.LoadFromFile("Sample.html", FileFormat.Html, XHTMLValidationType.None);
//Convert the HTML file to PDF format
doc.SaveToFile("HtmlToPDF.pdf", FileFormat.PDF);
doc.Close();
}
}
}

Convert HTML String to PDF in C#
In addition to converting HTML files to PDF, you are also able to convert HTML strings to PDF. Spire.Doc for .NET provides the Paragraph.AppendHTML() method to add an HTML string to a Word document. Once the HTML string has been added, you can convert the result document to PDF using the Document.SaveToFile(string filename, FileFormat.PDF) method. The detailed steps are as follows.
- Create an instance of the Document object.
- Add a paragraph to the document using the Document.AddSection().AddParagraph() method.
- Append an HTML string to the paragraph using the Paragraph.AppendHTML() method.
- Save the document to PDF format using the Document.SaveToFile(string filename, FileFormat.PDF) method.
- C#
using Spire.Doc;
using Spire.Doc.Documents;
namespace ConvertHtmlStringToPdf
{
internal class Program
{
static void Main(string[] args)
{
// Create an instance of the Document class
Document doc = new Document();
// Add a paragraph to the document
Paragraph para = doc.AddSection().AddParagraph();
// Specify the HTML string
string htmlString = @"<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>";
// Append the HTML string to the paragraph
para.AppendHTML(htmlString);
// Convert the document to PDF format
doc.SaveToFile("HtmlStringToPDF.pdf", FileFormat.PDF);
doc.Close();
}
}
}

Convert HTML to XPS in C#
XPS, or XML Paper Specification, is an alternative format to PDF that provides similar functionality and advantages. Converting HTML to XPS ensures the preservation of document layout, fonts, and images while maintaining high fidelity. XPS files are optimized for printing and can be viewed using XPS viewers or Windows' built-in XPS Viewer.
By using the Document.SaveToFile(string filename, FileFormat.XPS) method, you can convert HTML files to XPS format with ease. The detailed steps are as follows.
- Create an instance of the Document object.
- Load an HTML file using the Document.LoadFromFile() method.
- Save the HTML file to XPS format using the Document.SaveToFile(string filename, FileFormat.XPS) method.
- C#
using Spire.Doc;
using Spire.Doc.Documents;
namespace ConvertHtmlToXps
{
internal class Program
{
static void Main(string[] args)
{
// Create an instance of the Document class
Document doc = new Document();
// Load an HTML file
doc.LoadFromFile("Sample.html", FileFormat.Html, XHTMLValidationType.None);
//Convert the HTML file to XPS format
doc.SaveToFile("HtmlToXPS.xps", FileFormat.XPS);
doc.Close();
}
}
}

Convert HTML to XML in C#
Converting HTML to XML unlocks the potential for data extraction, manipulation, and integration with other systems. XML is a flexible and extensible markup language that allows for structured representation of data. By converting HTML to XML, you can extract specific elements, organize data hierarchically, and perform data analysis or integration tasks using XML processing tools and techniques.
To convert HTML files to XML format, you can use the Document.SaveToFile(string filename, FileFormat.Xml) method. The detailed steps are as follows.
- Create an instance of the Document object.
- Load an HTML file using the Document.LoadFromFile() method.
- Save the HTML file to XML format using the Document.SaveToFile(string filename, FileFormat.Xml) method.
- C#
using Spire.Doc;
using Spire.Doc.Documents;
namespace ConvertHtmlToXml
{
internal class Program
{
static void Main(string[] args)
{
// Create an instance of the Document class
Document doc = new Document();
// Load an HTML file
doc.LoadFromFile("Sample.html", FileFormat.Html, XHTMLValidationType.None);
//Convert the HTML file to XML format
doc.SaveToFile("HtmlToXML.xml", FileFormat.Xml);
doc.Close();
}
}
}

Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.
Convert Word from/to HTML with Embedded Image
Convert Word document to HTML is popular and widely used by programmers and developers. With the help of Spire.Doc for .NET, a professional word component, without installing MS Word, developers can convert word to html with only two lines of key code in C#. At the same time, Spire.Doc supports convert HTML to word document easily and quickly.
This article still focuses on convert word from/to HTML, while it mainly about the supports of embed image in the word document and HTML. With the improvements of Spire.Doc (starts from Spire.Doc V. 4.9.32), now it supports the new function of ImageEmbedded.
Please download Spire.Doc (version 4.9.32 or above) with .NET framework together and follow the simple steps as below:
Convert Word to HTML in C#:
Step 1: Create the word document.
Document document = new Document();
Step 2: Set the value of imageEmbedded attribute.
doc.HtmlExportOptions.ImageEmbedded=true;
Step 3: Save word document to HTML.
doc.SaveToFile("result.html",FileFormat.Html);
Spire.Doc also supports load the result HTML page and convert it into word document in only three lines of codes as below.
doc.SaveToFile("htmltoword.docx",FileFormat.Docx);
Besides conversion of word from/to HTML, Spire.Doc also supports Convert Word to PDF, Convert Word to Image and Convert Word to XPS in C#.