Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Thu Sep 18, 2014 10:46 am

Hello,
I created a Docx file using spire, and save some custom properties with different types(bool, int...). When i open the file using word, i see my properties with right types. But when i load this same file using spire, all properties types become string.
It seems that the problem occurs with docx and not Doc format.
I attached the file. Example of property : top_valid : bool
Can you please help me?
Thank you

tarikzaid
 
Posts: 29
Joined: Wed Aug 06, 2014 7:16 am

Fri Sep 19, 2014 2:07 am

Hello,

Thanks for your feedback.
We have reproduced the issue you mentioned, which has been posted to our Dev team, as soon as there are any update, we will let you know ASAP. Sorry for inconvenience.
BTW, we can't open the document you attached.
Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Fri Sep 26, 2014 12:29 pm

Hello,
are there any news about this issue please ?
Thanks

tarikzaid
 
Posts: 29
Joined: Wed Aug 06, 2014 7:16 am

Sun Sep 28, 2014 3:07 am

Hello,

The issue has been resolved, as soon as the newest hotfix is released, we will inform you immediately.
Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Mon Sep 29, 2014 2:47 am

Hello,

Thanks for waiting.
New hot fix has been released. Please download and test Spire.Doc Pack(hot fix) Version:5.2.48.
http://www.e-iceblue.com/downloads/hot_ ... 5.2.48.zip

Best wishes,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Mon Sep 29, 2014 3:07 pm

Thank you for your response.

I tryed your version, the types are saved correctly but i have an other problem, special characters are converted to x005F. any idea ?
Thank you

tarikzaid
 
Posts: 29
Joined: Wed Aug 06, 2014 7:16 am

Tue Sep 30, 2014 2:35 am

Dear tarikzaid,

Thanks for your reply.

I'm sorry that I cannot understand your question.
Please send us more detailed information about your problem, like document, code snippet and so on.

Best regards,
Burning
E-iceblue Support Team
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Thu Oct 23, 2014 12:38 pm

Hello,

When i save the document, some characters in a custom property are converted to character "x005F". I attached a document, you can produce the error with that document.
You open the document normally by using spire and try to read the custom properties, you get the charatcter x005F in some properties.

If you open it by word, the properties are correct.

Thank you

tarikzaid
 
Posts: 29
Joined: Wed Aug 06, 2014 7:16 am

Fri Oct 24, 2014 1:42 am

Dear tarikzaid ,

Thanks for your reply.

I used Spire.Doc v5.2.48 to test the document and there is no character "x005F" here.
Please try Spire.Doc v5.2.48.
Screenshot:
01.png

Best Regards,
Burning
E-iceblue Support Team
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Tue Oct 28, 2014 9:09 am

Dear tarikzaid,

Have you tried Spire.Doc v5.2.48 to resolve the issue?
Please feel free to contact us if you have any problem.

Best Regards,
Burning
E-iceblue Support Team
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Wed Nov 12, 2014 11:22 am

Hello,
i try version 5.2.68 with no success. some charatcetrs are converted to hexadecimal representation.

I add invatiant culture to all methods that read or add properties but still have the problem.

tarikzaid
 
Posts: 29
Joined: Wed Aug 06, 2014 7:16 am

Thu Nov 13, 2014 1:33 am

Dear tarikzaid,

I cannot reproduce this issue on my machine.
Please provide us your system information, programming environment and code snippet.

Best Regards,
Burning
E-iceblue Support Team
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Wed Nov 19, 2014 10:30 am

Hi,
I have two methods :
First method : add the property to the document, here is the code :
Code: Select all
         public static byte[] InjectProperty(string filename, string key, string value)
        {
           
            byte[] result = null;
            CultureInfo cc = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;
            try
            {
                var doc = new Document();
                byte[] file = File.ReadAllBytes(filename);
                using (Stream str = new MemoryStream(file))
                {

                    doc.LoadFromStream(str, FileFormat.Docx);

                    if (doc.CustomDocumentProperties[key] == null)
                    {
                        doc.CustomDocumentProperties.Add(key, value);
                    }
                    else
                    {
                        doc.CustomDocumentProperties[key].Value = value;
                    }
 
                    using (var outstream = new MemoryStream())
                    {
                        doc.SaveToStream(outstream, FileFormat.Docx);
                        result = outstream.ToArray();
                    }

                    doc.Close();
                }

                return result;
            }
            catch (Exception ex)
            {
                throw new AsConfException("Can not save properties document : " + ex.Message, "");
            }
            finally
            {
                Thread.CurrentThread.CurrentCulture = cc;
            }
        }


The second method reads the properties, here is the code :

Code: Select all
public static string GetDocumentProperty(byte[] file, string property)
        {
            string value = "";
            CultureInfo cc = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            try
            {

                var doc = new Spire.Doc.Document();

                using (MemoryStream stream = new MemoryStream(file))
                {
                    doc.LoadFromStream(stream, FileFormat.Auto);
                }
                if (doc.CustomDocumentProperties[property] != null)
                    value = doc.CustomDocumentProperties[property].Value.ToString();

                doc.Close();

                return value;
            }
            catch (Exception ex)
            {
                throw new AsConfException("Can not read properties of the document : " + ex.Message, "");
            }
            finally
            {
                Thread.CurrentThread.CurrentCulture = cc;
            }
        }


Here are the example for add and read a property:

Code: Select all
 byte[] result = InjectProperty(@"Example.docx", "cod_opemsg", "00014875545");
 string value = WordHelper.GetDocumentProperty(result, "cod_opemsg");


And the value i have is _x0030_0014875545. The first 0 is replaced by hex character.

thank you for your help.

Note : i have not this problem with oldest version of spire.

tarikzaid
 
Posts: 29
Joined: Wed Aug 06, 2014 7:16 am

Wed Nov 19, 2014 10:31 am

The Example.docx can be an empty word document.

tarikzaid
 
Posts: 29
Joined: Wed Aug 06, 2014 7:16 am

Thu Nov 20, 2014 1:59 am

Dear tarikzaid,

Thanks for sharing your code.

I have reproduced this issue and posted it to our dev team, we will inform you if there is any update.

Best Regards,
Burning
E-iceblue Support Team
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Return to Spire.Doc

cron