Java Code Examples for org.apache.pdfbox.cos.COSDictionary#setString()

The following examples show how to use org.apache.pdfbox.cos.COSDictionary#setString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PDOptionalContentProperties.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
private COSDictionary getD()
{
    COSBase base = this.dict.getDictionaryObject(COSName.D);
    if (base instanceof COSDictionary)
    {
        return (COSDictionary) base;
    }

    COSDictionary d = new COSDictionary();

    // Name optional but required for PDF/A-3
    d.setString(COSName.NAME, "Top");

    // D is required
    this.dict.setItem(COSName.D, d);        

    return d;
}
 
Example 2
Source File: PDOptionalContentProperties.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Creates a new optional content properties dictionary.
 */
public PDOptionalContentProperties()
{
    this.dict = new COSDictionary();
    this.dict.setItem(COSName.OCGS, new COSArray());
    COSDictionary d = new COSDictionary();

    // Name optional but required for PDF/A-3
    d.setString(COSName.NAME, "Top");

    this.dict.setItem(COSName.D, d);
}
 
Example 3
Source File: PDFontFactory.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Create a default font.
 * 
 * @return a default font
 * @throws IOException if something goes wrong
 */
public static PDFont createDefaultFont() throws IOException
{
    COSDictionary dict = new COSDictionary();
    dict.setItem(COSName.TYPE, COSName.FONT);
    dict.setItem(COSName.SUBTYPE, COSName.TRUE_TYPE);
    dict.setString(COSName.BASE_FONT, "Arial");
    return createFont(dict);
}
 
Example 4
Source File: PDCIDFontType2Embedder.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
private COSDictionary toCIDSystemInfo(String registry, String ordering, int supplement)
{
    COSDictionary info = new COSDictionary();
    info.setString(COSName.REGISTRY, registry);
    info.setString(COSName.ORDERING, ordering);
    info.setInt(COSName.SUPPLEMENT, supplement);
    return info;
}
 
Example 5
Source File: PDCIDSystemInfo.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
PDCIDSystemInfo(String registry, String ordering, int supplement)
{
    dictionary = new COSDictionary();
    dictionary.setString(COSName.REGISTRY, registry);
    dictionary.setString(COSName.ORDERING, ordering);
    dictionary.setInt(COSName.SUPPLEMENT, supplement);
}
 
Example 6
Source File: AddSpecialCharacterWithoutEmbedding.java    From testarea-pdfbox2 with Apache License 2.0 5 votes vote down vote up
COSDictionary buildUnembeddedArialWithSpecialEncoding() {
    COSArray differences = new COSArray();
    differences.add(COSInteger.get(32));
    differences.add(COSName.getPDFName("uniAB55"));

    COSDictionary fontDescDict = new COSDictionary();
    fontDescDict.setName("Type", "FontDescriptor");
    fontDescDict.setName("FontName", "Arial");
    fontDescDict.setString("FontFamily", "Arial");
    fontDescDict.setInt("Flags", 32);
    fontDescDict.setItem("FontBBox", new PDRectangle(-665, -325, 2665, 1365));
    fontDescDict.setInt("ItalicAngle", 0);
    fontDescDict.setInt("Ascent", 1040);
    fontDescDict.setInt("Descent", -325);
    fontDescDict.setInt("CapHeight", 716);
    fontDescDict.setInt("StemV", 88);
    fontDescDict.setInt("XHeight", 519);

    COSDictionary encodingDict = new COSDictionary();
    encodingDict.setName("Type", "Encoding");
    encodingDict.setName("BaseEncoding", "WinAnsiEncoding");
    encodingDict.setItem("Differences", differences);

    COSArray widths = new COSArray();
    widths.add(COSInteger.get(500));

    COSDictionary fontDict = new COSDictionary();
    fontDict.setName("Type", "Font");
    fontDict.setName("Subtype", "TrueType");
    fontDict.setName("BaseFont", "Arial");
    fontDict.setInt("FirstChar", 32);
    fontDict.setInt("LastChar", 32);
    fontDict.setItem("Widths", widths);
    fontDict.setItem("FontDescriptor", fontDescDict);
    fontDict.setItem("Encoding", encodingDict);

    return fontDict;
}