Skip to main content

Posts

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"); ...

Adding, Removing Text Watermark & Image Watermark in Word using Java

A watermark is a piece of faded text or a faded image that appears behind the content of a document. We can add a text watermark to a Word document to indicate the status of the document like draft, confidential and approved, or add an image watermark to identify a company logo. In this article, I am going to illustrate how to add text watermark and image watermark to a Word document and then remove the watermarks using  Free Spire.Doc for Java  library. Adding Text Watermark In Free Spire.Doc for Java,  TextWatermark  class is used to work with text watermark. When creating text watermark, we can customize the settings of the watermark such as font, font size, text color and layout. public class TextWatermark { public static void main(String[] args){ //Load the Word document Document doc = new Document(); doc.loadFromFile("Input.docx"); //Create a TextWatermark instance TextWatermark textWatermark ...