Returns the final binary representation of the current document.
426746
def output(params = {})

            has_objstm = self.each_object.any?{|obj| obj.is_a?(ObjectStream)}

            options =
            {
                eol: $/,
                rebuild_xrefs: true,
                noindent: false,
                obfuscate: false,
                use_xrefstm: has_objstm,
                use_xreftable: (not has_objstm),
                up_to_revision: @revisions.size
            }
            options.update(params)

            # Ensures we are using a valid EOL delimiter.
            assert_valid_eol(options[:eol])

            # Do not emit more revisions than present in the document.
            options[:up_to_revision] = [ @revisions.size, options[:up_to_revision] ].min

            # Reset to default params if no xrefs are chosen (hybrid files not supported yet)
            if options[:use_xrefstm] == options[:use_xreftable]
                options[:use_xrefstm] = has_objstm
                options[:use_xreftable] = (not has_objstm)
            end

            # Indent level for objects.
            indent = (options[:noindent] == true ? 0 : 1)

            # Get trailer dictionary
            trailer_dict = self.trailer.dictionary

            prev_xref_offset = nil
            xrefstm_offset = nil

            # Header
            bin = ""
            bin << @header.to_s(eol: options[:eol])

            # For each revision
            @revisions[0, options[:up_to_revision]].each do |rev|

                # Create xref table/stream.
                if options[:rebuild_xrefs] == true
                    lastno_table, lastno_stm = 0, 0
                    brange_table, brange_stm = 0, 0

                    xrefs_stm = [ XRef.new(0, 0, XRef::FREE) ]
                    xrefs_table = [ XRef.new(0, XRef::FIRSTFREE, XRef::FREE) ]

                    if options[:use_xreftable] == true
                        xrefsection = XRef::Section.new
                    end

                    if options[:use_xrefstm] == true
                        xrefstm = rev.xrefstm || XRefStream.new
                        if xrefstm == rev.xrefstm
                            xrefstm.clear
                        else
                            add_to_revision(xrefstm, rev)
                        end
                    end
                end

                objset = rev.objects

                objset.find_all{|obj| obj.is_a?(ObjectStream)}.each do |objstm|
                    objset.concat objstm.objects
                end if options[:rebuild_xrefs] == true and options[:use_xrefstm] == true

                previous_obj = nil

                # For each object, in number order
                # Move any XRefStream to the end of the revision.
                objset.sort_by {|obj| [obj.is_a?(XRefStream) ? 1 : 0, obj.no, obj.generation] }
                      .each do |obj|

                    # Ensures that every object has a unique reference number.
                    # Duplicates should never happen in a well-formed revision and will cause breakage of xrefs.
                    if previous_obj and previous_obj.reference == obj.reference
                        raise InvalidPDFError, "Duplicate object detected, reference #{obj.reference}"
                    else
                        previous_obj = obj
                    end

                    # Create xref entry.
                    if options[:rebuild_xrefs] == true

                        # Adding subsections if needed
                        if options[:use_xreftable] and (obj.no - lastno_table).abs > 1
                            xrefsection << XRef::Subsection.new(brange_table, xrefs_table)

                            xrefs_table.clear
                            brange_table = obj.no
                        end

                        if options[:use_xrefstm] and (obj.no - lastno_stm).abs > 1
                            xrefs_stm.each do |xref| xrefstm << xref end
                            xrefstm.Index ||= []
                            xrefstm.Index << brange_stm << xrefs_stm.length

                            xrefs_stm.clear
                            brange_stm = obj.no
                        end

                        # Process embedded objects
                        if options[:use_xrefstm] and obj.parent != obj and obj.parent.is_a?(ObjectStream)
                            index = obj.parent.index(obj.no)

                            xrefs_stm << XRefToCompressedObject.new(obj.parent.no, index)

                            lastno_stm = obj.no
                        else
                            xrefs_stm << XRef.new(bin.size, obj.generation, XRef::USED)
                            xrefs_table << XRef.new(bin.size, obj.generation, XRef::USED)

                            lastno_table = lastno_stm = obj.no
                        end
                    end

                    if obj.parent == obj or not obj.parent.is_a?(ObjectStream)

                        # Finalize XRefStm
                        if options[:rebuild_xrefs] == true and options[:use_xrefstm] == true and obj == xrefstm
                            xrefstm_offset = bin.size

                            xrefs_stm.each do |xref| xrefstm << xref end

                            xrefstm.W = [ 1, (xrefstm_offset.to_s(2).size + 7) >> 3, 2 ]
                            if xrefstm.DecodeParms.is_a?(Dictionary) and xrefstm.DecodeParms.has_key?(:Columns)
                                xrefstm.DecodeParms[:Columns] = xrefstm.W[0] + xrefstm.W[1] + xrefstm.W[2]
                            end

                            xrefstm.Index ||= []
                            xrefstm.Index << brange_stm << xrefs_stm.size

                            xrefstm.dictionary = xrefstm.dictionary.merge(trailer_dict)
                            xrefstm.Prev = prev_xref_offset
                            rev.trailer.dictionary = nil

                            add_to_revision(xrefstm, rev)

                            xrefstm.pre_build
                            xrefstm.post_build
                        end

                        # Output object code
                        if (obj.is_a?(Dictionary) or obj.is_a?(Stream))
                            bin << obj.to_s(eol: options[:eol], indent: indent)
                        else
                            bin << obj.to_s(eol: options[:eol])
                        end
                    end
                end # end each object

                rev.trailer ||= Trailer.new

                # XRef table
                if options[:rebuild_xrefs] == true

                    if options[:use_xreftable] == true
                        table_offset = bin.size

                        xrefsection << XRef::Subsection.new(brange_table, xrefs_table)
                        rev.xreftable = xrefsection

                        rev.trailer.dictionary = trailer_dict
                        rev.trailer.Size = objset.size + 1
                        rev.trailer.Prev = prev_xref_offset

                        rev.trailer.XRefStm = xrefstm_offset if options[:use_xrefstm] == true
                    end

                    startxref = options[:use_xreftable] == true ? table_offset : xrefstm_offset
                    rev.trailer.startxref = prev_xref_offset = startxref

                end

                # Trailer
                bin << rev.xreftable.to_s(eol: options[:eol]) if options[:use_xreftable] == true
                bin << (options[:obfuscate] == true ? rev.trailer.to_obfuscated_str : rev.trailer.to_s(eol: options[:eol], indent: indent))

            end # end each revision

            bin
        end
1054262
def extractImage(self, xref=0):
        """"""
        if self.isClosed or self.isEncrypted:
            raise ValueError("operation illegal for closed / encrypted doc")

        return _fitz.Document_extractImage(self, xref)
1065611
function hashDocument(document) {
  var words;

  if (Buffer.isBuffer(document)) {
    words = Base64.parse(document.toString('base64'));
  } else if (typeof document === 'string') {
    words = Base64.parse(document);
  } else {
    throw new TypeError('Expected document to be Buffer or String');
  }

  var hash = sha256(words);

  return hash.toString(Hex);
}
1018120
def to_binary_string(self, code, identifier):
        """"""
        return struct.pack(self.FORMAT, self.COMMAND, code, identifier)
363893
private ContentStream jcrBinaryContent( Document document ) {
        // pickup node properties
        Document props = document.getDocument("properties").getDocument(JcrLexicon.Namespace.URI);

        // extract binary value and content
        Binary value = props.getBinary("data");

        if (value == null) {
            return null;
        }

        byte[] content = value.getBytes();
        String fileName = props.getString("fileName");
        String mimeType = props.getString("mimeType");

        // wrap with input stream
        ByteArrayInputStream bin = new ByteArrayInputStream(content);
        bin.reset();

        // create content stream
        return new ContentStreamImpl(fileName, BigInteger.valueOf(content.length), mimeType, bin);
    }
995056
public function getDocumentType()
    {
        if (!$this->version) {
            $version = (string) $this->VERSION;

            switch ($version) {
                case '2.1':
                    $this->version = self::VCARD21;
                    break;
                case '3.0':
                    $this->version = self::VCARD30;
                    break;
                case '4.0':
                    $this->version = self::VCARD40;
                    break;
                default:
                    // We don't want to cache the version if it's unknown,
                    // because we might get a version property in a bit.
                    return self::UNKNOWN;
            }
        }

        return $this->version;
    }
83481
def complete(self):
        """"""
        if Part.count(self) != self.last_part_number + 1:
            raise MultipartMissingParts()

        with db.session.begin_nested():
            self.completed = True
            self.file.readable = True
            self.file.writable = False
        return self
786936
public BsonDocument toBsonDocument() {
    final BsonDocument updateDescDoc = new BsonDocument();
    updateDescDoc.put(
        Fields.UPDATED_FIELDS_FIELD,
        this.getUpdatedFields());

    final BsonArray removedFields = new BsonArray();
    for (final String field : this.getRemovedFields()) {
      removedFields.add(new BsonString(field));
    }
    updateDescDoc.put(
        Fields.REMOVED_FIELDS_FIELD,
        removedFields);

    return updateDescDoc;
  }
729891
def as_bin(self):
        """"""
        f = io.BytesIO()
        self.stream(f)
        return f.getvalue()
512054
function processRetrievedDocument(document, filePrismicMetadata, queryKey, ctx) {
            // add the complete result except for the data fragments
            var result = _.omit(document, 'fragments');
            result.data = {};

            // process the data fragments, invoking helpers to make the data more usable
            if (document.fragments != null && Object.keys(document.fragments).length  > 0) {
                for (var fragmentFullName in document.fragments) {

                    // strip the document type from the fragment name
                    var fragmentName = fragmentFullName.substr(fragmentFullName.lastIndexOf('.') + 1);

                    var fragment = document.fragments[fragmentFullName];
                    result.data[fragmentName] = processSingleFragment(fragment, ctx, filePrismicMetadata[queryKey]);
                }
            }

            return result;
        }
865959
def _getNewXref(self):
        """"""
        if self.isClosed or self.isEncrypted:
            raise ValueError("operation illegal for closed / encrypted doc")

        return _fitz.Document__getNewXref(self)
1083868
private void convertOldDocument() {

        Document newDocument = DocumentHelper.createDocument();
        Element root = newDocument.addElement(NODE_PAGES);
        root.add(I_CmsXmlSchemaType.XSI_NAMESPACE);
        root.addAttribute(I_CmsXmlSchemaType.XSI_NAMESPACE_ATTRIBUTE_NO_SCHEMA_LOCATION, XMLPAGE_XSD_SYSTEM_ID);

        Map<String, Element> pages = new HashMap<String, Element>();

        if ((m_document.getRootElement() != null) && (m_document.getRootElement().element(NODE_ELEMENTS) != null)) {
            for (Iterator<Element> i = CmsXmlGenericWrapper.elementIterator(
                m_document.getRootElement().element(NODE_ELEMENTS),
                NODE_ELEMENT); i.hasNext();) {

                Element elem = i.next();
                try {
                    String elementName = elem.attributeValue(ATTRIBUTE_NAME);
                    String elementLang = elem.attributeValue(ATTRIBUTE_LANGUAGE);
                    String elementEnabled = elem.attributeValue(ATTRIBUTE_ENABLED);
                    boolean enabled = (elementEnabled == null) ? true : Boolean.valueOf(elementEnabled).booleanValue();

                    Element page = pages.get(elementLang);
                    if (page == null) {
                        // no page available for the language, add one
                        page = root.addElement(NODE_PAGE).addAttribute(ATTRIBUTE_LANGUAGE, elementLang);
                        pages.put(elementLang, page);
                    }

                    Element newElement = page.addElement(NODE_ELEMENT).addAttribute(ATTRIBUTE_NAME, elementName);
                    if (!enabled) {
                        newElement.addAttribute(ATTRIBUTE_ENABLED, String.valueOf(enabled));
                    }
                    Element links = elem.element(NODE_LINKS);
                    if (links != null) {
                        newElement.add(links.createCopy());
                    }
                    Element content = elem.element(NODE_CONTENT);
                    if (content != null) {
                        newElement.add(content.createCopy());
                    }

                } catch (NullPointerException e) {
                    LOG.error(Messages.get().getBundle().key(Messages.ERR_XML_PAGE_CONVERT_CONTENT_0), e);
                }
            }
        }

        // now replace the old with the new document
        m_document = newDocument;
    }
1243421
def parse_binary(self):

		'''
		
		'''

		# derive mimetype
		self.mimetype = self.resource.rdf.graph.value(
			self.resource.uri,
			self.resource.rdf.prefixes.ebucore.hasMimeType).toPython()

		# get binary content as stremable response
		self.data = self.resource.repo.api.http_request(
			'GET',
			self.resource.uri,
			data=None,
			headers={'Content-Type':self.resource.mimetype},
			is_rdf=False,
			stream=True)
104992
def _getOLRootNumber(self):
        """"""
        if self.isClosed or self.isEncrypted:
            raise ValueError("operation illegal for closed / encrypted doc")

        return _fitz.Document__getOLRootNumber(self)
690678
def text(self) -> bytes:
        """"""
        if self.condition:
            if self.code:
                return BytesFormat(b'%b %b %b') \
                    % (self.condition, self.code, self._text)
            else:
                return BytesFormat(b'%b %b') % (self.condition, self._text)
        else:
            return bytes(self._text)
925919
def tohexstring(self):
        
        val = self.tostring()
        st = "{0:0x}".format(int(val, 2))
        return st.zfill(len(self.bitmap)*2)
486391
def to_document(self):
        
        return dict(
            info=thaw(self.info),
            paths=thaw(self.paths),
            definitions=thaw(self.definitions),
            securityDefinitions=thaw(self.securityDefinitions),
            security=thaw(self.security),
            swagger=thaw(self.swagger),
        )