Example #1
0
        public static void Run()
        {
            // ExStart:CreateFilledRectangle
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Graphs();

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

            // Create Graph instance
            Aspose.Pdf.Drawing.Graph graph = new Aspose.Pdf.Drawing.Graph(100, 400);
            // Add graph object to paragraphs collection of page instance
            page.Paragraphs.Add(graph);
            // Create Rectangle instance
            Aspose.Pdf.Drawing.Rectangle rect = new Aspose.Pdf.Drawing.Rectangle(100, 100, 200, 120);
            // Specify fill color for Graph object
            rect.GraphInfo.FillColor = Aspose.Pdf.Color.Red;
            // Add rectangle object to shapes collection of Graph object
            graph.Shapes.Add(rect);
            dataDir = dataDir + "CreateFilledRectangle_out.pdf";
            // Save PDF file
            doc.Save(dataDir);
            // ExEnd:CreateFilledRectangle
            Console.WriteLine("\nFilled rectangle object created successfully.\nFile saved at " + dataDir);
        }
Example #2
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);
 }
        public static void Run()
        {
            // ExStart:CreateRectangleWithAlphaColor
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Graphs();

            // Instantiate Document instance
            Document doc = new Document();

            // Add page to pages collection of PDF file
            Aspose.Pdf.Page page = doc.Pages.Add();
            // Create Graph instance
            Aspose.Pdf.Drawing.Graph canvas = new Aspose.Pdf.Drawing.Graph(100, 400);
            // Create rectangle object with specific dimensions
            Aspose.Pdf.Drawing.Rectangle rect = new Aspose.Pdf.Drawing.Rectangle(100, 100, 200, 100);
            // Set graph fill color from System.Drawing.Color structure from a 32-bit ARGB value
            rect.GraphInfo.FillColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.FromArgb(128, System.Drawing.Color.FromArgb(12957183)));
            // Add rectangle object to shapes collection of Graph instance
            canvas.Shapes.Add(rect);

            // Create second rectangle object
            Aspose.Pdf.Drawing.Rectangle rect1 = new Aspose.Pdf.Drawing.Rectangle(200, 150, 200, 100);
            rect1.GraphInfo.FillColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.FromArgb(128, System.Drawing.Color.FromArgb(16118015)));
            canvas.Shapes.Add(rect1);
            // Add graph instance to paragraph collection of page object
            page.Paragraphs.Add(canvas);

            dataDir = dataDir + "CreateRectangleWithAlphaColor_out_.pdf";
            // Save PDF file
            doc.Save(dataDir);
            // ExEnd:CreateRectangleWithAlphaColor
            Console.WriteLine("\nRectangle object created successfully with alpha color.\nFile saved at " + dataDir);
        }
Example #4
0
        public static void Graph4(Page pdfPage)
        {
            //pdfPage.PageInfo.Margin.Left = pdfPage.PageInfo.Margin.Right = pdfPage.PageInfo.Margin.Bottom = pdfPage.PageInfo.Margin.Top = 0;
            pdfPage.PageInfo.Margin.Left = pdfPage.PageInfo.Margin.Right = pdfPage.PageInfo.Margin.Bottom = pdfPage.PageInfo.Margin.Top = 20;

            // Create Graph instance
            Aspose.Pdf.Drawing.Graph graph = new Aspose.Pdf.Drawing.Graph(200, 400);
            
            // Add graph object to paragraphs collection of page instance
            pdfPage.Paragraphs.Add(graph);

            // Create Rectangle instance
            //Aspose.Pdf.Drawing.Rectangle rect = new Aspose.Pdf.Drawing.Rectangle(100, 100, 200, 120);
            //Aspose.Pdf.Drawing.Rectangle rect = new Aspose.Pdf.Drawing.Rectangle(0, 0, 200, 400);
            Aspose.Pdf.Drawing.Rectangle rect1 = new Aspose.Pdf.Drawing.Rectangle(0, 0, 200, 400);
            Aspose.Pdf.Drawing.Rectangle rect2 = new Aspose.Pdf.Drawing.Rectangle(100, 0, 100, 200);

            // Specify fill color for Graph object
            rect1.GraphInfo.FillColor = Aspose.Pdf.Color.Blue;
            rect2.GraphInfo.FillColor = Aspose.Pdf.Color.Red;

            // Add rectangle object to shapes collection of Graph object
            graph.Shapes.Add(rect1);
            graph.Shapes.Add(rect2);
        }
        public static void Run()
        {
            // ExStart:CreateFilledRectangle
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Graphs();

            // Create Document instance
            Document doc = new Document();
            // Add page to pages collection of PDF file
            Page page = doc.Pages.Add();
            // Create Graph instance
            Aspose.Pdf.Drawing.Graph graph = new Aspose.Pdf.Drawing.Graph(100, 400);
            // Add graph object to paragraphs collection of page instance
            page.Paragraphs.Add(graph);
            // Create Rectangle instance
            Aspose.Pdf.Drawing.Rectangle rect = new Aspose.Pdf.Drawing.Rectangle(100, 100, 200, 120);
            // Specify fill color for Graph object
            rect.GraphInfo.FillColor = Aspose.Pdf.Color.Red;
            // Add rectangle object to shapes collection of Graph object
            graph.Shapes.Add(rect);
            dataDir = dataDir + "CreateFilledRectangle_out.pdf";
            // Save PDF file
            doc.Save(dataDir);
            // ExEnd:CreateFilledRectangle
            Console.WriteLine("\nFilled rectangle object created successfully.\nFile saved at " + dataDir);            
        }
        public static void Run()
        {
            // ExStart:CreateRectangleWithAlphaColor
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Graphs();

            // Instantiate Document instance
            Document doc = new Document();
            // Add page to pages collection of PDF file
            Aspose.Pdf.Page page = doc.Pages.Add();
            // Create Graph instance
            Aspose.Pdf.Drawing.Graph canvas = new Aspose.Pdf.Drawing.Graph(100, 400);
            // Create rectangle object with specific dimensions
            Aspose.Pdf.Drawing.Rectangle rect = new Aspose.Pdf.Drawing.Rectangle(100, 100, 200, 100);
            // Set graph fill color from System.Drawing.Color structure from a 32-bit ARGB value
            rect.GraphInfo.FillColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.FromArgb(128, System.Drawing.Color.FromArgb(12957183)));
            // Add rectangle object to shapes collection of Graph instance
            canvas.Shapes.Add(rect);

            // Create second rectangle object
            Aspose.Pdf.Drawing.Rectangle rect1 = new Aspose.Pdf.Drawing.Rectangle(200, 150, 200, 100);
            rect1.GraphInfo.FillColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.FromArgb(128, System.Drawing.Color.FromArgb(16118015)));
            canvas.Shapes.Add(rect1);
            // Add graph instance to paragraph collection of page object
            page.Paragraphs.Add(canvas);

            dataDir = dataDir + "CreateRectangleWithAlphaColor_out.pdf";
            // Save PDF file
            doc.Save(dataDir);
            // ExEnd:CreateRectangleWithAlphaColor
            Console.WriteLine("\nRectangle object created successfully with alpha color.\nFile saved at " + dataDir);            
        }
Example #7
0
        private void debug_createP(string fileFullName)
        {
            Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document();
            Aspose.Pdf.Page     pdfPage     = (Aspose.Pdf.Page)pdfDocument.Pages.Add();

            Console.WriteLine("pdfPage.Rect = " + pdfPage.Rect);
            Console.WriteLine("pdfPage.PageInfo: Width - Height - PureHeight = " + pdfPage.PageInfo.Width + " - " + pdfPage.PageInfo.Height + " - " + pdfPage.PageInfo.PureHeight);
            Console.WriteLine("pdfPage.PageInfo: Margin.Top - Right - Bottom - Left = " + pdfPage.PageInfo.Margin.Top + " - " + pdfPage.PageInfo.Margin.Right + " - " + pdfPage.PageInfo.Margin.Bottom + " - " + pdfPage.PageInfo.Margin.Left);

            TextParagraph paragraph = new TextParagraph();

            // append string lines
            paragraph.AppendLine("the quick brown fox jumps over the lazy dog");
            paragraph.AppendLine("line2");
            paragraph.AppendLine("line3");


            Console.WriteLine("paragraph.Rectangle = " + paragraph.Rectangle);
            Console.WriteLine("paragraph.TextRectangle = " + paragraph.TextRectangle);



            // Create Graph instance
            Aspose.Pdf.Drawing.Graph graph = new Aspose.Pdf.Drawing.Graph((float)pdfPage.Rect.Width, (float)pdfPage.Rect.Height);
            // Add graph object to paragraphs collection of page instance
            pdfPage.Paragraphs.Add(graph);
            // Create Rectangle instance
            //Aspose.Pdf.Drawing.Rectangle rect = new Aspose.Pdf.Drawing.Rectangle(100, 100, 200, 120);

            Aspose.Pdf.Drawing.Rectangle rect = new Aspose.Pdf.Drawing.Rectangle((float)paragraph.Rectangle.LLX, (float)paragraph.Rectangle.LLY, (float)paragraph.Rectangle.Width, (float)paragraph.Rectangle.Height);
            //Aspose.Pdf.Drawing.Rectangle rect = new Aspose.Pdf.Drawing.Rectangle((float)paragraph.TextRectangle.LLX, (float)paragraph.TextRectangle.LLY, (float)paragraph.TextRectangle.Width, (float)paragraph.TextRectangle.Height);

            // Specify fill color for Graph object

            //rect.GraphInfo.FillColor = Aspose.Pdf.Color.Red;
            rect.GraphInfo.LineWidth = 2;
            rect.GraphInfo.Color     = Aspose.Pdf.Color.Brown;

            // Add rectangle object to shapes collection of Graph object
            graph.Shapes.Add(rect);



            TextBuilder textBuilder = new TextBuilder(pdfPage);

            textBuilder.AppendParagraph(paragraph);


            pdfDocument.Save(fileFullName);
        }
Example #8
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);
        }
        public static void Run()
        {
            // ExStart:AddTransparentText
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();

            // Create Document instance
            Document doc = new Document();

            // Create page to pages collection of PDF file
            Aspose.Pdf.Page page = doc.Pages.Add();

            // Create Graph object
            Aspose.Pdf.Drawing.Graph canvas = new Aspose.Pdf.Drawing.Graph(100, 400);
            // Create rectangle instance with certain dimensions
            Aspose.Pdf.Drawing.Rectangle rect = new Aspose.Pdf.Drawing.Rectangle(100, 100, 400, 400);
            // Create color object from Alpha color channel
            rect.GraphInfo.FillColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.FromArgb(128, System.Drawing.Color.FromArgb(12957183)));
            // Add rectanlge to shapes collection of Graph object
            canvas.Shapes.Add(rect);
            // Add graph object to paragraphs collection of page object
            page.Paragraphs.Add(canvas);
            // Set value to not change position for graph object
            canvas.IsChangePosition = false;

            // Create TextFragment instance with sample value
            TextFragment text = new TextFragment("transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text ");

            // Create color object from Alpha channel
            Aspose.Pdf.Color color = Aspose.Pdf.Color.FromArgb(30, 0, 255, 0);
            // Set color information for text instance
            text.TextState.ForegroundColor = color;
            // Add text to paragraphs collection of page instance
            page.Paragraphs.Add(text);

            dataDir = dataDir + "AddTransparentText_out.pdf";
            doc.Save(dataDir);
            // ExEnd:AddTransparentText
            Console.WriteLine("\nTransparent text added successfully.\nFile saved at " + dataDir);
        }
        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);            
        }
        public static void Run()
        {
            // ExStart:AddTransparentText
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();

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

            // Create Graph object 
            Aspose.Pdf.Drawing.Graph canvas = new Aspose.Pdf.Drawing.Graph(100, 400);
            // Create rectangle instance with certain dimensions
            Aspose.Pdf.Drawing.Rectangle rect = new Aspose.Pdf.Drawing.Rectangle(100, 100, 400, 400);
            // Create color object from Alpha color channel
            rect.GraphInfo.FillColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.FromArgb(128, System.Drawing.Color.FromArgb(12957183)));
            // Add rectanlge to shapes collection of Graph object
            canvas.Shapes.Add(rect);
            // Add graph object to paragraphs collection of page object
            page.Paragraphs.Add(canvas);
            // Set value to not change position for graph object
            canvas.IsChangePosition = false;

            // Create TextFragment instance with sample value
            TextFragment text = new TextFragment("transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text ");
            // Create color object from Alpha channel
            Aspose.Pdf.Color color = Aspose.Pdf.Color.FromArgb(30, 0, 255, 0);
            // Set color information for text instance
            text.TextState.ForegroundColor = color;
            // Add text to paragraphs collection of page instance
            page.Paragraphs.Add(text);

            dataDir = dataDir + "AddTransparentText_out.pdf";
            doc.Save(dataDir);
            // ExEnd:AddTransparentText            
            Console.WriteLine("\nTransparent text added successfully.\nFile saved at " + dataDir);
        }
Example #12
0
 // ExStart:AddRectangle
 private static void AddRectangle(Aspose.Pdf.Page page, float x, float y, float width, float height, Aspose.Pdf.Color color, int zindex)
 {
     // create graph object with dimensions same as specified for Rectangle object
     Aspose.Pdf.Drawing.Graph graph = new Aspose.Pdf.Drawing.Graph(width, height);
     // can we change the position of graph instance
     graph.IsChangePosition = false;
     // set Left coordinate position for Graph instance
     graph.Left = x;
     // set Top coordinate position for Graph object
     graph.Top = y;
     // Add a rectangle inside the "graph"
     Aspose.Pdf.Drawing.Rectangle rect = new Aspose.Pdf.Drawing.Rectangle(0, 0, width, height);
     // set rectangle fill color
     rect.GraphInfo.FillColor = color;
     // color of graph object
     rect.GraphInfo.Color = color;
     // add rectangle to shapes collection of graph instance
     graph.Shapes.Add(rect);
     // set Z-Index for rectangle object
     graph.ZIndex = zindex;
     // add graph to paragraphs collection of page object
     page.Paragraphs.Add(graph);
 }
 // ExStart:AddRectangle
 private static void AddRectangle(Aspose.Pdf.Page page, float x, float y, float width, float height, Aspose.Pdf.Color color, int zindex)
 {
     // Create graph object with dimensions same as specified for Rectangle object
     Aspose.Pdf.Drawing.Graph graph = new Aspose.Pdf.Drawing.Graph(width, height);
     // Can we change the position of graph instance
     graph.IsChangePosition = false;
     // Set Left coordinate position for Graph instance
     graph.Left = x;
     // Set Top coordinate position for Graph object
     graph.Top = y;
     // Add a rectangle inside the "graph"
     Aspose.Pdf.Drawing.Rectangle rect = new Aspose.Pdf.Drawing.Rectangle(0, 0, width, height);
     // Set rectangle fill color
     rect.GraphInfo.FillColor = color;
     // Color of graph object
     rect.GraphInfo.Color = color;
     // Add rectangle to shapes collection of graph instance
     graph.Shapes.Add(rect);
     // Set Z-Index for rectangle object
     graph.ZIndex = zindex;
     // Add graph to paragraphs collection of page object
     page.Paragraphs.Add(graph);
 }