Skip to content

Instantly share code, notes, and snippets.

@keiono
Created June 23, 2011 20:57
Show Gist options
  • Save keiono/1043609 to your computer and use it in GitHub Desktop.
Save keiono/1043609 to your computer and use it in GitHub Desktop.
Create Empty PDF on OSGi
final Rectangle pageSize = PageSize.LETTER;
final Document document = new Document(pageSize);
OutputStream os = new BufferedOutputStream(new FileOutputStream("itextTest2.pdf"));
final PdfWriter writer = PdfWriter.getInstance(document, os);
document.open();
final PdfContentByte canvas = writer.getDirectContent();
final float pageWidth = pageSize.getWidth();
final float pageHeight = pageSize.getHeight();
final DefaultFontMapper fontMapper = new DefaultFontMapper();
final Graphics2D g = canvas.createGraphics(pageWidth, pageHeight);
g.dispose();
document.close();
os.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment