Пример #1
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            Document           doc  = new Document(dataDir + "input.pdf");
            Page               page = doc.Pages[2];
            OperatorCollection oc   = page.Contents;

            // used path-painting operators
            Operator[] operators = new Operator[] {
                new Operator.Stroke(),
                new Operator.ClosePathStroke(),
                new Operator.Fill()
            };

            ArrayList list = new ArrayList();

            foreach (Operator op in operators)
            {
                OperatorSelector os = new OperatorSelector(op);
                oc.Accept(os);
                list.AddRange(os.Selected);
            }

            oc.Delete(list);

            doc.Save(dataDir + "No_Graphics.pdf");
        }
Пример #2
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            Document doc = new Document(dataDir+ "input.pdf");
            Page page = doc.Pages[2];
            OperatorCollection oc = page.Contents;

            // used path-painting operators
            Operator[] operators = new Operator[] {
            new Operator.Stroke(),
            new Operator.ClosePathStroke(),
            new Operator.Fill()
            };

            ArrayList list = new ArrayList();
            foreach (Operator op in operators)
            {
                OperatorSelector os = new OperatorSelector(op);
                oc.Accept(os);
                list.AddRange(os.Selected);
            }

            oc.Delete(list);

            doc.Save(dataDir+ "No_Graphics.pdf");
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Operators();

            Document doc = new Document(dataDir+ "RemoveGraphicsObjects.pdf");
            Page page = doc.Pages[2];
            OperatorCollection oc = page.Contents;

            // used path-painting operators
            Operator[] operators = new Operator[] {
new Operator.Stroke(),
new Operator.ClosePathStroke(),
new Operator.Fill()
};

            ArrayList list = new ArrayList();
            foreach (Operator op in operators)
            {
                OperatorSelector os = new OperatorSelector(op);
                oc.Accept(os);
                list.AddRange(os.Selected);
            }

            oc.Delete(list);

            doc.Save(dataDir+ "No_Graphics.pdf");
            
            
        }
        public static void Run()
        {
            // ExStart:RemoveGraphicsObjects
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Operators();

            Document           doc  = new Document(dataDir + "RemoveGraphicsObjects.pdf");
            Page               page = doc.Pages[2];
            OperatorCollection oc   = page.Contents;

            // Used path-painting operators
            Operator[] operators = new Operator[] {
                new Operator.Stroke(),
                new Operator.ClosePathStroke(),
                new Operator.Fill()
            };

            ArrayList list = new ArrayList();

            foreach (Operator op in operators)
            {
                OperatorSelector os = new OperatorSelector(op);
                oc.Accept(os);
                list.AddRange(os.Selected);
            }

            oc.Delete(list);
            doc.Save(dataDir + "No_Graphics_out.pdf");
            // ExEnd:RemoveGraphicsObjects
        }
        /// <summary>
        /// Gets the <paramref name="type" />'s implicit operator of the type specified by the given
        /// <paramref name="matcher"/>.
        /// </summary>
        /// <param name="type">The type from which to retrieve the operator.</param>
        /// <param name="matcher">An action specifying the type of implicit operator to retrieve.</param>
        /// <returns>
        /// The <paramref name="type" />'s implicit operator of the type specified by the given
        /// <paramref name="matcher"/>, or null if none exists.
        /// </returns>
        public static MethodInfo GetImplicitOperator(this Type type, Action <OperatorSelector> matcher)
        {
            var selector = new OperatorSelector();

            matcher?.Invoke(selector);

            return(type.GetImplicitOperators().FirstOrDefault(selector.Matches));
        }
        /// <summary>
        /// Gets the <paramref name="type" />'s implicit and explicit operators, optionally of the type
        /// specified by the given <paramref name="matcher"/>.
        /// </summary>
        /// <param name="type">The type from which to retrieve the operators.</param>
        /// <param name="matcher">An action specifying the type of implicit operator to retrieve.</param>
        /// <returns>The <paramref name="type" />'s implicit and explicit operators.</returns>
        public static IEnumerable <MethodInfo> GetOperators(this Type type, Action <OperatorSelector> matcher = null)
        {
            var operators = type
                            .GetPublicStaticMembers()
                            .Filter(m => (m.Name == ImplicitOperatorName) || (m.Name == ExplicitOperatorName))
                            .OfType <MethodInfo>();

            if (matcher == null)
            {
                return(operators);
            }

            var selector = new OperatorSelector();

            matcher.Invoke(selector);

            return(operators.Filter(selector.Matches));
        }
Пример #7
0
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();

            // Open document
            Document pdfDocument = new Document(dataDir + "RemoveAllText.pdf");

            // Loop through all pages of PDF Document
            for (int i = 1; i <= pdfDocument.Pages.Count; i++)
            {
                Page             page             = pdfDocument.Pages[i];
                OperatorSelector operatorSelector = new OperatorSelector(new Aspose.Pdf.Operators.TextShowOperator());
                // Select all text on the page
                page.Contents.Accept(operatorSelector);
                // Delete all text
                page.Contents.Delete(operatorSelector.Selected);
            }
            // Save the document
            pdfDocument.Save(dataDir + "RemoveAllText_out.pdf", Aspose.Pdf.SaveFormat.Pdf);
            // ExEnd:1
        }