login about faq

The method ZipEntry.ReplaceString(data) returns true but if the method Zip.WriteToMemory is called, the ZipEntry is missing (Version 9.4.1). In the Version 9.4.0 this method still worked.

The LastErrorText does not show any error.

Here shortened what we do.

// Get the document byte[] data = Document.GetDocumentManager().GetDocument(_DCH.DocumentInfo);

Zip.OpenFromMemory(data);

ZipEntry zc = Zip.GetEntryByName("content.xml");
ZipEntry zs = Zip.GetEntryByName("styles.xml");

string content = FileEncoder.GetEncoder().GetString(zc.Inflate());
string style = FileEncoder.GetEncoder().GetString(zs.Inflate());

// do some string processing with content and replace the result with the original content.

zc.ReplaceData(FileEncoder.GetEncoder().GetBytes(content));
zs.ReplaceData(FileEncoder.GetEncoder().GetBytes(style));

// return the zip

return Zip.WriteToMemory();

After retrieving the Zip and opening the Zip-Content the content.xml and style.xml are missing.

asked Oct 31 '13 at 10:28

Apex's gravatar image

Apex
1112


I believe this has already been fixed. Please let me know the .NET Framework version you are using and I'll provide a URL w/ the pre-release download.

link

answered Nov 04 '13 at 11:13

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

We are using the .NET Version 3.5.0.0.

link

answered Nov 05 '13 at 03:27

Apex's gravatar image

Apex
1112

Thanks for your fast fix, but strange enough we have now an other problem with the Zip component.

What we are doing:

..

byte[] data = Retrieve a 'Open-Office.odt' file.

Zip zip = new Zip();

zip.OpenFromMemory(data);

return zip.WriteToMemory();

..

Using the Chilkat Version 9.4.0 the document can be opened by the 'Open-Office 3.2' application. Using the Chilkat Version 9.4.1.1 (preRelease) the document cannot be opened and the Open Office application tells me that the document is invalid (broken) and has to be fixed. And of course the LastErrorText does not show any error.

Loading the data directly (without the Zip component) into 'Open-Office' works as expected.

The problem we have is, that we are using Chilkat with IMap, too. Here we need a fix done in the 9.4.1 version.

Any hints?

link

answered Nov 11 '13 at 09:51

Apex's gravatar image

Apex
1112

We are manipulating Open-Office documents templates (e. g. creating personalized news letter, contracts).
In order to retrieve the effects following steps can be made:

  1. Load the document into a byte array:

            FileStream fs = new FileStream(File, FileMode.Open, FileAccess.Read, FileShare.Read);
            int length = (int)fs.Length;
            byte[] buffer = new byte[length];
            fs.Read(buffer, 0, length);
    
  2. Create a new Zip object and call the 'OpenFromMemory' method.

            Zip zip = new Zip();
            zip.OpenFromMemory(buffer);
    
  3. Write directly into another byte array:

            byte[] result = zip.WriteToMemory();
    
  4. Now we retrieve this content by download using an application/octet stream.

  5. Save the document and open it with the 'Open-Office' application.

  6. With the version 9.4.0 everything is ok. With the version 9.4.1 prerelease 'Open-Office' throws an error indicating the document is broken and needs to be fixed.

Comparing the hex values of the both documents we can see slight differences between the documents (it seems in the internal file structure. The files itself seem to be ok. The method 'OpenFromMemory' returns true. The LastErrorText of the WriteToMemory is:
ChilkatLog:
WriteToMemory:
DllDate: Oct 22 2013
ChilkatVersion: 9.4.1.66
UnlockPrefix: *** Username: SV-DEV-03:DefaultAppPool
Architecture: Little Endian; 32-bit
Language: .NET 2.0
VerboseLogging: 0
targetZipPath: unnamed.zip
writeZipToOutput:
oemCodePage: 850
encryption: 0
passwordProtected: 0
totalSize64: 26131
numCentralDirRecords: 17
--writeZipToOutput
Success.
--WriteToMemory
--ChilkatLog

link

answered Nov 12 '13 at 08:36

Apex's gravatar image

Apex
1112

Thanks! I'm sorry for my confusion -- I didn't realize that .odt files were actually .zip archives. I'm investigating..

(Nov 12 '13 at 11:23) chilkat ♦♦

The problem was due to the use of data descriptors in the zip format. When Chilkat re-writes, it automatically removes the data descriptors and write a friendlier zip. It didn't do this quite correctly. I found and fixed the problem, and I'll post a new build URL when it's ready.

link

answered Nov 12 '13 at 17:51

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

link

answered Nov 12 '13 at 19:19

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

I tested both new builds. Now it seems working. Thank you very much for your fast support.

(Nov 14 '13 at 04:24) Apex

This makes me worried that the behavior also affects .docx documents. I wrote a while ago about a similar ReplaceString issue. Though it was solved any appeared to be working, I am wondering if that is only because Microsoft Word ignores minor structural errors ?!?

Can you confirm this and if it relates only to the WriteToMemory() method or also WriteZipAndClose() ?

link

answered Nov 13 '13 at 14:20

roan98dk's gravatar image

roan98dk
326192034

I've tested the 9.4.1/prerelease version from Nov 05 at 14:25. It seems that .docx documents ignore minor structural errors in opposite of .odt documents.

(Nov 14 '13 at 04:18) Apex

The problem would've applied to both WriteToMemory and WriteZipAndClose. Internally, the zip writing software writes to an "output" which can be either memory or a file.

The Zip format is such that information about the files is redundant -- for example, the filename/path of each file within the zip is stored twice - once in the local file header, and once in the central directory header. The same applies to many other pieces of information. The issue with re-writing a .zip that uses data descriptors (which is generally uncommon) was such that the problem occurred in one of the two places

(Nov 15 '13 at 11:28) chilkat ♦♦

I see a similar problem in 9.4.1.0 : a call to ReplaceData causes the FileName property of the Entry to go blank.

Before I test the new pre-release version from the download link above, could you explain why the dll file name is changed from ChilkatDotNet4.dll to ChilkatDotNet2.dll ?

Thanks!

link

answered Nov 26 '13 at 14:26

ixm7's gravatar image

ixm7
632210

Please ignore. Re-assigning the FileName property immediately after the ReplaceData() call seems to fix the issue.

link

answered Nov 26 '13 at 14:36

ixm7's gravatar image

ixm7
632210

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×87

Asked: Oct 31 '13 at 10:28

Seen: 1,959 times

Last updated: Nov 26 '13 at 14:36

powered by OSQA