Hi,

I have experienced this with iTextSHARP 5.4.5.

The problem:

PdfStamper crashes during .Close() if xml-metadata contain a german umlaut.

I have traced that in the source code:

     (XmpMetaParser.cs)
         private static XmlDocument ParseXmlFromBytebuffer(ByteBuffer 
buffer, ParseOptions options) {
             try
             {
                 XmlDocument doc = new XmlDocument();
                 doc.Load(buffer.ByteStream);
                 return doc;
             }

In doc.Load an XmlException is thrown, but only an XmpException is catched.

To verify my assumption I inserted a catch block for XmlException which 
is - as far as possible - identical to that for XmpException (see source 
code below). It looks as if the metadata are copied correctly to the 
target file.

I probably won't use that modification, because I'm not happy modifying 
iText myself. Instead I will try to throw out the metadata by using 
PdfReader/PdfWriter.

But it would be nice if the developpers could correct the problem in the 
next version.

Thanks for the great iText(Sharp) software.

Peter Schwalm


             ...
             catch (XmlException e)
             {
                 XmlDocument doc = new XmlDocument();
//              if (e.ErrorCode == XmpError.BADXML || e.ErrorCode == 
XmpError.BADSTREAM)
                 if (true)
                     {
                     if (options.AcceptLatin1)
                     {
                         buffer = Latin1Converter.Convert(buffer);
                     }

                     if (options.FixControlChars)
                     {
                         try
                         {
                             StreamReader streamReader = new 
StreamReader(buffer.ByteStream, Encoding.GetEncoding(buffer.Encoding));
                             FixAsciiControlsReader fixReader = new 
FixAsciiControlsReader(streamReader);
                             doc.Load(fixReader);
                             return doc;
                         }
                         catch (Exception)
                         {
                             // can normally not happen as the encoding 
is provided by a util function
                             throw new XmpException("Unsupported 
Encoding", XmpError.INTERNALFAILURE, e);
                         }
                     }
                     doc.Load(buffer.ByteStream);
                     return doc;
                 }
                 throw e;
             }
             catch (XmpException e)
             {
                 XmlDocument doc = new XmlDocument();
                 if (e.ErrorCode == XmpError.BADXML || e.ErrorCode == 
XmpError.BADSTREAM)
                 {
                 ....



------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to