use of com.tom_roush.pdfbox.cos.COSString in project PdfBox-Android by TomRoush.
the class PDChoiceTest method getOptionsFromMixed.
/*
* Get the entries form a moxed values array. See PDFBOX-4185
*/
@Test
public void getOptionsFromMixed() {
PDChoice choiceField = new PDComboBox(acroForm);
COSArray choiceFieldOptions = new COSArray();
// add string entry to options
choiceFieldOptions.add(new COSString(" "));
// add array entry to options
COSArray entry = new COSArray();
entry.add(new COSString("A"));
choiceFieldOptions.add(entry);
// add array entry to options
entry = new COSArray();
entry.add(new COSString("B"));
choiceFieldOptions.add(entry);
// add the options using the low level COS model as the PD model will
// abstract the COSArray
choiceField.getCOSObject().setItem(COSName.OPT, choiceFieldOptions);
assertEquals(options, choiceField.getOptions());
}
use of com.tom_roush.pdfbox.cos.COSString in project PdfBox-Android by TomRoush.
the class PDDefaultAppearanceStringTest method testFontResourceUnavailable.
@Test(expected = IOException.class)
public void testFontResourceUnavailable() throws IOException {
COSString sampleString = new COSString("/Helvetica 12 Tf 0.019 0.305 0.627 rg");
new PDDefaultAppearanceString(sampleString, resources);
}
use of com.tom_roush.pdfbox.cos.COSString in project PdfBox-Android by TomRoush.
the class PDDefaultAppearanceStringTest method testWrongNumberOfColorArguments.
@Test(expected = IOException.class)
public void testWrongNumberOfColorArguments() throws IOException {
COSString sampleString = new COSString("/Helvetica 12 Tf 0.305 0.627 rg");
new PDDefaultAppearanceString(sampleString, resources);
}
use of com.tom_roush.pdfbox.cos.COSString in project PdfBox-Android by TomRoush.
the class ControlCharacterTest method getStringsFromStream.
private List<String> getStringsFromStream(PDField field) throws IOException {
PDAnnotationWidget widget = field.getWidgets().get(0);
PDFStreamParser parser = new PDFStreamParser(widget.getNormalAppearanceStream());
Object token = parser.parseNextToken();
List<String> stringValues = new ArrayList<String>();
while (token != null) {
if (token instanceof COSString) {
// TODO: improve the string output to better match
// trimming as Acrobat adds spaces to strings
// where we don't
stringValues.add(((COSString) token).getString().trim());
}
token = parser.parseNextToken();
}
return stringValues;
}
use of com.tom_roush.pdfbox.cos.COSString in project PdfBox-Android by TomRoush.
the class PDChoiceTest method getOptionsFromStrings.
@Test
public void getOptionsFromStrings() {
PDChoice choiceField = new PDComboBox(acroForm);
COSArray choiceFieldOptions = new COSArray();
choiceFieldOptions.add(new COSString(" "));
choiceFieldOptions.add(new COSString("A"));
choiceFieldOptions.add(new COSString("B"));
// add the options using the low level COS model as the PD model will
// abstract the COSArray
choiceField.getCOSObject().setItem(COSName.OPT, choiceFieldOptions);
assertEquals(options, choiceField.getOptions());
}
Aggregations