[
https://issues.apache.org/jira/browse/PDFBOX-4437?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16750067#comment-16750067
]
Andrew Hung commented on PDFBOX-4437:
-------------------------------------
Running into some issues and looks for assistance.
I've attached the [^Stamp_appearance_decoded.txt] of a image stamp, and the
original xfdf [^stamp_annotation.xfdf] which is linked to the PDF [^A1.01 -
MYLES - 2ND-4TH FLOOR PLAN.pdf]
Below is the content of the appearance decoded but replaced the data value
since it was too large, xfdf itself was 378KB.
What I'm trying to do is the following:
1) Use PDAppearanceDictionary (apDict) - this covers the first 2 elements key
AP and N)
2) Create PDFormXObject (form)
3) Set BBox to the form
4) Set Matrix to the form
5) Create PDResources (resources)
6) Create a PDImageXObject (image) using the following:
{code:java}
PDImageXObject imageX = new PDImageXObject(new PDStream(new COSStream()), new
PDResources());
{code}
7) Decode to data value and outputstream (os.write) it to the image like so
{code:java}
os.write( datavalue.getBytes("ISO-8859-1"));
{code}
8) Add PDImageXObject to resources
9) Set resources to form
10) Set normalAppearance to apDict
Part of the issue I face is the root data has reference to xobj1, which needed
to be updated since step 8 creates a new id.
But based on those steps do you see anything wrong in how I'm using the API, or
do I need to go down and build FDF objects for these items and/or working with
a COSDictionary directly?
Attached current updated version of [^FDFAnnotationStamp2.java] (I'll be added
more detailed comments to help in read it better).
{code:java}
<DICT KEY="AP">
<STREAM KEY="N">
<ARRAY KEY="BBox">
<FIXED VAL="0.000000"/>
<FIXED VAL="0.000000"/>
<FIXED VAL="512.000000"/>
<FIXED VAL="512.000000"/>
</ARRAY>
<INT KEY="FormType" VAL="1"/>
<INT KEY="Length" VAL="68"/>
<ARRAY KEY="Matrix">
<FIXED VAL="-0.000000"/>
<FIXED VAL="1.000000"/>
<FIXED VAL="-1.000000"/>
<FIXED VAL="-0.000000"/>
<FIXED VAL="-0.000000"/>
<FIXED VAL="-0.000000"/>
</ARRAY>
<NAME KEY="Name" VAL="FRM"/>
<DICT KEY="Resources">
<DICT KEY="XObject">
<STREAM KEY="xobj1">
<INT KEY="BitsPerComponent" VAL="8"/>
<NAME KEY="ColorSpace" VAL="DeviceRGB"/>
<NAME KEY="Filter" VAL="DCTDecode"/>
<INT KEY="Height" VAL="2033"/>
<BOOL KEY="Interpolate" VAL="true"/>
<INT KEY="Length" VAL="98993"/>
<STREAM KEY="SMask">
<INT KEY="BitsPerComponent" VAL="8"/>
<NAME KEY="ColorSpace" VAL="DeviceGray"/>
<NAME KEY="Filter" VAL="FlateDecode"/>
<INT KEY="Height" VAL="2033"/>
<BOOL KEY="Interpolate" VAL="true"/>
<INT KEY="Length" VAL="18812"/>
<NAME KEY="Subtype" VAL="Image"/>
<NAME KEY="Type" VAL="XObject"/>
<INT KEY="Width" VAL="1089"/>
<DATA ENCODING="HEX" MODE="RAW">bytes</DATA>
</STREAM>
<NAME KEY="Subtype" VAL="Image"/>
<NAME KEY="Type" VAL="XObject"/>
<INT KEY="Width" VAL="1089"/>
<DATA ENCODING="HEX" MODE="RAW">bytes</DATA>
</STREAM>
<STREAM KEY="xobj2">
<INT KEY="BitsPerComponent" VAL="8"/>
<NAME KEY="ColorSpace" VAL="DeviceGray"/>
<NAME KEY="Filter" VAL="FlateDecode"/>
<INT KEY="Height" VAL="2033"/>
<BOOL KEY="Interpolate" VAL="true"/>
<INT KEY="Length" VAL="18812"/>
<NAME KEY="Subtype" VAL="Image"/>
<NAME KEY="Type" VAL="XObject"/>
<INT KEY="Width" VAL="1089"/>
<DATA ENCODING="HEX" MODE="RAW">bytes</DATA>
</STREAM>
</DICT>
</DICT>
<NAME KEY="Subtype" VAL="Form"/>
<NAME KEY="Type" VAL="XObject"/>
<DATA ENCODING="HEX" MODE="RAW">bytes</DATA>
</STREAM>
</DICT>
{code}
> Import XFDF stamp annotation loses appearance
> ---------------------------------------------
>
> Key: PDFBOX-4437
> URL: https://issues.apache.org/jira/browse/PDFBOX-4437
> Project: PDFBox
> Issue Type: Bug
> Components: PDModel
> Affects Versions: 2.0.9, 2.0.10, 2.0.11, 2.0.12, 2.0.13
> Reporter: Andrew Hung
> Priority: Major
> Attachments: A1.01 - MYLES - 2ND-4TH FLOOR PLAN.pdf,
> FDFAnnotationStamp.java, FDFAnnotationStamp2.java,
> Stamp_appearance_decoded.txt, stamp_annotation.xfdf, xfdf stamp annotation to
> PDF.zip
>
>
> When loading an XFDF which has a stamp annotation which contains an
> appearance element after added to the PDF in place of the annotation is an
> box with an X.
> Reviewing the FDFAnnotationStamp class, it skips all internal elements. Is
> there any development being done to enhance this?
> I've attached "xfdf stamp annotation to PDF.zip" which has an example, if you
> open the stamp_annot.xfdf it will show on the PDF. While using PDFBox API
> the only piece missing is the appearance of the stamp.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]