File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -116,7 +116,7 @@ public FDFAnnotationStamp(Element element) throws IOException
116116 }
117117 if (base64EncodedAppearance != null && !base64EncodedAppearance .isEmpty ())
118118 {
119- LOG .debug ("Decoded XML: {} " , () -> new String (decodedAppearanceXML , StandardCharsets .UTF_8 ));
119+ LOG .debug ("Decoded XML:\n ==== \n {} \n ==== " , () -> new String (decodedAppearanceXML , StandardCharsets .UTF_8 ));
120120
121121 Document stampAppearance = XMLUtil
122122 .parse (new ByteArrayInputStream (decodedAppearanceXML ));
@@ -253,8 +253,16 @@ else if ("ASCII".equals(childEncodingAttr))
253253 {
254254 try (OutputStream os = stream .createOutputStream ())
255255 {
256- // not sure about charset
257- os .write (child .getTextContent ().getBytes ());
256+ String encoding = child .getOwnerDocument ().getXmlEncoding ();
257+ if (encoding == null )
258+ {
259+ encoding = child .getOwnerDocument ().getInputEncoding ();
260+ }
261+ if (encoding == null )
262+ {
263+ encoding = "UTF-8" ;
264+ }
265+ os .write (child .getTextContent ().getBytes (encoding ));
258266 LOG .debug ("{} => Data was streamed" , parentAttrKey );
259267 }
260268 }
You can’t perform that action at this time.
0 commit comments