Created
July 20, 2011 08:57
-
-
Save anonymous/1094612 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Read this and add the latest libraries i added 4 of them | |
// http://www.printmyfolders.com/Home/PDFBox-Tutorial | |
import org.apache.pdfbox.pdmodel.PDDocument; | |
import org.apache.pdfbox.pdmodel.PDPage; | |
import org.apache.pdfbox.pdmodel.edit.PDPageContentStream; | |
import org.apache.pdfbox.pdmodel.font.PDType1Font; | |
import org.apache.pdfbox.pdmodel.font.PDFont; | |
public class print | |
{ | |
public static void main(String argc[]) | |
{ | |
PDDocument doc = null; | |
PDPage page = null; | |
try{ | |
doc = new PDDocument(); | |
page = new PDPage(); | |
doc.addPage(page); | |
PDFont font = PDType1Font.HELVETICA_BOLD; | |
PDPageContentStream content = new PDPageContentStream(doc, page); | |
content.beginText(); | |
content.setFont( font, 12 ); | |
content.moveTextPositionByAmount( 100, 700 ); | |
content.drawString("Hello from www.printmyfolders.com"); | |
content.endText(); | |
content.close(); | |
doc.save("PDFWithText.pdf"); | |
doc.silentPrint(); | |
doc.close(); | |
} catch (Exception e){ | |
System.out.println(e); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment