Skip to main content

Posts

Showing posts from May, 2019

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");         PrinterJob loPrinterJob = PrinterJob.getPrinterJob();         PageFormat loPageFormat   = loPrinterJob.defaul

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 = new Tex