use of com.tom_roush.pdfbox.pdmodel.PDResources in project PdfBox-Android by TomRoush.
the class PDAcroForm method verifyOrCreateDefaults.
/*
* Verify that there are default entries for required
* properties.
*
* If these are missing create default entries similar to
* Adobe Reader / Adobe Acrobat
*
*/
private void verifyOrCreateDefaults() {
final String adobeDefaultAppearanceString = "/Helv 0 Tf 0 g ";
// DA entry is required
if (getDefaultAppearance().length() == 0) {
setDefaultAppearance(adobeDefaultAppearanceString);
dictionary.setNeedToBeUpdated(true);
}
// DR entry is required
PDResources defaultResources = getDefaultResources();
if (defaultResources == null) {
defaultResources = new PDResources();
setDefaultResources(defaultResources);
dictionary.setNeedToBeUpdated(true);
}
// PDFBOX-3732: 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.
// PDFBOX-4393: the two fonts are added by Adobe when signing
// and this breaks a previous signature. (Might be an Adobe bug)
COSDictionary fontDict = defaultResources.getCOSObject().getCOSDictionary(COSName.FONT);
if (fontDict == null) {
fontDict = new COSDictionary();
defaultResources.getCOSObject().setItem(COSName.FONT, fontDict);
}
if (!fontDict.containsKey(COSName.HELV)) {
defaultResources.put(COSName.HELV, PDType1Font.HELVETICA);
defaultResources.getCOSObject().setNeedToBeUpdated(true);
fontDict.setNeedToBeUpdated(true);
}
if (!fontDict.containsKey(COSName.ZA_DB)) {
defaultResources.put(COSName.ZA_DB, PDType1Font.ZAPF_DINGBATS);
defaultResources.getCOSObject().setNeedToBeUpdated(true);
fontDict.setNeedToBeUpdated(true);
}
}
use of com.tom_roush.pdfbox.pdmodel.PDResources in project PdfBox-Android by TomRoush.
the class PDAcroForm method resolveNeedsTranslation.
/**
* Check if there is a translation needed to place the annotations content.
*
* @param appearanceStream
* @return the need for a translation transformation.
*/
private boolean resolveNeedsTranslation(PDAppearanceStream appearanceStream) {
boolean needsTranslation = true;
PDResources resources = appearanceStream.getResources();
if (resources != null && resources.getXObjectNames().iterator().hasNext()) {
Iterator<COSName> xObjectNames = resources.getXObjectNames().iterator();
while (xObjectNames.hasNext()) {
try {
// if the BBox of the PDFormXObject does not start at 0,0
// there is no need do translate as this is done by the BBox definition.
PDXObject xObject = resources.getXObject(xObjectNames.next());
if (xObject instanceof PDFormXObject) {
PDRectangle bbox = ((PDFormXObject) xObject).getBBox();
float llX = bbox.getLowerLeftX();
float llY = bbox.getLowerLeftY();
if (Float.compare(llX, 0) != 0 && Float.compare(llY, 0) != 0) {
needsTranslation = false;
}
}
} catch (IOException e) {
// we can safely ignore the exception here
// as this might only cause a misplacement
}
}
return needsTranslation;
}
return true;
}
use of com.tom_roush.pdfbox.pdmodel.PDResources in project PdfBox-Android by TomRoush.
the class PDVisibleSigBuilder method createInnerFormResource.
@Override
public void createInnerFormResource() {
PDResources innerFormResources = new PDResources();
pdfStructure.setInnerFormResources(innerFormResources);
Log.i("PdfBox-Android", "Resources of another form (inner form - it will be inside holder form)" + "have been created");
}
use of com.tom_roush.pdfbox.pdmodel.PDResources in project PdfBox-Android by TomRoush.
the class PDVisibleSigBuilder method createHolderFormResources.
@Override
public void createHolderFormResources() {
PDResources holderFormResources = new PDResources();
pdfStructure.setHolderFormResources(holderFormResources);
Log.i("PdfBox-Android", "Holder form resources have been created");
}
use of com.tom_roush.pdfbox.pdmodel.PDResources in project PdfBox-Android by TomRoush.
the class PDVisibleSigBuilder method createImageFormResources.
@Override
public void createImageFormResources() {
PDResources imageFormResources = new PDResources();
pdfStructure.setImageFormResources(imageFormResources);
Log.i("PdfBox-Android", "Created image form resources");
}
Aggregations