将XFDF导入FDFAnnotation并转换为PDAnnotation后,发现PDAnnotationFreeText的字体颜色不见了。
<freetext page="0" rect="376.81193,778.184946,500.283994,807.936941" flags="print" name="373b558a-4892-5fb4-a9aa-b4d7175d3966" title="wwh" subject="Free text" date="D:20190808175721+08'00'" width="0" creationdate="D:20190808175700+08'00'" TextColor="#00CC63" FontSize="17">
<contents>English</contents>
<defaultappearance>0 0 0 rg /Arial 17 Tf</defaultappearance>
<defaultstyle>font: Arial 17pt; text-align: left; color: #00CC63</defaultstyle>
</freetext>
这是导入 FDFAnnotation 后的详细信息
COSDictionary{
COSName{Type}:COSName{Annot};
COSName{Page}:COSInt{0};
COSName{M}:COSString{D:20190808175721+08'00'};
COSName{F}:COSInt{4};
COSName{NM}:COSString{373b558a-4892-5fb4-a9aa-b4d7175d3966};
COSName{Rect}:COSArray{COSFloat{376.81192};COSFloat{778.18494};COSFloat{500.284};COSFloat{807.93695};};
COSName{T}:COSString{wwh};
COSName{CreationDate}:COSString{D:20190808175700+08'00'};
COSName{Subj}:COSString{Free text};
COSName{IT}:COSName{};
COSName{Contents}:COSString{English};
COSName{Subtype}:COSName{FreeText};
COSName{Q}:0;
COSName{DA}:COSString{0 0 0 rg /Arial 17 Tf};
COSName{DS}:COSString{font: Arial 17pt; text-align: left; color: #00CC63};
}
我已提取颜色十六进制代码并尝试转换为 PDColor
int c = Integer.parseInt("#00CC63".substring(1), 16);
float r = ((c & 0xFF0000) >> 16) / 255f;
float g = ((c & 0x00FF00) >> 8) / 255f;
float b = ((c & 0x0000FF) >> 0) / 255f;
PDColor pdc = new PDColor( new float[] { r, g, b }, PDDeviceRGB.INSTANCE);
但是 PDColor 只是改变背景颜色,不是我的期望。我可以知道如何设置字体颜色吗?
这是我的示例文件:https ://1.bitsend.jp/download/c10903041b8af47195daeef1f471a366.html