Closed rpiazza closed 9 years ago
This example works normally in my irb session, and I was able to open it okay in Office365 and OpenOffice. The output has been tested on Word 2010 and above. Are you perhaps running Word 2007? (There are major differences between the .doc and .docx standards.)
I'm using Office365. However, I couldn't even unzip it using winzip...
I attached the file that was generated.
From: John Dugan [mailto:notifications@github.com] Sent: Tuesday, May 19, 2015 3:54 PM To: trade-informatics/caracal Cc: Piazza, Rich Subject: Re: [caracal] Unable to open document in Word or Winzip (#8)
This example works normally in my irb session, and I was able to open it okay in Office365 and OpenOffice. The output has been tested on Word 2010 and above. Are you perhaps running Word 2007? (There are major differences between the .doc and .docx standards.)
— Reply to this email directly or view it on GitHubhttps://github.com/trade-informatics/caracal/issues/8#issuecomment-103650406.
Github will strip out the attachments from your emails. And don't take this the wrong way, but I wouldn't open an attachment from a stranger anyway. :)
What's weird is I typed the exact set of commands into irb and was able to load the resulting file to Office365 without any issue. (FWIW, the gem is also running right now in a production system and works exactly as advertised there.) I presume there must be some significant difference between my environments and your local environment. Maybe you could dump your ruby version and gemset and I could try to recreate?
Did you change the extension to .zip before you tried to unzip it? (Sorry if that seems like a rudimentary question. I use the compression library that's built into OSX and, as you might expect, it has no idea that .docx files are zipped. I always had to replace .docx with .zip to unpack the file.)
Good point on the attachment :-)
Yes, I changed the extension to zip
ruby 2.1.6p336 (2015-04-13 revision 50298) [x64-mingw32]
bigdecimal (1.2.4) bundler (1.9.9) caracal (0.2.1) diff-lcs (1.2.5) io-console (0.4.3) json (1.8.1) mini_portile (0.6.2) minitest (4.7.5) nokogiri (1.6.6.2 x64-mingw32) psych (2.0.5) rake (10.4.2, 10.1.0) rdoc (4.1.0) rspec (3.2.0) rspec-core (3.2.3) rspec-expectations (3.2.1) rspec-mocks (3.2.1) rspec-support (3.2.2) rubyzip (1.1.7) stix_schema_spy (1.3) test-unit (2.1.6.0) tilt (1.4.1)
Hi Rich,
There's a high likelihood this is a Windows-specific issue. As far as I know, we've only used this gem in Unix/Linux environments. Do you have access to a Linux or Unix (or OS X) environment? If so, can you try running it there to see if you get the same results?
Cheers, Tim
On Wed, May 20, 2015 at 7:20 AM, Rich Piazza notifications@github.com wrote:
Good point on the attachment :-)
Yes, I changed the extension to zip
ruby 2.1.6p336 (2015-04-13 revision 50298) [x64-mingw32]
bigdecimal (1.2.4) bundler (1.9.9) caracal (0.2.1) diff-lcs (1.2.5) io-console (0.4.3) json (1.8.1) mini_portile (0.6.2) minitest (4.7.5) nokogiri (1.6.6.2 x64-mingw32) psych (2.0.5) rake (10.4.2, 10.1.0) rdoc (4.1.0) rspec (3.2.0) rspec-core (3.2.3) rspec-expectations (3.2.1) rspec-mocks (3.2.1) rspec-support (3.2.2) rubyzip (1.1.7) stix_schema_spy (1.3) test-unit (2.1.6.0) tilt (1.4.1)
— Reply to this email directly or view it on GitHub https://github.com/trade-informatics/caracal/issues/8#issuecomment-103885242 .
Tim Lowrimore Coroutine LLC 1877 Broadway St., Suite 100 Boulder, CO 80302 901.490.5325 http://www.coroutine.com
Yes, that's my guess, too.
What's interesting to me is Nokogiri is the only natively-compiled gem used and we don't do anything particularly sophisticated with it. Caracal really ought to work fine on a PC. I'm pretty curious about what's causing the issue.
I tried it on a Mac - it worked fine. I copied the file back to my Windows box and it opened in Word with no issues.
If I can get you the two files, you can compare them - although I have a feeling it is the zip algorithm
What I'd recommend is taking Caracal out of the equation. Try using rubyzip to zip up any set of files on your PC. If you get the same behavior, then I think you'll want to log that non-Caracal example as an issue with the rubyzip team.
I have moved to a Linux box - and this is no longer a problem
@rpiazza Welcome to GNU/Linux. If only all my clients (and their clients) would do the same.
I produced a sample doc, using the following commands, in irb:
docx = Caracal::Document.new("fred.docx") para2 = "fooz" docx.p para2 buffer = docx.render File.open("./#{docx.name}", 'w') { |f| f.write(buffer.string) }
but the document doesn't open in Word or Winzip. Winzip gives the error: Error: Central Directory not found . I tried 7zip, which opens the file, but then it I get an "unsupported compression method" error when I try to extract a file.