PdfContents(PdfContentByte under,
PdfContentByte content,
PdfContentByte text,
PdfContentByte secondContent,
Rectangle page) throws BadPdfFormatException {
// constructor
super();
try {
OutputStream out = null;
streamBytes = new ByteArrayOutputStream();
if (Document.compress)
{
compressed = true;
compressionLevel = text.getPdfWriter().getCompressionLevel();
out = new DeflaterOutputStream(streamBytes, new Deflater(compressionLevel));
}
else
out = streamBytes;
int rotation = page.getRotation();
switch (rotation) {
case 90:
out.write(ROTATE90);
out.write(DocWriter.getISOBytes(ByteBuffer.formatDouble(page.getTop())));
out.write(' ");
out.write('0");
out.write(ROTATEFINAL);
break;
case 180:
out.write(ROTATE180);
out.write(DocWriter.getISOBytes(ByteBuffer.formatDouble(page.getRight())));
out.write(' ");
out.write(DocWriter.getISOBytes(ByteBuffer.formatDouble(page.getTop())));
out.write(ROTATEFINAL);
break;
case 270:
out.write(ROTATE270);
out.write('0");
out.write(' ");
out.write(DocWriter.getISOBytes(ByteBuffer.formatDouble(page.getRight())));
out.write(ROTATEFINAL);
break;
}
if (under.size() > 0) {
out.write(SAVESTATE);
under.getInternalBuffer().writeTo(out);
out.write(RESTORESTATE);
}
if (content.size() > 0) {
out.write(SAVESTATE);
content.getInternalBuffer().writeTo(out);
out.write(RESTORESTATE);
}
if (text != null) {
out.write(SAVESTATE);
text.getInternalBuffer().writeTo(out);
out.write(RESTORESTATE);
}
if (secondContent.size() > 0) {
secondContent.getInternalBuffer().writeTo(out);
}
out.close();
}
catch (Exception e) {
throw new BadPdfFormatException(e.getMessage());
}
put(PdfName.LENGTH, new PdfNumber(streamBytes.size()));
if (compressed)
put(PdfName.FILTER, PdfName.FLATEDECODE);
}
Constructs a PdfContents-object, containing text and general graphics. Parameters:
under - the direct content that is under all others
content - the graphics in a page
text - the text in a page
secondContent - the direct content that is over all others
Throws:
BadPdfFormatException - on error
|