public override Stream ProcessPart(Stream partData, DocumentText discoveryText, RelatedPartProvider relPartProvider, DocumentProcessingActions action)
        {
            //this is for the discovery on open documents - the copy loses all other macro information except this items
            //specifying macro content - there is a single vbaproject.bin file containing all macros
            //so far this appears to be valid

            if (DocumentProcessor.ActionIncludesCleaning(action))
                return null;

            if (action == DocumentProcessingActions.PassThrough)
                return partData;

            if (m_bInterestedInMacros)
            {
                List<IAbstractTextType> ttypes = discoveryText.GetTextTypes(ContentType.Macro);
                TextType macro = null;
                if (ttypes.Count > 0)
                {
                    macro = (TextType)ttypes[0];
                }
                else
                {
                    macro = new TextType(ContentType.Macro);
                    discoveryText.AddTextType(macro);
                }

                TextNode macroNode = new TextNode();
                NodeInfo ni = new NodeInfo();
                ni.name = "Id";
                ni.value = m_id;
                ni.type = DataType.String;
                macroNode.AddInfo(ni);

                ni = new NodeInfo();
                ni.name = "Target";
                ni.value = m_target;
                ni.type = DataType.String;
                macroNode.AddInfo(ni);

                ni = new NodeInfo();
                ni.name = "Type";
                ni.value = m_type;
                ni.type = DataType.String;
                macroNode.AddInfo(ni);

                macro.AddChild(macroNode);
            }

            Initialize();
            ConstructFilter(partData, discoveryText, action);
            ExecuteFilter();
            return m_outStream;
        }
示例#2
0
        public DocumentText Execute()
        {
            _docText = new DocumentText();
            _paraType = new TextType(ContentType.Paragraph);
            _docText.AddTextType(_paraType);

            _builder = new StringBuilder();
            _iPos = 0;

            // Properties
            try
            {
                foreach (KeyValuePair<string, string> kvp in Workshare.Pdf.Reader.GetProperties(_file, _password))
                {
                    AddProperty(kvp.Key, kvp.Value);
                }
            }
            catch(Exception ex)
            {
                AddError(ex.Message);
            }

            // Content
            try
            {
                foreach (string paragraph in Workshare.Pdf.Reader.GetParagraphs(_file, _password))
                {
                    AddText(paragraph);                    
                    NewParagraph();
                }
            }
            catch(Exception ex)
            {
                AddError(ex.Message);
            }

            return _docText;
        }
示例#3
0
        private TextType FindTextType(DocumentText dt)
        {
            foreach (TextType tt in dt.GetTextTypes())
            {
                if (tt.GetContentType() == ContentType)
                    return tt;
            }

            TextType tt2 = new TextType(ContentType);
            if (ContentType == ContentType.ContentRule)
                return tt2;
            
            dt.AddTextType(tt2);
            return tt2;
        }