/** * Get the default appearance. * * This is an inheritable attribute. * * The default appearance contains a set of default graphics and text operators * to define the field’s text size and color. * * @return the DA element of the dictionary object */ PDDefaultAppearanceString getDefaultAppearanceString() throws IOException { COSString da = (COSString) getInheritableAttribute(COSName.DA); PDResources dr = getAcroForm().getDefaultResources(); return new PDDefaultAppearanceString(da, dr); }
private PDDefaultAppearanceString getWidgetDefaultAppearanceString(PDAnnotationWidget widget) throws IOException { COSString da = (COSString) widget.getCOSObject().getDictionaryObject(COSName.DA); PDResources dr = field.getAcroForm().getDefaultResources(); return new PDDefaultAppearanceString(da, dr); }
if (field.getAcroForm().getDefaultResources() == null) PDResources acroFormResources = field.getAcroForm().getDefaultResources();
font = acroForm.getDefaultResources().getFont(fontName);
private void assignAcroFormDefaultResource(PDAcroForm acroForm, COSDictionary newDict) { // read and set/update AcroForm default resource dictionary /DR if available COSBase newBase = newDict.getDictionaryObject(COSName.DR); if (newBase instanceof COSDictionary) { COSDictionary newDR = (COSDictionary) newBase; PDResources defaultResources = acroForm.getDefaultResources(); if (defaultResources == null) { acroForm.getCOSObject().setItem(COSName.DR, newDR); newDR.setDirect(true); newDR.setNeedToBeUpdated(true); } else { COSDictionary oldDR = defaultResources.getCOSObject(); COSBase newXObjectBase = newDR.getItem(COSName.XOBJECT); COSBase oldXObjectBase = oldDR.getItem(COSName.XOBJECT); if (newXObjectBase instanceof COSDictionary && oldXObjectBase instanceof COSDictionary) { ((COSDictionary) oldXObjectBase).addAll((COSDictionary) newXObjectBase); oldDR.setNeedToBeUpdated(true); } } } }
PDResources defaultResources = getDefaultResources(); if (defaultResources == null)
public List<String> prepareFont(PDDocument _pdfDocument, List<PDFont> fonts) throws IOException { PDDocumentCatalog docCatalog = _pdfDocument.getDocumentCatalog(); PDAcroForm acroForm = docCatalog.getAcroForm(); PDResources res = acroForm.getDefaultResources(); if (res == null) res = new PDResources(); List<String> fontNames = new ArrayList<String>(); for (PDFont font: fonts) { fontNames.add(res.addFont(font)); } acroForm.setDefaultResources(res); return fontNames; } public PDFont loadTrueTypeFont(PDDocument _pdfDocument, String resourceName) throws IOException { try ( InputStream fontStream = getClass().getResourceAsStream(resourceName); ) { return PDTrueTypeFont.loadTTF(_pdfDocument, fontStream); } }
public String prepareFont(PDDocument _pdfDocument) throws IOException { PDDocumentCatalog docCatalog = _pdfDocument.getDocumentCatalog(); PDAcroForm acroForm = docCatalog.getAcroForm(); PDResources res = acroForm.getDefaultResources(); if (res == null) res = new PDResources(); InputStream fontStream = getClass().getResourceAsStream("LiberationSans-Regular.ttf"); PDTrueTypeFont font = PDTrueTypeFont.loadTTF(_pdfDocument, fontStream); String fontName = res.addFont(font); acroForm.setDefaultResources(res); return fontName; }
/** * Get the default appearance. * * This is an inheritable attribute. * * The default appearance contains a set of default graphics and text operators * to define the field’s text size and color. * * @return the DA element of the dictionary object */ PDDefaultAppearanceString getDefaultAppearanceString() throws IOException { COSString da = (COSString) getInheritableAttribute(COSName.DA); PDResources dr = getAcroForm().getDefaultResources(); return new PDDefaultAppearanceString(da, dr); }
/** * Get the default appearance. * * This is an inheritable attribute. * * The default appearance contains a set of default graphics and text operators * to define the field’s text size and color. * * @return the DA element of the dictionary object */ PDDefaultAppearanceString getDefaultAppearanceString() throws IOException { COSString da = (COSString) getInheritableAttribute(COSName.DA); PDResources dr = getAcroForm().getDefaultResources(); return new PDDefaultAppearanceString(da, dr); }
private PDDefaultAppearanceString getWidgetDefaultAppearanceString(PDAnnotationWidget widget) throws IOException { COSString da = (COSString) widget.getCOSObject().getDictionaryObject(COSName.DA); PDResources dr = field.getAcroForm().getDefaultResources(); return new PDDefaultAppearanceString(da, dr); }
private PDDefaultAppearanceString getWidgetDefaultAppearanceString(PDAnnotationWidget widget) throws IOException { COSString da = (COSString) widget.getCOSObject().getDictionaryObject(COSName.DA); PDResources dr = field.getAcroForm().getDefaultResources(); return new PDDefaultAppearanceString(da, dr); }
document.getDocumentCatalog().setAcroForm(acroForm); PDResources dr = acroForm.getDefaultResources(); if (dr == null)
if (field.getAcroForm().getDefaultResources() == null) PDResources acroFormResources = field.getAcroForm().getDefaultResources();
if (field.getAcroForm().getDefaultResources() == null) PDResources acroFormResources = field.getAcroForm().getDefaultResources();
PDAcroForm form = catalog.getAcroForm(); List<PDField> tmpfields = form.getFields(); PDResources formresources = form.getDefaultResources(); Map formfonts = formresources.getFonts(); PDAnnotation ann;
private void verifyOrCreateDefaults() { final String adobeDefaultAppearanceString = "/Helv 0 Tf 0 g "; // DA entry is required if (getDefaultAppearance().length() == 0) { setDefaultAppearance(adobeDefaultAppearanceString); } // DR entry is required PDResources defaultResources = getDefaultResources(); if (defaultResources == null) { defaultResources = new PDResources(); setDefaultResources(defaultResources); } // Adobe Acrobat uses Helvetica as a default font and // stores that under the name '/Helv' in the resources dictionary // Zapf Dingbats is included per default for check boxes and // radio buttons as /ZaDb. if (!defaultResources.getCOSObject().containsKey("Helv")) { defaultResources.put(COSName.getPDFName("Helv"), PDType1Font.HELVETICA); } if (!defaultResources.getCOSObject().containsKey("ZaDb")) { defaultResources.put(COSName.getPDFName("ZaDb"), PDType1Font.ZAPF_DINGBATS); } }
private void verifyOrCreateDefaults() { final String adobeDefaultAppearanceString = "/Helv 0 Tf 0 g "; // DA entry is required if (getDefaultAppearance().length() == 0) { setDefaultAppearance(adobeDefaultAppearanceString); } // DR entry is required PDResources defaultResources = getDefaultResources(); if (defaultResources == null) { defaultResources = new PDResources(); setDefaultResources(defaultResources); } // Adobe Acrobat uses Helvetica as a default font and // stores that under the name '/Helv' in the resources dictionary // Zapf Dingbats is included per default for check boxes and // radio buttons as /ZaDb. if (!defaultResources.getCOSObject().containsKey("Helv")) { defaultResources.put(COSName.getPDFName("Helv"), PDType1Font.HELVETICA); } if (!defaultResources.getCOSObject().containsKey("ZaDb")) { defaultResources.put(COSName.getPDFName("ZaDb"), PDType1Font.ZAPF_DINGBATS); } }
private void assignAcroFormDefaultResource(PDAcroForm acroForm, COSDictionary newDict) { // read and set/update AcroForm default resource dictionary /DR if available COSBase newBase = newDict.getDictionaryObject(COSName.DR); if (newBase instanceof COSDictionary) { COSDictionary newDR = (COSDictionary) newBase; PDResources defaultResources = acroForm.getDefaultResources(); if (defaultResources == null) { acroForm.getCOSObject().setItem(COSName.DR, newDR); newDR.setDirect(true); newDR.setNeedToBeUpdated(true); } else { COSDictionary oldDR = defaultResources.getCOSObject(); COSBase newXObjectBase = newDR.getItem(COSName.XOBJECT); COSBase oldXObjectBase = oldDR.getItem(COSName.XOBJECT); if (newXObjectBase instanceof COSDictionary && oldXObjectBase instanceof COSDictionary) { ((COSDictionary) oldXObjectBase).addAll((COSDictionary) newXObjectBase); oldDR.setNeedToBeUpdated(true); } } } }
private void assignAcroFormDefaultResource(PDAcroForm acroForm, COSDictionary newDict) { // read and set/update AcroForm default resource dictionary /DR if available COSBase newBase = newDict.getDictionaryObject(COSName.DR); if (newBase instanceof COSDictionary) { COSDictionary newDR = (COSDictionary) newBase; PDResources defaultResources = acroForm.getDefaultResources(); if (defaultResources == null) { acroForm.getCOSObject().setItem(COSName.DR, newDR); newDR.setDirect(true); newDR.setNeedToBeUpdated(true); } else { COSDictionary oldDR = defaultResources.getCOSObject(); COSBase newXObjectBase = newDR.getItem(COSName.XOBJECT); COSBase oldXObjectBase = oldDR.getItem(COSName.XOBJECT); if (newXObjectBase instanceof COSDictionary && oldXObjectBase instanceof COSDictionary) { ((COSDictionary) oldXObjectBase).addAll((COSDictionary) newXObjectBase); oldDR.setNeedToBeUpdated(true); } } } }