Skip to main content

Posts

Insert Content Controls into Word Document in Java

  Introduction Content controls are ideal for creating templates because content controls can help us fix the position of content, specify the kind of content (for example, a date, a picture, or text), and restrict or enable editing on content. In this article, I will demonstrate how to insert the following types of content controls into a Word document in Java. ·        Combo box ·        Check box ·        Text ·        Picture ·        Date picker ·        Drop-down list   Required library Free Spire.Doc for Java Before using the below code, we need to download Free Spire.Doc for Java and then import the Spire.Doc.jar file into our project. For maven project, you can refer this online tutorial to install Free Spire.Doc for Java from maven repository...

Extract Text and Images from Word Document in Java

In this blog, I’ll introduce an easy solution to extract text and images from a Word document within Java application. Required Library Free Spire.Doc for Java Before using the below code, we need to download  Free Spire.Doc for Java   and then import the Spire.Doc.jar file into our project. For maven project, you can refer this  online tutorial   to install Free Spire.Doc for Java from maven repository. Extract Text Free Spire.Doc for Java provides a getText method in Document class which we can use to get text from a Word document. import com.spire.doc.Document; import java.io.FileWriter; import java.io.IOException; public class ReadText{ public static void main(String[] args) throws IOException { //load Word document Document document = new Document(); document.loadFromFile( "C: \\ Users \\ Administrator \\ Desktop \\ sample.docx" ); //get text from document as string Strin...

Add Text Watermark and Image Watermark to PDF in Java

In this blog, I’ll introduce how to add text watermark and image watermark to a PDF file using Free Spire.PDF for Java library. Before using the below code, you need to download Free Spire.PDF for Java from this link and import the jar file under the lib folder to your project. Add text watermark import com.spire.pdf.*; import com.spire.pdf.graphics.*; import java.awt.*; import java.awt.geom.*; public class Watermark {     public static void main(String[] args){         // load PDF file         PdfDocument pdf = new PdfDocument();         pdf.loadFromFile( "Software - Wikipedia.pdf" );         //add text watermark to every page in the PDF file         for ( int i = 0 ; i< pdf.getPages().getCount(); i++) {             Pdf...

Convert Word Document to Other File Formats (Pdf, Image, Html, Txt etc.) in Java

Convert Word document to other file formats is undoubtedly one of the most common requirements when we working with Word document. In this article, we’ll learn how to convert Word document to other file formats programmatically in Java by using Free Spire.Doc for Java library. Free Spire.Doc for Java library let us convert Word document to a series of file formats easily and effectively without having Microsoft Office to be installed on our system. The following conversions are supported by Free Spire.Doc for Java: Microsoft Word file format conversions Convert Word to Pdf Convert Word to Image Convert Word to Html Convert Word to Rtf Convert Word to Svg Convert Word to Txt Convert Word to Xps Convert Word to Pcl Convert Word to Post Script Convert Word to Odt Convert Word to Epub Convert Word to WordML/WordXML In the following examples, we’ll see how to convert Word document to Pdf, Image, Html and Svg. Convert Word to Pdf The following example demo...

Print PDF files in Java

  In this article, I will show you how to print a PDF file with custom settings, such as silently print to a default printer and set the number of copies, show print dialog when printing, and print to a specific printer with custom paper size in Java using Free Spire.PDF for Java library. Import Jar File Download Free Spire.PDF for Java from this Link , you’ll find the jar file under the lib folder, add it into your project.  If your project is a maven project, refer this online tutorial to install Free Spire.PDF for Java into your project. Print PDF File Silently with Default Printer import com.spire.pdf.*; import java.awt.print.*; public class Print {     public static void main(String[] args) {         //load the sample document         PdfDocument pdf = new PdfDocument();         pdf.loadFromFile("Sample.pdf"); ...