Пример #1
0
 public static void Graph2(Page pdfPage)
 {
     int alpha = 10;
     int green = 0;
     int red = 100;
     int blue = 0;
     // Create Color object using Alpha RGB 
     Aspose.Pdf.Color alphaColor = Aspose.Pdf.Color.FromArgb(alpha, red, green, blue); // Provide alpha channel
                                                                                       // Instantiate Document object
     // Create Graph object with certain dimensions
     Aspose.Pdf.Drawing.Graph graph = new Aspose.Pdf.Drawing.Graph(300, 400);
     // Set border for Drawing object
     graph.Border = (new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, Aspose.Pdf.Color.Black));
     // Add graph object to paragraphs collection of Page instance
     pdfPage.Paragraphs.Add(graph);
     // Create Rectangle object with certain dimensions
     Aspose.Pdf.Drawing.Rectangle rectangle = new Aspose.Pdf.Drawing.Rectangle(0, 0, 100, 50);
     // Create graphInfo object for Rectangle instance
     Aspose.Pdf.GraphInfo graphInfo = rectangle.GraphInfo;
     // Set color information for GraphInfo instance
     graphInfo.Color = (Aspose.Pdf.Color.Red);
     // Set fill color for GraphInfo
     graphInfo.FillColor = (alphaColor);
     // Add rectangle shape to shapes collection of graph object
     graph.Shapes.Add(rectangle);
 }
Пример #2
0
        public static void CustomLineStyleForFootNote()
        {
            // ExStart:CustomLineStyleForFootNote
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();

            // Create Document instance
            Document doc = new Document();
            // Add page to pages collection of PDF
            Page page = doc.Pages.Add();

            // Create GraphInfo object
            Aspose.Pdf.GraphInfo graph = new Aspose.Pdf.GraphInfo();
            // Set line width as 2
            graph.LineWidth = 2;
            // Set the color for graph object
            graph.Color = Aspose.Pdf.Color.Red;
            // Set dash array value as 3
            graph.DashArray = new int[] { 3 };
            // Set dash phase value as 1
            graph.DashPhase = 1;
            // Set footnote line style for page as graph
            page.NoteLineStyle = graph;
            // Create TextFragment instance
            TextFragment text = new TextFragment("Hello World");

            // Set FootNote value for TextFragment
            text.FootNote = new Note("foot note for test text 1");
            // Add TextFragment to paragraphs collection of first page of document
            page.Paragraphs.Add(text);
            // Create second TextFragment
            text = new TextFragment("Aspose.Pdf for .NET");
            // Set FootNote for second text fragment
            text.FootNote = new Note("foot note for test text 2");
            // Add second text fragment to paragraphs collection of PDF file
            page.Paragraphs.Add(text);

            dataDir = dataDir + "CustomLineStyleForFootNote_out.pdf";

            // Save resulting PDF document.
            doc.Save(dataDir);
            // ExEnd:CustomLineStyleForFootNote
            Console.WriteLine("\nCustom line style defined successfully.\nFile saved at " + dataDir);
        }
        public static void CustomLineStyleForFootNote()
        {
            // ExStart:CustomLineStyleForFootNote
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();

            // Create Document instance
            Document doc = new Document();
            // Add page to pages collection of PDF
            Page page = doc.Pages.Add();
            // Create GraphInfo object
            Aspose.Pdf.GraphInfo graph = new Aspose.Pdf.GraphInfo();
            // Set line width as 2
            graph.LineWidth = 2;
            // Set the color for graph object
            graph.Color = Aspose.Pdf.Color.Red;
            // Set dash array value as 3
            graph.DashArray = new int[] { 3 };
            // Set dash phase value as 1
            graph.DashPhase = 1;
            // Set footnote line style for page as graph
            page.NoteLineStyle = graph;
            // Create TextFragment instance
            TextFragment text = new TextFragment("Hello World");
            // Set FootNote value for TextFragment
            text.FootNote = new Note("foot note for test text 1");
            // Add TextFragment to paragraphs collection of first page of document
            page.Paragraphs.Add(text);
            // Create second TextFragment
            text = new TextFragment("Aspose.Pdf for .NET");
            // Set FootNote for second text fragment
            text.FootNote = new Note("foot note for test text 2");
            // Add second text fragment to paragraphs collection of PDF file
            page.Paragraphs.Add(text);

            dataDir = dataDir + "CustomLineStyleForFootNote_out.pdf";

            // Save resulting PDF document.
            doc.Save(dataDir);
            // ExEnd:CustomLineStyleForFootNote
            Console.WriteLine("\nCustom line style defined successfully.\nFile saved at " + dataDir);
        }
Пример #4
0
        public static void Run()
        {
            // ExStart:AddDrawing
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Graphs();

            int alpha = 10;
            int green = 0;
            int red   = 100;
            int blue  = 0;

            // Create Color object using Alpha RGB
            Aspose.Pdf.Color alphaColor = Aspose.Pdf.Color.FromArgb(alpha, red, green, blue); // provide alpha channel
            // Instantiate Document object
            Document document = new Document();
            // Add page to pages collection of PDF file
            Page page = document.Pages.Add();

            // Create Graph object with certain dimensions
            Aspose.Pdf.Drawing.Graph graph = new Aspose.Pdf.Drawing.Graph(300, 400);
            // Set border for Drawing object
            graph.Border = (new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, Aspose.Pdf.Color.Black));
            // Add graph object to paragraphs collection of Page instance
            page.Paragraphs.Add(graph);
            // Create Rectangle object with certain dimensions
            Aspose.Pdf.Drawing.Rectangle rectangle = new Aspose.Pdf.Drawing.Rectangle(0, 0, 100, 50);
            // Create graphInfo object for Rectangle instance
            Aspose.Pdf.GraphInfo graphInfo = rectangle.GraphInfo;
            // Set color information for GraphInfo instance
            graphInfo.Color = (Aspose.Pdf.Color.Red);
            // Set fill color for GraphInfo
            graphInfo.FillColor = (alphaColor);
            // Add rectangle shape to shapes collection of graph object
            graph.Shapes.Add(rectangle);
            dataDir = dataDir + "AddDrawing_out_.pdf";
            // Save PDF file
            document.Save(dataDir);
            // ExEnd:AddDrawing
            Console.WriteLine("\nDrawing added successfully with transparent color.\nFile saved at " + dataDir);
        }
Пример #5
0
        public void EditPdfFile(List<ProblematicLanguage> database)
        {
            //Console.WriteLine("inside pdf function!");

            int wordCount = 0;
            // Open the PDF file
            Document pdfDoc = new Document(FilePath);
            TextSearchOptions textSearchOptions = new TextSearchOptions(true);
            //DocumentBuilder builder = new DocumentBuilder(pdfDoc);
            TextFragmentCollection textFragmentCollection;

            // Add page to pages collection of PDF
            Page page = pdfDoc.Pages.Add();
            // Create GraphInfo object
            Aspose.Pdf.GraphInfo graph = new Aspose.Pdf.GraphInfo();
            // Set line width as 2
            graph.LineWidth = 2;
            // Set the color for graph object
            graph.Color = Aspose.Pdf.Color.Black;
            // Set dash array value as 3
            graph.DashArray = new int[] { 3 };
            // Set dash phase value as 1
            graph.DashPhase = 1;
            // Set footnote line style for page as graph
            page.NoteLineStyle = graph;


            foreach (var dbEntry in database)
            {
                foreach (string category in Categories)
                {
                    if (dbEntry.Category == category)
                    {
                        //String find = "(?i)\b"+dbEntry.ProblemPhrase+"\b"; 
                        TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("(?i)\b" + dbEntry.ProblemPhrase + "\b");
                        //TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("(?i)cakewalk", new TextSearchOptions(true));
                        pdfDoc.Pages.Accept(textFragmentAbsorber);
                        textFragmentCollection = textFragmentAbsorber.TextFragments;


                        foreach (TextFragment textFragment in textFragmentCollection)
                        {
                            wordCount++;
                            if (category == "Anti-Black")
                                textFragment.TextState.BackgroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Yellow);
                            if (category == "Anti-Indigenous")
                                textFragment.TextState.BackgroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Magenta);

                            textFragment.FootNote = new Aspose.Pdf.Note(dbEntry.ProblemPhrase + ": " + dbEntry.Resources + "  Read more about this here: " + dbEntry.Link);
                            // Add TextFragment to paragraphs collection of first page of document
                            page.Paragraphs.Add(textFragment);
                        }
                    }
                }
            }

            string ext3 = FilePath.Substring(0, FilePath.LastIndexOf("."));
            string newFilePath = (ext3 + "UPDATED.pdf");
            pdfDoc.Save(newFilePath);

            if (wordCount > 0)
                Console.WriteLine("\nFound {0} problematic terms.", wordCount);

            else
                Console.WriteLine("\nNo problematic terms were found.");

            Console.WriteLine("See new file:\n\n          {0}", newFilePath);
            Console.WriteLine("(Press any key to return to main menu)");
            Console.ReadKey();
        }