Giter Site home page Giter Site logo

omnidocx's People

Contributors

bdknox avatar parthnagori avatar senych-vitalii avatar xukeek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

omnidocx's Issues

Gem is not thread safe

The Omnidocx::Docx.merge_documents method is static, but it sets instance variables. As a result, running in a threaded environment you will end up sharing values and writing between files. You can recreate this pretty easily by setting debugger breakpoints after instance variables are set, trigger merging documents on multiple threads, and you'll see data written between files incorrectly.

def self.merge_documents(documents_to_merge = [], final_path, page_break)
  temp_file = Tempfile.new('docxedit-')
  documents_to_merge_count = documents_to_merge.count

  if documents_to_merge_count < 2
    return "Pass atleast two documents to be merged"   #minimum two documents required to merge
  end

  # FIXME: _These should not be instance variables_
  @main_document_zip = Zip::File.new(documents_to_merge.first)
  @main_document_xml = Nokogiri::XML(@main_document_zip.read(DOCUMENT_FILE_PATH))
  @main_body = @main_document_xml.xpath("//w:body")
  @rel_doc = ""
  @cont_type_doc = ""
  @style_doc = ""
  doc_cnt = 0
  #cnt variable to construct relationship ids, taken a high value 100 to avoid duplication
  cnt = 100
  tbl_cnt = 10
  #hash to store information about the media files and their corresponding new names
  media_hash = {}
  #rid_hash to store relationship information
  rid_hash = {}
  #table hash to store information if any tables present
  table_hash = {}
  #head_foot_media hash to store if any media files present in header/footer
  head_foot_media = {}
  #a counter for docPr element in the main document body
  docPr_id = 100

  #array to store content type information about media extensions
  default_extensions = []
  #array to store override content type information
  override_partnames = []

  #array to store information about additional content types other than the ones present in the first(main) document
  additional_cont_type_entries = []

  # prepare initial set of data from first document
  @main_document_zip.entries.each do |zip_entrie|
    in_stream = zip_entrie.get_input_stream.read

Error while merging document with no header and footer

I am simply merging 2 documents, out of which of which the first document of array does not have any header and footer, at that time i am getting this exception NoMethodError: undefined method 'attributes' for nil:NilClass on line 323 in omnidocx.rb

rubyzip dependency

omnidocx was resolved to 0.1.4, which depends on
rubyzip (>= 1.1.6, ~> 1.1)

Would be nice to move the dependency of ruby zip to a grather version

Malformed <Relationship> Node When Merging Documents (affects merging documents with images)

In def self.merge_documents, when attaching a new Relationship node (new_rel_node = "<Relationship Id=#{new_id} Type=#{node["Type"]} Target=#{target_val} />"), Nokogiri will attempt to fix the XML and in the process lowercase all of the attributes, resulting in a corrupt word/_rels/document.xml.rels (e.g. <relationship id="rId101" type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" target="media/image101.png"/>).

Proposed solution would be to either properly escape new_rel_node, e.g. new_rel_node = "<Relationship Id=\"#{new_id}\" Type=\"#{node["Type"]}\" Target=\"#{target_val}\" />", or to use Nokogiri::XML::Node.new to properly create the node

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.