HelloWorld.java
import java.io.*; import java.awt.Color; import org.faceless.pdf2.*; public class HelloWorld { public static void main(String[] args) throws IOException { PDF p = new PDF(); PDFPage page = p.newPage("A4"); PDFStyle mystyle = new PDFStyle(); mystyle.setFont(new StandardFont(StandardFont.HELVETICA), 24); mystyle.setFillColor(Color.black); page.setStyle(mystyle); page.drawText("Hello, PDF-viewing World!", 100, page.getHeight()-100); // Set some meta-information in the document p.setInfo("Author", "Joe Bloggs"); p.setInfo("Title", "My First Document"); // Set the password StandardEncryptionHandler handler = new StandardEncryptionHandler(); handler.setUserPassword("password"); p.setEncryptionHandler(handler); OutputStream fo = new FileOutputStream("HelloWorld.pdf"); p.render(fo); fo.close(); } }