public static void Run()
        {
            try
            {
                // ExStart:ChangeStampPosition
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();

                // Instantiate PdfContentEditor Object
                PdfContentEditor pdfContentEditor = new PdfContentEditor();

                // Bind input PDF file
                pdfContentEditor.BindPdf(dataDir + "ChangeStampPosition.pdf");

                int pageId = 1;
                int stampIndex = 1;
                double x = 200;
                double y = 200;

                // Change the position of the stamp to new x and y position
                pdfContentEditor.MoveStamp(pageId, stampIndex, x, y);

                // Save the Pdf file
                pdfContentEditor.Save(dataDir + "ChangeStampPosition_out.pdf");
                // ExEnd:ChangeStampPosition
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            
        }
 public static void Main()
 {
     // The path to the documents directory.
     string dataDir = Path.GetFullPath("../../../Data/");
     //open input PDF
     PdfContentEditor pdfContentEditor = new PdfContentEditor();
     pdfContentEditor.BindPdf(dataDir+ "input.pdf");
     //replace text on all pages
     pdfContentEditor.ReplaceText("Hello", 1, "World");
     //save output PDF
     pdfContentEditor.Save(dataDir+ "ReplaceText.pdf");
 }
 public static void Main()
 {
     // The path to the documents directory.
     string dataDir = Path.GetFullPath("../../../Data/");
     //open input PDF
     PdfContentEditor pdfContentEditor = new PdfContentEditor();
     pdfContentEditor.BindPdf(dataDir+ "input.pdf");
     //replace image on a particular page
     pdfContentEditor.ReplaceImage(1, 1, dataDir+ "aspose-logo.jpg");
     //save output PDF
     pdfContentEditor.Save(dataDir+ "output.pdf");
 }
 public static void Run()
 {
     // The path to the documents directory.
     string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Text();
     //open input PDF
     PdfContentEditor pdfContentEditor = new PdfContentEditor();
     pdfContentEditor.BindPdf(dataDir+ "input1.pdf");
     //replace text on all pages
     pdfContentEditor.ReplaceText("Hello", "World");
     //save output PDF
     pdfContentEditor.Save(dataDir+ "ReplaceTextOnAllPages.pdf");
     
 }
 public static void Run()
 {
     // The path to the documents directory.
     string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();
     //open input PDF
     PdfContentEditor pdfContentEditor = new PdfContentEditor();
     pdfContentEditor.BindPdf(dataDir+ "ReplaceImage.pdf");
     //replace image on a particular page
     pdfContentEditor.ReplaceImage(1, 1, dataDir+ "aspose-logo.jpg");
     //save output PDF
     pdfContentEditor.Save(dataDir+ "ReplaceImage_out.pdf");
     
     
 }
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");
            //open document
            PdfContentEditor contentEditor = new PdfContentEditor();
            contentEditor.BindPdf(dataDir+ "input.pdf");

            //delete attachments
            contentEditor.DeleteAttachments();

            //save updated PDF
            contentEditor.Save(dataDir+ "output.pdf");
        }
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            // instantiate PdfContentEditor object
            PdfContentEditor editor = new PdfContentEditor();
            // bind input PDF file
            editor.BindPdf(dataDir+ "input.pdf");
            // the last argumnet is for transparency of icon
            editor.CreateFileAttachment(new System.Drawing.Rectangle(50, 50, 10, 10), "here", "simple.doc", 1, "Paperclip", 0.005);
            // save the updated PDF file
            editor.Save(dataDir+ "PdfWith_Transparent_Annotation.pdf");
        }
 public static void Main()
 {
     // The path to the documents directory.
     string dataDir = Path.GetFullPath("../../../Data/");
     //open document
     PdfContentEditor contentEditor = new PdfContentEditor();
     contentEditor.BindPdf(dataDir+ "input.pdf");
     //crate rectangle
     System.Drawing.Rectangle rect = new System.Drawing.Rectangle(50, 50, 100, 100);
     //create annotation
     contentEditor.CreateFreeText(rect, "Sample content", 1);
     //save updated PDF file
     contentEditor.Save(dataDir+ "output.pdf");
 }
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");
            //open document
            PdfContentEditor contentEditor = new PdfContentEditor();
            contentEditor.BindPdf(dataDir+ "input.pdf");

            //add attachment
            contentEditor.AddDocumentAttachment(dataDir+ "test.txt", "Attachment Description");

            //save updated PDF
            contentEditor.Save(dataDir+ "output.pdf");
        }
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");
            //open PDF file
            PdfContentEditor contentEditor = new PdfContentEditor();
            contentEditor.BindPdf(dataDir+ "input.pdf");

            //delete the images from the particular page
            contentEditor.DeleteImage();

            //save output PDF
            contentEditor.Save(dataDir+ "output.pdf");
        }
 public static void Run()
 {
     // ExStart:ReplaceText
     // The path to the documents directory.
     string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Text();
     // Open input PDF
     PdfContentEditor pdfContentEditor = new PdfContentEditor();
     pdfContentEditor.BindPdf(dataDir + "ReplaceText.pdf");
     // Replace text on all pages
     pdfContentEditor.ReplaceText("Hello", "World");
     // Save output PDF
     pdfContentEditor.Save(dataDir + "ReplaceText_out.pdf");
     // ExEnd:ReplaceText
 }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Attachments();
            //open document
            PdfContentEditor contentEditor = new PdfContentEditor();
            contentEditor.BindPdf(dataDir+ "AddAttachment.pdf");

            //add attachment
            contentEditor.AddDocumentAttachment(dataDir+ "test.txt", "Attachment Description");

            //save updated PDF
            contentEditor.Save(dataDir+ "AddAttachment_out.pdf");
            
        }
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");
            //open document
            PdfContentEditor contentEditor = new PdfContentEditor();
            contentEditor.BindPdf(dataDir+ "input.pdf");

            //change Viewer Preferences
            contentEditor.ChangeViewerPreference(ViewerPreference.CenterWindow);
            contentEditor.ChangeViewerPreference(ViewerPreference.HideMenubar);
            contentEditor.ChangeViewerPreference(ViewerPreference.PageModeUseNone);

            //save output PDF file
            contentEditor.Save(dataDir+ "output.pdf");
        }
        public static void Run()
        {
            // ExStart:DeleteAllAttachments
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Attachments();
            // Open document
            PdfContentEditor contentEditor = new PdfContentEditor();
            contentEditor.BindPdf(dataDir+ "DeleteAllAttachments.pdf");

            // Delete attachments
            contentEditor.DeleteAttachments();

            // Save updated PDF
            contentEditor.Save(dataDir+ "DeleteAllAttachments_out.pdf");
            // ExEnd:DeleteAllAttachments            
        }
 public static void Run()
 {
     // The path to the documents directory.
     string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Annotations();
     //open document
     PdfContentEditor contentEditor = new PdfContentEditor();
     contentEditor.BindPdf(dataDir+ "AddFreeTextAnnotation.pdf");
     //crate rectangle
     System.Drawing.Rectangle rect = new System.Drawing.Rectangle(50, 50, 100, 100);
     //create annotation
     contentEditor.CreateFreeText(rect, "Sample content", 1);
     //save updated PDF file
     contentEditor.Save(dataDir+ "AddFreeTextAnnotation_out.pdf");
     
     
 }
        public static void Run()
        {
            // ExStart:CreateFileAnnotation
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Annotations();

            // Instantiate PdfContentEditor object
            PdfContentEditor editor = new PdfContentEditor();
            // Bind input PDF file
            editor.BindPdf(dataDir+ "CreateFileAnnotation.pdf");
            // The last argumnet is for transparency of icon
            editor.CreateFileAttachment(new System.Drawing.Rectangle(50, 50, 10, 10), "here", dataDir + "AddFreeTextAnnotation.pdf", 1, "Paperclip", 0.005);
            // Save the updated PDF file
            editor.Save(dataDir+ "PdfWith_Transparent_Annotation_out.pdf");
            // ExEnd:CreateFileAnnotation
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();
            //open PDF file
            PdfContentEditor contentEditor = new PdfContentEditor();
            contentEditor.BindPdf(dataDir+ "DeleteAllImages.pdf");

            //delete the images from the particular page
            contentEditor.DeleteImage();

            //save output PDF
            contentEditor.Save(dataDir+ "DeleteAllImages_out.pdf");
 
            
        }
        public static void Run()
        {
            // ExStart:SetViewerPreference
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_WorkingDocuments();
            // Open document
            PdfContentEditor contentEditor = new PdfContentEditor();
            contentEditor.BindPdf(dataDir + "SetViewerPreference.pdf");

            // Change Viewer Preferences
            contentEditor.ChangeViewerPreference(ViewerPreference.CenterWindow);
            contentEditor.ChangeViewerPreference(ViewerPreference.HideMenubar);
            contentEditor.ChangeViewerPreference(ViewerPreference.PageModeUseNone);

            // Save output PDF file
            contentEditor.Save(dataDir+ "SetViewerPreference_out.pdf");
            // ExEnd:SetViewerPreference            
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Attachments();
            //open document
            PdfContentEditor contentEditor = new PdfContentEditor();
            contentEditor.BindPdf(dataDir+ "AddAttachment-Stream.pdf");

            //read file into stream (FileStream or MemoryStream)
            FileStream fileStream = new FileStream(dataDir+ "test.txt", FileMode.Open);
            //add attachment
            contentEditor.AddDocumentAttachment(fileStream, "Attachment Name", "Attachment Description");

            //save updated PDF
            contentEditor.Save(dataDir+ "AddAttachment-Stream_out.pdf");
            
            
        }
        public static void Run()
        {
            // ExStart:CreateAppLinkWithColor
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_LinksActions();

            // Open document
            PdfContentEditor contentEditor = new PdfContentEditor();
            contentEditor.BindPdf(dataDir + "CreateApplicationLink.pdf");

            System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(100, 100, 200, 200);

            // Create application link
            contentEditor.CreateApplicationLink(rectangle,  dataDir + "test.txt", 1, System.Drawing.Color.Red);

            // Save updated PDF
            contentEditor.Save( dataDir + "CreateAppLinkWithColor_out.pdf");
            // ExEnd:CreateAppLinkWithColor                                 
        }
        public static void Run()
        {
            // ExStart:SetViewerPreference
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_WorkingDocuments();
            // Open document
            PdfContentEditor contentEditor = new PdfContentEditor();

            contentEditor.BindPdf(dataDir + "SetViewerPreference.pdf");

            // Change Viewer Preferences
            contentEditor.ChangeViewerPreference(ViewerPreference.CenterWindow);
            contentEditor.ChangeViewerPreference(ViewerPreference.HideMenubar);
            contentEditor.ChangeViewerPreference(ViewerPreference.PageModeUseNone);

            // Save output PDF file
            contentEditor.Save(dataDir + "SetViewerPreference_out.pdf");
            // ExEnd:SetViewerPreference
        }
        public static void Run()
        {
            // ExStart:RemoveAction
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_LinksActions();
           
            // Open document
            PdfContentEditor contentEditor = new PdfContentEditor();
            contentEditor.BindPdf(dataDir + "RemoveOpenAction.pdf");

            System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(100, 100, 200, 200);

            // Create application link
            contentEditor.RemoveDocumentOpenAction();

            // Save updated PDF
            contentEditor.Save( dataDir + "RemoveOpenAction_out.pdf");
            // ExEnd:RemoveAction                        
        }
        public static void Run()
        {
            // ExStart:CreateJSLink
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_LinksActions();
          
            // Open document
            PdfContentEditor contentEditor = new PdfContentEditor();
            contentEditor.BindPdf( dataDir + "CreateApplicationLink.pdf");

            System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(100, 100, 200, 200);

            // Create application link
            contentEditor.CreateJavaScriptLink("app.alert('Welcome to Aspose!');", rectangle, 1,  System.Drawing.Color.Red);

            // Save updated PDF
            contentEditor.Save( dataDir + "CreateJSLink_out.pdf");
            // ExEnd:CreateJSLink                                 
        }
Exemple #24
0
        public static void Run()
        {
            // ExStart:SearchTextAndAddHyperlink
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();
            // Create absorber object to find all instances of the input search phrase
            TextFragmentAbsorber absorber = new TextFragmentAbsorber("\\d{4}-\\d{4}");

            // Enable regular expression search
            absorber.TextSearchOptions = new TextSearchOptions(true);
            // Open document
            PdfContentEditor editor = new PdfContentEditor();

            // Bind source PDF file
            editor.BindPdf(dataDir + "SearchRegularExpressionPage.pdf");
            // Accept the absorber for the page
            editor.Document.Pages[1].Accept(absorber);

            int[]                dashArray = { };
            String[]             LEArray   = { };
            System.Drawing.Color blue      = System.Drawing.Color.Blue;

            // Loop through the fragments
            foreach (TextFragment textFragment in absorber.TextFragments)
            {
                textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.Blue;
                System.Drawing.Rectangle rect = new System.Drawing.Rectangle((int)textFragment.Rectangle.LLX,
                                                                             (int)Math.Round(textFragment.Rectangle.LLY), (int)Math.Round(textFragment.Rectangle.Width + 2),
                                                                             (int)Math.Round(textFragment.Rectangle.Height + 1));
                Enum[] actionName = new Enum[2] {
                    Aspose.Pdf.Annotations.PredefinedAction.Document_AttachFile, Aspose.Pdf.Annotations.PredefinedAction.Document_ExtractPages
                };
                editor.CreateWebLink(rect, "http://www.aspose.com", 1, blue, actionName);
                editor.CreateLine(rect, "", (float)textFragment.Rectangle.LLX + 1, (float)textFragment.Rectangle.LLY - 1,
                                  (float)textFragment.Rectangle.URX, (float)textFragment.Rectangle.LLY - 1, 1, 1, blue, "S", dashArray, LEArray);
            }

            dataDir = dataDir + "SearchTextAndAddHyperlink_out_.pdf";
            editor.Save(dataDir);
            editor.Close();
            // ExEnd:SearchTextAndAddHyperlink
            Console.WriteLine("\nText replaced and hyperlink added successfully based on a regular expression.\nFile saved at " + dataDir);
        }
        public static void Run()
        {
            // ExStart:AddAttachmentStream
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Attachments();
            // Open document
            PdfContentEditor contentEditor = new PdfContentEditor();

            contentEditor.BindPdf(dataDir + "AddAttachment-Stream.pdf");

            // Read file into stream (FileStream or MemoryStream)
            FileStream fileStream = new FileStream(dataDir + "test.txt", FileMode.Open);

            // Add attachment
            contentEditor.AddDocumentAttachment(fileStream, "Attachment Name", "Attachment Description");

            // Save updated PDF
            contentEditor.Save(dataDir + "AddAttachment-Stream_out.pdf");
            // ExEnd:AddAttachmentStream
        }
        public static void Run()
        {
            // ExStart:DeleteImagesPage
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();
            // Open PDF file
            PdfContentEditor contentEditor = new PdfContentEditor();
            contentEditor.BindPdf(dataDir+ "DeleteImages-Page.pdf");

            // Array of images to be deleted
            int[] imageIndex = new int[] { 1 };

            // Delete the images from the particular page
            contentEditor.DeleteImage(2, imageIndex);

            // Save output PDF
            contentEditor.Save(dataDir+ "DeleteImages-Page_out.pdf");
            // ExEnd:DeleteImagesPage           
            
        }
        public static void Run()
        {
            // ExStart:CreateDocAdditionalAction
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_LinksActions();

            // Open document
            PdfContentEditor contentEditor = new PdfContentEditor();

            contentEditor.BindPdf(dataDir + "CreateDocumentLink.pdf");

            System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(100, 100, 200, 200);

            // Create application link
            contentEditor.AddDocumentAdditionalAction(PdfContentEditor.DocumentClose, "app.alert('Thank you for using Aspose products!');");

            // Save updated PDF
            contentEditor.Save(dataDir + "CreateDocAdditionalAction_out.pdf");
            // ExEnd:CreateDocAdditionalAction
        }
        public static void Run()
        {
            // ExStart:CreateDocAdditionalAction
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_LinksActions();

            // Open document
            PdfContentEditor contentEditor = new PdfContentEditor();
            contentEditor.BindPdf(dataDir + "CreateDocumentLink.pdf");

            System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(100, 100, 200, 200);

            // Create application link
            contentEditor.AddDocumentAdditionalAction(PdfContentEditor.DocumentClose, "app.alert('Thank you for using Aspose products!');");

            // Save updated PDF
            contentEditor.Save( dataDir + "CreateDocAdditionalAction_out.pdf");
            // ExEnd:CreateDocAdditionalAction
                     
        }
Exemple #29
0
        public static void Run()
        {
            // ExStart:DeleteImagesPage
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();
            // Open PDF file
            PdfContentEditor contentEditor = new PdfContentEditor();

            contentEditor.BindPdf(dataDir + "DeleteImages-Page.pdf");

            // Array of images to be deleted
            int[] imageIndex = new int[] { 1 };

            // Delete the images from the particular page
            contentEditor.DeleteImage(2, imageIndex);

            // Save output PDF
            contentEditor.Save(dataDir + "DeleteImages-Page_out.pdf");
            // ExEnd:DeleteImagesPage
        }
Exemple #30
0
        public static void Run()
        {
            // ExStart:RemoveAction
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_LinksActions();

            // Open document
            PdfContentEditor contentEditor = new PdfContentEditor();

            contentEditor.BindPdf(dataDir + "RemoveOpenAction.pdf");

            System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(100, 100, 200, 200);

            // Create application link
            contentEditor.RemoveDocumentOpenAction();

            // Save updated PDF
            contentEditor.Save(dataDir + "RemoveOpenAction_out.pdf");
            // ExEnd:RemoveAction
        }
Exemple #31
0
        public static void Run()
        {
            // ExStart:CreateAppLink
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_LinksActions();

            // Open document
            PdfContentEditor contentEditor = new PdfContentEditor();

            contentEditor.BindPdf(dataDir + "CreateApplicationLink.pdf");

            System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(100, 100, 200, 200);

            // Create application link
            contentEditor.CreateApplicationLink(rectangle, dataDir + "test.txt", 1);

            // Save updated PDF
            contentEditor.Save(dataDir + "CreateApplicationLink_out_.pdf");
            // ExEnd:CreateAppLink
        }
        public static void Run()
        {
            // ExStart:CreateJSLink
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_LinksActions();

            // Open document
            PdfContentEditor contentEditor = new PdfContentEditor();

            contentEditor.BindPdf(dataDir + "CreateApplicationLink.pdf");

            System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(100, 100, 200, 200);

            // Create application link
            contentEditor.CreateJavaScriptLink("app.alert('Welcome to Aspose!');", rectangle, 1, System.Drawing.Color.Red);

            // Save updated PDF
            contentEditor.Save(dataDir + "CreateJSLink_out_.pdf");
            // ExEnd:CreateJSLink
        }
Exemple #33
0
        public static void SetPrintDlgPropertiesUsingPdfContentEditor()
        {
            //ExStart:SetPrintDlgPropertiesUsingPdfContentEditor
            string dataDir = RunExamples.GetDataDir_AsposePdf_WorkingDocuments();

            string outputFile = dataDir + "input.pdf";

            using (PdfContentEditor ed = new PdfContentEditor())
            {
                ed.BindPdf(outputFile);
                if ((ed.GetViewerPreference() & ViewerPreference.DuplexFlipShortEdge) > 0)
                {
                    Console.WriteLine("The file has duplex flip short edge");
                }

                ed.ChangeViewerPreference(ViewerPreference.DuplexFlipShortEdge);
                ed.Save(dataDir + "SetPrintDlgPropertiesUsingPdfContentEditor_out.pdf");
            }
            //ExEnd: SetPrintDlgPropertiesUsingPdfContentEditor
        }
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            //Instantiate PdfContentEditor Object
            PdfContentEditor pdfContentEditor = new PdfContentEditor();

            ////bind input PDF file
            pdfContentEditor.BindPdf(dataDir + "input.pdf");

            int    pageId     = 1;
            int    stampIndex = 1;
            double x          = 200;
            double y          = 200;

            //Change the position of the stamp to new x and y position
            pdfContentEditor.MoveStamp(pageId, stampIndex, x, y);

            //Save the PDF file
            pdfContentEditor.Save(dataDir + "output.pdf");
        }
Exemple #35
0
        private Document RemoveExistingWatermarks(Document pdfDocument)
        {
            PdfContentEditor ped = new PdfContentEditor(pdfDocument);

            for (int i = 1; i <= pdfDocument.Pages.Count; i++)
            {
                double pHeight = pdfDocument.Pages[i].Rect.Height;
                double pWidth  = pdfDocument.Pages[i].Rect.Width;

                StampInfo[] vstamp     = ped.GetStamps(i);
                List <int>  ltToDelete = new List <int>();
                for (int j = 0; j < vstamp.Length; j++)
                {
                    if (StampType.Form == vstamp[j].StampType)
                    {
                        if ((vstamp[j].Rectangle.Height * 100) / pHeight >= 30 || (vstamp[j].Rectangle.Width * 100) / pWidth >= 30)
                        {
                            ltToDelete.Add(j);
                        }
                    }
                }

                int[] vToDelete = new int[ltToDelete.Count];
                for (int j = 0; j < ltToDelete.Count; j++)
                {
                    vToDelete[j] = ltToDelete[j];
                }

                ped.DeleteStamp(i, vToDelete);
            }


            MemoryStream outStream = new MemoryStream();

            ped.Save(outStream);
            Document pdfDocumentNoStamps = new Document(outStream);

            return(pdfDocumentNoStamps);
        }
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            //Instantiate PdfContentEditor Object
            PdfContentEditor pdfContentEditor = new PdfContentEditor();

            ////bind input PDF file
            pdfContentEditor.BindPdf(dataDir+ "input.pdf");

            int pageId = 1;
            int stampIndex = 1;
            double x = 200;
            double y = 200;

            //Change the position of the stamp to new x and y position
            pdfContentEditor.MoveStamp(pageId, stampIndex, x, y);

            //Save the PDF file
            pdfContentEditor.Save(dataDir+ "output.pdf");
        }
Exemple #37
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();

            //Instantiate PdfContentEditor Object
            PdfContentEditor pdfContentEditor = new PdfContentEditor();

            ////bind input PDF file
            pdfContentEditor.BindPdf(dataDir + "ChangeStampPosition.pdf");

            int    pageId     = 1;
            int    stampIndex = 1;
            double x          = 200;
            double y          = 200;

            //Change the position of the stamp to new x and y position
            pdfContentEditor.MoveStamp(pageId, stampIndex, x, y);

            //Save the PDF file
            pdfContentEditor.Save(dataDir + "ChangeStampPosition_out.pdf");
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();

            //Instantiate PdfContentEditor Object
            PdfContentEditor pdfContentEditor = new PdfContentEditor();

            ////bind input PDF file
            pdfContentEditor.BindPdf(dataDir+ "ChangeStampPosition.pdf");

            int pageId = 1;
            int stampIndex = 1;
            double x = 200;
            double y = 200;

            //Change the position of the stamp to new x and y position
            pdfContentEditor.MoveStamp(pageId, stampIndex, x, y);

            //Save the PDF file
            pdfContentEditor.Save(dataDir+ "ChangeStampPosition_out.pdf");
        }
        public static void Run()
        {
            // ExStart:SearchTextAndAddHyperlink
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();
            // Create absorber object to find all instances of the input search phrase
            TextFragmentAbsorber absorber = new TextFragmentAbsorber("\\d{4}-\\d{4}");
            // Enable regular expression search
            absorber.TextSearchOptions = new TextSearchOptions(true);
            // Open document
            PdfContentEditor editor = new PdfContentEditor();
            // Bind source PDF file
            editor.BindPdf(dataDir + "SearchRegularExpressionPage.pdf");
            // Accept the absorber for the page
            editor.Document.Pages[1].Accept(absorber);

            int[] dashArray = { };
            String[] LEArray = { };
            System.Drawing.Color blue = System.Drawing.Color.Blue;

            // Loop through the fragments
            foreach (TextFragment textFragment in absorber.TextFragments)
            {
                textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.Blue;
                System.Drawing.Rectangle rect = new System.Drawing.Rectangle((int)textFragment.Rectangle.LLX,
                    (int)Math.Round(textFragment.Rectangle.LLY), (int)Math.Round(textFragment.Rectangle.Width + 2),
                    (int)Math.Round(textFragment.Rectangle.Height + 1));
                Enum[] actionName = new Enum[2] { Aspose.Pdf.Annotations.PredefinedAction.Document_AttachFile, Aspose.Pdf.Annotations.PredefinedAction.Document_ExtractPages };
                editor.CreateWebLink(rect, "http:// Www.aspose.com", 1, blue, actionName);
                editor.CreateLine(rect, "", (float)textFragment.Rectangle.LLX + 1, (float)textFragment.Rectangle.LLY - 1,
                    (float)textFragment.Rectangle.URX, (float)textFragment.Rectangle.LLY - 1, 1, 1, blue, "S", dashArray, LEArray);
            }

            dataDir = dataDir + "SearchTextAndAddHyperlink_out.pdf";
            editor.Save(dataDir);
            editor.Close();
            // ExEnd:SearchTextAndAddHyperlink
            Console.WriteLine("\nText replaced and hyperlink added successfully based on a regular expression.\nFile saved at " + dataDir);
        }
Exemple #40
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();
            //create absorber object to find all instances of the input search phrase
            TextFragmentAbsorber absorber = new TextFragmentAbsorber("D[a-z]{7}:");

            //Enable regular expression search
            absorber.TextSearchOptions = new TextSearchOptions(true);
            //open document
            PdfContentEditor editor = new PdfContentEditor();

            // bind source PDF file
            editor.BindPdf(dataDir + "Input_new.pdf");
            //accept the absorber for the page
            editor.Document.Pages[1].Accept(absorber);

            int[]                dashArray = { };
            String[]             LEArray   = { };
            System.Drawing.Color blue      = System.Drawing.Color.Blue;

            //loop through the fragments
            foreach (TextFragment textFragment in absorber.TextFragments)
            {
                textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.Blue;
                System.Drawing.Rectangle rect = new System.Drawing.Rectangle((int)textFragment.Rectangle.LLX,
                                                                             (int)Math.Round(textFragment.Rectangle.LLY), (int)Math.Round(textFragment.Rectangle.Width + 2),
                                                                             (int)Math.Round(textFragment.Rectangle.Height + 1));
                Enum[] actionName = new Enum[2] {
                    Aspose.Pdf.InteractiveFeatures.PredefinedAction.Document_AttachFile, Aspose.Pdf.InteractiveFeatures.PredefinedAction.Document_ExtractPages
                };
                editor.CreateWebLink(rect, "http://www.aspose.com", 1, blue, actionName);
                editor.CreateLine(rect, "", (float)textFragment.Rectangle.LLX + 1, (float)textFragment.Rectangle.LLY - 1,
                                  (float)textFragment.Rectangle.URX, (float)textFragment.Rectangle.LLY - 1, 1, 1, blue, "S", dashArray, LEArray);
            }
            //Save & Close the document
            editor.Save(dataDir + "TextReplaced_with_Links.pdf");
            editor.Close();
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();
            //create absorber object to find all instances of the input search phrase
            TextFragmentAbsorber absorber = new TextFragmentAbsorber("D[a-z]{7}:");
            //Enable regular expression search
            absorber.TextSearchOptions = new TextSearchOptions(true);
            //open document            
            PdfContentEditor editor = new PdfContentEditor();
            // bind source PDF file
            editor.BindPdf(dataDir+ "Input_new.pdf");
            //accept the absorber for the page
            editor.Document.Pages[1].Accept(absorber);

            int[] dashArray = { };
            String[] LEArray = { };
            System.Drawing.Color blue = System.Drawing.Color.Blue;

            //loop through the fragments
            foreach (TextFragment textFragment in absorber.TextFragments)
            {
                textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.Blue;
                System.Drawing.Rectangle rect = new System.Drawing.Rectangle((int)textFragment.Rectangle.LLX,
                    (int)Math.Round(textFragment.Rectangle.LLY), (int)Math.Round(textFragment.Rectangle.Width + 2),
                    (int)Math.Round(textFragment.Rectangle.Height + 1));
                Enum[] actionName = new Enum[2] { Aspose.Pdf.InteractiveFeatures.PredefinedAction.Document_AttachFile, Aspose.Pdf.InteractiveFeatures.PredefinedAction.Document_ExtractPages };
                editor.CreateWebLink(rect, "http://www.aspose.com", 1, blue, actionName);
                editor.CreateLine(rect, "", (float)textFragment.Rectangle.LLX + 1, (float)textFragment.Rectangle.LLY - 1,
                    (float)textFragment.Rectangle.URX, (float)textFragment.Rectangle.LLY - 1, 1, 1, blue, "S", dashArray, LEArray);
            }
            //Save & Close the document
            editor.Save(dataDir+ "TextReplaced_with_Links.pdf");
            editor.Close();
 
            
            
        }
        public static void AddingBorderAroundAddedText()
        {
            // ExStart:AddingBorderAroundAddedText
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();

            PdfContentEditor editor = new PdfContentEditor();

            editor.BindPdf(dataDir + "input.pdf");
            LineInfo lineInfo = new LineInfo();

            lineInfo.LineWidth         = 2;
            lineInfo.VerticeCoordinate = new float[] { 0, 0, 100, 100, 50, 100 };
            lineInfo.Visibility        = true;
            editor.CreatePolygon(lineInfo, 1, new System.Drawing.Rectangle(0, 0, 0, 0), "");

            dataDir = dataDir + "AddingBorderAroundAddedText_out.pdf";

            // Save resulting PDF document.
            editor.Save(dataDir);
            // ExEnd:AddingBorderAroundAddedText
            Console.WriteLine("\nBorder around text added successfully.\nFile saved at " + dataDir);
        }
Exemple #43
0
        public ActionResult <Response> ConcatenateWithContents([FromBody] Request request)
        {
            try
            {
                Stopwatch stopwatch1 = new Stopwatch();
                stopwatch1.Start();

                PdfFileEditor pdfEditor = new PdfFileEditor();

                using (MemoryStream Concatenated_Stream = new MemoryStream())
                {
                    string concFilename = "Concatenated_Table_Of_Contents.pdf";

                    List <System.IO.Stream> pdfStreams = new List <System.IO.Stream>();
                    string[] files = System.IO.Directory.GetFiles(serverDirectory);
                    foreach (string file in files)
                    {
                        if (file.ToLower().Contains(concFilename.ToLower()))
                        {
                            continue;
                        }
                        if (!Path.GetExtension(file).Equals(".pdf"))
                        {
                            continue;
                        }
                        System.IO.FileStream stream = new System.IO.FileStream(file, System.IO.FileMode.Open);
                        pdfStreams.Add(stream);
                    }

                    //System.IO.FileStream outputPDF = new System.IO.FileStream(serverDirectory + request.filename + ".pdf", System.IO.FileMode.Create);
                    Stopwatch stopwatch2 = new Stopwatch();
                    stopwatch2.Start();

                    pdfEditor.Concatenate(pdfStreams.ToArray(), Concatenated_Stream);

                    stopwatch2.Stop();
                    Console.WriteLine("PdfEditor.Concatenate Action: " + stopwatch2.ElapsedMilliseconds.ToString());

                    // Insert a blank page at the begining of concatenated file to display Table of Contents
                    Aspose.Pdf.Document concatenated_pdfDocument = new Aspose.Pdf.Document(Concatenated_Stream);
                    // Insert a empty page in a PDF
                    concatenated_pdfDocument.Pages.Insert(1);

                    using (MemoryStream Document_With_BlankPage = new MemoryStream())
                    {
                        // Save output file

                        stopwatch2.Reset();
                        stopwatch2.Start();
                        concatenated_pdfDocument.Save(Document_With_BlankPage);

                        stopwatch2.Stop();
                        Console.WriteLine("Concatenated_pdfDocument.Save Action: " + stopwatch2.ElapsedMilliseconds.ToString());

                        using (var Document_with_TOC_Heading = new MemoryStream())
                        {
                            // Add Table Of Contents logo as stamp to PDF file
                            PdfFileStamp fileStamp = new PdfFileStamp();
                            // Find the input file
                            fileStamp.BindPdf(Document_With_BlankPage);

                            // Set Text Stamp to display string Table Of Contents
                            Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
                            stamp.BindLogo(new FormattedText("Table Of Contents", System.Drawing.Color.Maroon, System.Drawing.Color.Transparent, Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, true, 18));
                            // Specify the origin of Stamp. We are getting the page width and specifying the X coordinate for stamp
                            stamp.SetOrigin((new PdfFileInfo(Document_With_BlankPage).GetPageWidth(1) / 3), 700);
                            // Set particular pages
                            stamp.Pages = new int[] { 1 };
                            // Add stamp to PDF file

                            stopwatch2.Reset();
                            stopwatch2.Start();
                            fileStamp.AddStamp(stamp);

                            stopwatch2.Stop();
                            Console.WriteLine("FileStamp.AddStamp Action: " + stopwatch2.ElapsedMilliseconds.ToString());

                            int counter = 1;
                            int diff    = 0;
                            foreach (System.IO.Stream stream in pdfStreams)
                            {
                                var Document_Link = new Aspose.Pdf.Facades.Stamp();
                                Document_Link.BindLogo(new FormattedText(counter + " - Link to Document " + counter, System.Drawing.Color.Black, System.Drawing.Color.Transparent, Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, true, 12));
                                Document_Link.SetOrigin(150, 650 - diff);
                                Document_Link.Pages = new int[] { 1 };
                                fileStamp.AddStamp(Document_Link);
                                counter++;
                                diff += 40;
                            }

                            stopwatch2.Reset();
                            stopwatch2.Start();
                            fileStamp.Save(Document_with_TOC_Heading);
                            stopwatch2.Stop();
                            Console.WriteLine("FileStamp.Save Action: " + stopwatch2.ElapsedMilliseconds.ToString());


                            fileStamp.Close();

                            PdfContentEditor contentEditor = new PdfContentEditor();
                            // Bind the PDF file in which we added the blank page
                            contentEditor.BindPdf(Document_with_TOC_Heading);

                            counter = 1;
                            diff    = 0;
                            int numberOfpagesOfPreviousFile = 0;
                            foreach (System.IO.Stream stream in pdfStreams)
                            {
                                if (counter == 1)
                                {
                                    contentEditor.CreateLocalLink(new System.Drawing.Rectangle(150, 650 - diff, 100, 20), counter + 1, 1, System.Drawing.Color.Transparent);
                                }
                                else
                                {
                                    //Replace counter with numberOfpagesOfPreviousFile of the following line to fix Link page number
                                    contentEditor.CreateLocalLink(new System.Drawing.Rectangle(150, 650 - diff, 100, 20), counter + 1, 1, System.Drawing.Color.Transparent);
                                }
                                counter++;
                                numberOfpagesOfPreviousFile = new PdfFileInfo(stream).NumberOfPages;
                                diff += 40;
                            }

                            if (System.IO.File.Exists(serverDirectory + concFilename))
                            {
                                System.IO.File.Delete(serverDirectory + concFilename);
                            }

                            stopwatch2.Reset();
                            stopwatch2.Start();

                            contentEditor.Save(serverDirectory + concFilename);

                            stopwatch2.Stop();
                            Console.WriteLine("FileStamp.Save Action: " + stopwatch2.ElapsedMilliseconds.ToString());
                        }
                    }
                }

                stopwatch1.Stop();
                Console.WriteLine("Total Time: " + stopwatch1.ElapsedMilliseconds.ToString());

                return(new Response()
                {
                    FileContent = string.Empty,
                    FileName = "Concatenated_Table_Of_Contents.pdf",
                    Message = "Files Concatenated successfully to: Concatenated_Table_Of_Contents.pdf file",
                    Success = true
                });
            }
            catch (Exception ex)
            {
                return(new Response()
                {
                    FileContent = string.Empty,
                    FileName = "",
                    Message = "Could not concatenate files. " + ex.Message,
                    Success = false
                });
            }
        }
 /// <summary>
 /// Sets the PDF to be showing the Bookmarks pane (document outline) on document open.
 /// </summary>
 /// <param name="pdf">PDF byte array</param>
 /// <returns>PDF byte array</returns>
 private static byte[] setShowBookmarksPaneOnOpen( byte[] pdf )
 {
     using( var tmpPdf = new MemoryStream( pdf ) ) {
         var pce = new PdfContentEditor();
         pce.BindPdf( tmpPdf );
         pce.ChangeViewerPreference( ViewerPreference.PageModeUseOutlines );
         using( var saveStream = new MemoryStream() ) {
             pce.Save( saveStream );
             return saveStream.ToArray();
         }
     }
 }
Exemple #45
0
        public IHttpActionResult Upload()
        {
            var httpRequest = HttpContext.Current.Request;
            var fullPath    = Path.Combine(Config.Configuration.WorkingDirectory.Replace("/", "\\"), "Editor", httpRequest.Form["documentId"]);

            var postedFile = httpRequest.Files[0];

            if (postedFile == null)
            {
                return(InternalServerError(new Exception("")));
            }

            if (httpRequest.Form["Opp"].StartsWith("uploading"))
            {
                var guid       = Guid.NewGuid().ToString();
                var tempFolder = string.Format("{0}Editor\\{1}", Config.Configuration.WorkingDirectory.Replace("/", "\\"), guid);
                Directory.CreateDirectory(tempFolder);
                var filePath = Path.Combine(tempFolder, "document.pdf");
                postedFile.SaveAs(filePath);
                var model = new DocStatusModel
                {
                    d                = ImageConverter(filePath),
                    Path             = guid,
                    OriginalFileName = postedFile.FileName
                };
                return(Ok(model));
            }
            else if (httpRequest.Form["Opp"].StartsWith("appending"))
            {
                string appPages   = httpRequest.Form["pages"];
                string appRatios  = httpRequest.Form["ratios"];
                string appHeights = httpRequest.Form["heights"];
                var    filePath   = Path.Combine(fullPath, "append.pdf");
                postedFile.SaveAs(filePath);
                var model = new DocStatusModel
                {
                    d    = AppendConverter(fullPath, appPages, appRatios, appHeights),
                    Path = httpRequest.Form["documentId"]
                };
                return(Ok(model));
            }
            else if (httpRequest.Form["Opp"].StartsWith("addAttachment"))
            {
                var documentFileName = Path.Combine(fullPath, "document.pdf");

                PdfContentEditor contentEditor = new PdfContentEditor();
                contentEditor.BindPdf(documentFileName);
                contentEditor.AddDocumentAttachment(postedFile.InputStream, postedFile.FileName, "File added by Aspose.PDF Editor");
                contentEditor.Save(documentFileName);

                return(Ok(new DocStatusModel
                {
                    d = postedFile.FileName,
                    Path = httpRequest.Form["documentId"]
                }));
            }
            else
            {
                //Or just save it locally
                var filePath = Path.Combine(fullPath, postedFile.FileName);
                postedFile.SaveAs(filePath);

                var model = new DocStatusModel
                {
                    d    = postedFile.FileName,
                    Path = httpRequest.Form["documentId"]
                };
                return(Ok(model));
            }
        }
Exemple #46
0
        public static void CompletedCode()
        {
            // ExStart:CompletedCode
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();

            // Create PdfFileEditor object
            PdfFileEditor pdfEditor = new PdfFileEditor();

            // Create a MemoryStream object to hold the resultant PDf file
            using (MemoryStream Concatenated_Stream = new MemoryStream())
            {
                // Save concatenated output file
                pdfEditor.Concatenate(new FileStream(dataDir + "input1.pdf", FileMode.Open), new FileStream(dataDir + "input2.pdf", FileMode.Open), Concatenated_Stream);
                // Insert a blank page at the begining of concatenated file to display Table of Contents
                Aspose.Pdf.Document concatenated_pdfDocument = new Aspose.Pdf.Document(Concatenated_Stream);
                // Insert a empty page in a PDF
                concatenated_pdfDocument.Pages.Insert(1);

                // Hold the resultnat file with empty page added
                using (MemoryStream Document_With_BlankPage = new MemoryStream())
                {
                    // Save output file
                    concatenated_pdfDocument.Save(Document_With_BlankPage);

                    using (var Document_with_TOC_Heading = new MemoryStream())
                    {
                        // Add Table Of Contents logo as stamp to PDF file
                        PdfFileStamp fileStamp = new PdfFileStamp();
                        // Find the input file
                        fileStamp.BindPdf(Document_With_BlankPage);

                        // Set Text Stamp to display string Table Of Contents
                        Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
                        stamp.BindLogo(new FormattedText("Table Of Contents", System.Drawing.Color.Maroon, System.Drawing.Color.Transparent, Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, true, 18));
                        // Specify the origin of Stamp. We are getting the page width and specifying the X coordinate for stamp
                        stamp.SetOrigin((new PdfFileInfo(Document_With_BlankPage).GetPageWidth(1) / 3), 700);
                        // Set particular pages
                        stamp.Pages = new int[] { 1 };
                        // Add stamp to PDF file
                        fileStamp.AddStamp(stamp);

                        // Create stamp text for first item in Table Of Contents
                        var Document1_Link = new Aspose.Pdf.Facades.Stamp();
                        Document1_Link.BindLogo(new FormattedText("1 - Link to Document 1", System.Drawing.Color.Black, System.Drawing.Color.Transparent, Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, true, 12));
                        // Specify the origin of Stamp. We are getting the page width and specifying the X coordinate for stamp
                        Document1_Link.SetOrigin(150, 650);
                        // Set particular pages on which stamp should be displayed
                        Document1_Link.Pages = new int[] { 1 };
                        // Add stamp to PDF file
                        fileStamp.AddStamp(Document1_Link);

                        // Create stamp text for second item in Table Of Contents
                        var Document2_Link = new Aspose.Pdf.Facades.Stamp();
                        Document2_Link.BindLogo(new FormattedText("2 - Link to Document 2", System.Drawing.Color.Black, System.Drawing.Color.Transparent, Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, true, 12));
                        // Specify the origin of Stamp. We are getting the page width and specifying the X coordinate for stamp
                        Document2_Link.SetOrigin(150, 620);
                        // Set particular pages on which stamp should be displayed
                        Document2_Link.Pages = new int[] { 1 };
                        // Add stamp to PDF file
                        fileStamp.AddStamp(Document2_Link);

                        // Save updated PDF file
                        fileStamp.Save(Document_with_TOC_Heading);
                        fileStamp.Close();

                        // Now we need to add Heading for Table Of Contents and links for documents
                        PdfContentEditor contentEditor = new PdfContentEditor();
                        // Bind the PDF file in which we added the blank page
                        contentEditor.BindPdf(Document_with_TOC_Heading);
                        // Create link for first document
                        contentEditor.CreateLocalLink(new System.Drawing.Rectangle(150, 650, 100, 20), 2, 1, System.Drawing.Color.Transparent);
                        // Create link for Second document
                        // We have used   new PdfFileInfo("d:/pdftest/Input1.pdf").NumberOfPages + 2   as PdfFileInfo.NumberOfPages(..) returns the page count for first document
                        // and 2 is because, second document will start at Input1+1 and 1 for the page containing Table Of Contents.
                        contentEditor.CreateLocalLink(new System.Drawing.Rectangle(150, 620, 100, 20), new PdfFileInfo(dataDir + "Input1.pdf").NumberOfPages + 2, 1, System.Drawing.Color.Transparent);

                        // Save updated PDF
                        contentEditor.Save(dataDir + "Concatenated_Table_Of_Contents.pdf");
                    }
                }
            }
            // ExEnd:CompletedCode
        }
        public static void Run()
        {
            // ExStart:CreateNestedBookmarks
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();

            // New a object of Class PdfContentEditor
            PdfContentEditor editor = new PdfContentEditor();

            editor.BindPdf(dataDir + "inFile.pdf");
            // Creating child items of a chapter, in this example, the first child item also include a child item.
            Bookmark bm11 = new Bookmark();

            // Set the action type of BookMark
            bm11.Action = "GoTo";
            // Set the BookMark Destination page
            bm11.PageNumber = 3;
            // Set the BookMark title.
            bm11.Title = "Section - 1.1.1";

            Bookmark bm1 = new Bookmark();

            bm1.Action     = "GoTo";
            bm1.PageNumber = 2;
            bm1.Title      = "Section - 1.1";

            Aspose.Pdf.Facades.Bookmarks bms1 = new Aspose.Pdf.Facades.Bookmarks();
            bms1.Add(bm11);
            bm1.ChildItems = bms1;

            // Creating a child item of a chapter.
            Bookmark bm2 = new Bookmark();

            bm2.Action     = "GoTo";
            bm2.PageNumber = 4;
            bm2.Title      = "Section - 1.2";

            // Creating a chapter (Parent Level Bookmark)
            Bookmark bm = new Bookmark();

            bm.Action     = "GoTo";
            bm.PageNumber = 1;
            bm.Title      = "Chapter - 1";

            Aspose.Pdf.Facades.Bookmarks bms = new Aspose.Pdf.Facades.Bookmarks();
            // Add the Section - 1.1, bookmark to bookmarks collection
            bms.Add(bm1);
            // Add the Section - 1.2, bookmark to bookmarks collection
            bms.Add(bm2);
            // Add the Bookmarks collection as child_Item of Chapter_Level bookmark
            bm.ChildItems = bms;

            // Creating a chapter (Parent Level Bookmark)
            Bookmark bm_parent2 = new Bookmark();

            bm_parent2.Action     = "GoTo";
            bm_parent2.PageNumber = 5;
            bm_parent2.Title      = "Chapter - 2";

            // Creating a child item of a chapter.
            Bookmark bm22 = new Bookmark();

            bm22.Action     = "GoTo";
            bm22.PageNumber = 6;
            bm22.Title      = "Section - 2.1";

            Aspose.Pdf.Facades.Bookmarks bms_parent2 = new Aspose.Pdf.Facades.Bookmarks();
            // Add the Section - 2.1, bookmark to bookmarks collection
            bms_parent2.Add(bm22);
            // Add the Bookmarks collection as child_Item of Chapter2_Level bookmark
            bm_parent2.ChildItems = bms_parent2;

            // Saves the result PDF to file
            editor.Save(dataDir + "Nested_BookMarks_out.pdf");
            // ExEnd:CreateNestedBookmarks
        }
        public static void AddingBorderAroundAddedText()
        {
            // ExStart:AddingBorderAroundAddedText
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();

            PdfContentEditor editor = new PdfContentEditor();
            editor.BindPdf(dataDir + "input.pdf");
            LineInfo lineInfo = new LineInfo();
            lineInfo.LineWidth = 2;
            lineInfo.VerticeCoordinate = new float[] { 0, 0, 100, 100, 50, 100 };
            lineInfo.Visibility = true;
            editor.CreatePolygon(lineInfo, 1, new System.Drawing.Rectangle(0, 0, 0, 0), "");

            dataDir = dataDir + "AddingBorderAroundAddedText_out.pdf";

            // Save resulting PDF document.
            editor.Save(dataDir);
            // ExEnd:AddingBorderAroundAddedText
            Console.WriteLine("\nBorder around text added successfully.\nFile saved at " + dataDir);
        }