Skip to content

This is a collection of examples that shows you how to use Spire.Doc for Java to create and manipulate Word documents.

Notifications You must be signed in to change notification settings

eiceblue/Spire.Doc-for-Java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 

Repository files navigation

Spire.Doc for Java, Java Library to Create, Manipulate & Convert Word Documents

Foo

Product Page | Documentation | Examples | Forum | Temporary License | Customized Demo

Spire.Doc for Java is a professional Word API that enables developers to create, read, manipulate, convert and print Word documents in Java applications without installing Microsoft Office.

By using this multi-functional API, developers are able to perform various Word document processing tasks with ease, like inserting image, hyperlink, digital signature, bookmark, watermark, setting header & footer, creating table, setting background image, adding footnote & endnote and many more.

Standalone Java API

Spire.Doc for Java is a totally independent API, it doesn't require Microsoft Office or any other third-party libraries to be installed on system.

Support Both Old and New Word Versions

  • Word 97-2003
  • Word 2007
  • Word 2010
  • Word 2013
  • Word 2016
  • Word 2019

Support a Rich Set of Word Elements

Spire.Doc for Java supports almost all Word document elements, including sections, headers, footers, footnotes, endnotes, paragraphs, lists, tables, text, fields, hyperlinks, bookmarks, watermarks, math equations, mail merge, comments, images, styles, background settings, digital signature, document printing, document settings, document encryption and decryption. Furthermore, drawing objects including shapes, textboxes, images, OLE objects and content controls are supported as well.

High Quality File Conversions

Using Spire.Doc for Java, developers can:

Examples

Create a Word Document in Java

//Create a Document instance
Document doc = new Document();
//Add a section
Section section = doc.addSection();
//Add a paragraph
Paragraph para = section.addParagraph();
//Append text to the paragraph
para.appendText("Hello World");
//Save the result document
doc.saveToFile("output/Output.docx", FileFormat.Docx_2013);

Convert Word to PDF, HTML and XPS in Java

//Create a Document instance
Document document = new Document();
//Load a sample document
document.loadFromFile("C:/Templates/Template.docx");

//Save to PDF
document.saveToFile("toPDF.pdf", FileFormat.PDF);
//Save to HTML
document.saveToFile("toHTML.html", FileFormat.Html);
//Save to XPS
document.saveToFile("toXPS.xps", FileFormat.XPS);

Convert Word to Image in Java

//Create a Document instance
Document document = new Document();
//Load a sample document
document.loadFromFile("C:/Templates/Template.docx");

//Save to PNG image
for (int i = 0; i < document.getPageCount(); i++) {
    BufferedImage image = document.saveToImages(i, ImageType.Bitmap);
    File file = new File("out/" + String.format(("Img-%d.png"), i));
    ImageIO.write(image, "PNG", file);
}

Product Page | Documentation | Examples | Forum | Temporary License | Customized Demo

About

This is a collection of examples that shows you how to use Spire.Doc for Java to create and manipulate Word documents.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published