use of com.tom_roush.pdfbox.cos.COSFloat in project PdfBox-Android by TomRoush.
the class ContentStreamWriter method writeObject.
private void writeObject(Object o) throws IOException {
if (o instanceof COSString) {
COSWriter.writeString((COSString) o, output);
output.write(SPACE);
} else if (o instanceof COSFloat) {
((COSFloat) o).writePDF(output);
output.write(SPACE);
} else if (o instanceof COSInteger) {
((COSInteger) o).writePDF(output);
output.write(SPACE);
} else if (o instanceof COSBoolean) {
((COSBoolean) o).writePDF(output);
output.write(SPACE);
} else if (o instanceof COSName) {
((COSName) o).writePDF(output);
output.write(SPACE);
} else if (o instanceof COSArray) {
COSArray array = (COSArray) o;
output.write(COSWriter.ARRAY_OPEN);
for (int i = 0; i < array.size(); i++) {
writeObject(array.get(i));
output.write(SPACE);
}
output.write(COSWriter.ARRAY_CLOSE);
} else if (o instanceof COSDictionary) {
COSDictionary obj = (COSDictionary) o;
output.write(COSWriter.DICT_OPEN);
for (Map.Entry<COSName, COSBase> entry : obj.entrySet()) {
if (entry.getValue() != null) {
writeObject(entry.getKey());
output.write(SPACE);
writeObject(entry.getValue());
output.write(SPACE);
}
}
output.write(COSWriter.DICT_CLOSE);
output.write(SPACE);
} else if (o instanceof Operator) {
Operator op = (Operator) o;
if (op.getName().equals(OperatorName.BEGIN_INLINE_IMAGE)) {
output.write(OperatorName.BEGIN_INLINE_IMAGE.getBytes(Charsets.ISO_8859_1));
COSDictionary dic = op.getImageParameters();
for (COSName key : dic.keySet()) {
Object value = dic.getDictionaryObject(key);
key.writePDF(output);
output.write(SPACE);
writeObject(value);
output.write(EOL);
}
output.write(OperatorName.BEGIN_INLINE_IMAGE_DATA.getBytes(Charsets.ISO_8859_1));
output.write(EOL);
output.write(op.getImageData());
output.write(EOL);
output.write(OperatorName.END_INLINE_IMAGE.getBytes(Charsets.ISO_8859_1));
output.write(EOL);
} else {
output.write(op.getName().getBytes(Charsets.ISO_8859_1));
output.write(EOL);
}
} else {
throw new IOException("Error:Unknown type in content stream:" + o);
}
}
use of com.tom_roush.pdfbox.cos.COSFloat in project PdfBox-Android by TomRoush.
the class PDAnnotationMarkup method setRectDifferences.
/**
* This will set the difference between the annotations "outer" rectangle defined by
* /Rect and the border.
*
* @param differenceLeft left difference from the annotations /Rect entry
* @param differenceTop top difference from the annotations /Rect entry
* @param differenceRight right difference from the annotations /Rect entry
* @param differenceBottom bottom difference from the annotations /Rect entry
*/
public void setRectDifferences(float differenceLeft, float differenceTop, float differenceRight, float differenceBottom) {
COSArray margins = new COSArray();
margins.add(new COSFloat(differenceLeft));
margins.add(new COSFloat(differenceTop));
margins.add(new COSFloat(differenceRight));
margins.add(new COSFloat(differenceBottom));
getCOSObject().setItem(COSName.RD, margins);
}
use of com.tom_roush.pdfbox.cos.COSFloat in project PdfBox-Android by TomRoush.
the class PDAnnotationSquareCircle method setRectDifferences.
/**
* This will set the difference between the annotations "outer" rectangle defined by
* /Rect and the border.
*
* @param differenceLeft left difference from the annotations /Rect entry
* @param differenceTop top difference from the annotations /Rect entry
* @param differenceRight right difference from the annotations /Rect entry
* @param differenceBottom bottom difference from the annotations /Rect entry
*/
public void setRectDifferences(float differenceLeft, float differenceTop, float differenceRight, float differenceBottom) {
COSArray margins = new COSArray();
margins.add(new COSFloat(differenceLeft));
margins.add(new COSFloat(differenceTop));
margins.add(new COSFloat(differenceRight));
margins.add(new COSFloat(differenceBottom));
getCOSObject().setItem(COSName.RD, margins);
}
use of com.tom_roush.pdfbox.cos.COSFloat in project PdfBox-Android by TomRoush.
the class MatrixTest method testPdfbox2872.
/**
* Test of PDFBOX-2872 bug
*/
@Test
public void testPdfbox2872() {
Matrix m = new Matrix(2, 4, 5, 8, 2, 0);
COSArray toCOSArray = m.toCOSArray();
assertEquals(new COSFloat(2), toCOSArray.get(0));
assertEquals(new COSFloat(4), toCOSArray.get(1));
assertEquals(new COSFloat(5), toCOSArray.get(2));
assertEquals(new COSFloat(8), toCOSArray.get(3));
assertEquals(new COSFloat(2), toCOSArray.get(4));
assertEquals(new COSFloat(0), toCOSArray.get(5));
}
use of com.tom_roush.pdfbox.cos.COSFloat in project PdfBox-Android by TomRoush.
the class PDPage method setTransition.
/**
* Convenient method to set a transition and the display duration
*
* @param transition The new transition to set on this page.
* @param duration The maximum length of time, in seconds, that the page shall be displayed during presentations
* before the viewer application shall automatically advance to the next page.
*/
public void setTransition(PDTransition transition, float duration) {
page.setItem(COSName.TRANS, transition);
page.setItem(COSName.DUR, new COSFloat(duration));
}
Aggregations