forked from itext/i5js-sandbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New example in answer to SO question
- Loading branch information
Bruno Lowagie
committed
Jun 26, 2016
1 parent
990493c
commit 2c24a92
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* This example was written by Bruno Lowagie in answer to the following question: | ||
* http://stackoverflow.com/questions/37991675 | ||
*/ | ||
package sandbox.fonts; | ||
|
||
import com.itextpdf.text.Chunk; | ||
import com.itextpdf.text.Document; | ||
import com.itextpdf.text.DocumentException; | ||
import com.itextpdf.text.Font; | ||
import com.itextpdf.text.Paragraph; | ||
import com.itextpdf.text.pdf.PdfWriter; | ||
|
||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import sandbox.WrapToTest; | ||
|
||
/** | ||
* | ||
* @author Bruno Lowagie (iText Software) | ||
*/ | ||
@WrapToTest | ||
public class TickboxCharacter { | ||
public static final String DEST = "results/fonts/tickbox_character.pdf"; | ||
|
||
public static void main(String[] args) throws IOException, DocumentException { | ||
File file = new File(DEST); | ||
file.getParentFile().mkdirs(); | ||
new TickboxCharacter().createPdf(DEST); | ||
} | ||
|
||
public void createPdf(String dest) throws IOException, DocumentException { | ||
Document document = new Document(); | ||
PdfWriter.getInstance(document, new FileOutputStream(dest)); | ||
document.open(); | ||
Paragraph p = new Paragraph("This is a tick box character: "); | ||
Font zapfdingbats = new Font(Font.FontFamily.ZAPFDINGBATS, 14); | ||
Chunk chunk = new Chunk("o", zapfdingbats); | ||
p.add(chunk); | ||
document.add(p); | ||
document.close(); | ||
} | ||
} |