Ejemplo n.º 1
0
        public override FileFormat Match(FileFormatScanJob job)
        {
            if (!ValidateStartBytes(job))
            {
                return(null);
            }

            var contentTypes = OOXmlUtils.GetContentTypesFromZip(job);

            if (string.IsNullOrWhiteSpace(contentTypes))
            {
                return(null);
            }

            if (contentTypes.IndexOf("application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml", StringComparison.Ordinal) == -1 &&
                contentTypes.IndexOf("application/vnd.ms-word.document.macroEnabled.main+xml", StringComparison.Ordinal) == -1)
            {
                return(null);
            }

            var macros      = (contentTypes.IndexOf("application/vnd.ms-word.document.macroEnabled.main+xml", StringComparison.Ordinal) > -1);
            var fingerprint = new WordDocumentFormat(macros);

            return(fingerprint);
        }
        /// <summary>
        /// creates a centimeters custom sized paper.
        /// </summary>
        /// <param name="Width"></param>
        /// <param name="Height"></param>
        /// <param name="LeftMargin"></param>
        /// <param name="RightMargin"></param>
        /// <param name="TopMargin"></param>
        /// <param name="BottomMargin"></param>
        /// <returns></returns>
        public static WordDocumentFormat InCentimeters(double Width,double Height,double LeftMargin,double RightMargin,double TopMargin,double BottomMargin)
        {
            WordDocumentFormat rpf=new WordDocumentFormat();
            rpf.height=(int)(Height*16840/29.7);
            rpf.width=(int)(Width*16840/29.7);
            rpf.margl=(int)(LeftMargin*16840/29.7);
            rpf.margr=(int)(RightMargin*16840/29.7);
            rpf.margt=(int)(TopMargin*16840/29.7);
            rpf.margb=(int)(BottomMargin*16840/29.7);

            return rpf;
        }