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 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 Run()
        {
            try
            {
                // ExStart:ExtractImageImageStamp
                // 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 + "ExtractImage-ImageStamp.pdf");

                // Get Stamp info for the first stamp
                StampInfo[] infos = pdfContentEditor.GetStamps(1);

                // Get the image from Stamp Info
                System.Drawing.Image image = infos[0].Image;

                // Save the extracted image
                image.Save(dataDir + "image_out_.jpg");
                // ExEnd:ExtractImageImageStamp
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemple #4
0
        public static void Run()
        {
            // ExStart:SearchTextAndDrawRectangle
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();

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

            // Create TextAbsorber object to find all the phrases matching the regular expression

            TextFragmentAbsorber textAbsorber = new TextFragmentAbsorber(@"[\S]+");

            TextSearchOptions textSearchOptions = new TextSearchOptions(true);

            textAbsorber.TextSearchOptions = textSearchOptions;

            document.Pages.Accept(textAbsorber);

            var editor = new PdfContentEditor(document);

            foreach (TextFragment textFragment in textAbsorber.TextFragments)

            {
                foreach (TextSegment textSegment in textFragment.Segments)

                {
                    DrawBox(editor, textFragment.Page.Number, textSegment, System.Drawing.Color.Red);
                }
            }
            dataDir = dataDir + "SearchTextAndDrawRectangle_out.pdf";
            document.Save(dataDir);
            // ExEnd:SearchTextAndDrawRectangle
            Console.WriteLine("\nRectangle drawn successfully on searched text.\nFile saved at " + dataDir);
        }
        public static void Run()
        {
            try
            {
                // ExStart:ExtractImageImageStamp
                // 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 + "ExtractImage-ImageStamp.pdf");

                // Get Stamp info for the first stamp
                StampInfo[] infos = pdfContentEditor.GetStamps(1);

                // Get the image from Stamp Info           
                System.Drawing.Image image = infos[0].Image;

                // Save the extracted image
                image.Save(dataDir + "image_out.jpg");
                // ExEnd:ExtractImageImageStamp  
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            
        }
 /// <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());
         }
     }
 }
 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_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");
        }
Exemple #10
0
 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");
     
 }
Exemple #11
0
        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 + "input1.pdf");
            //replace text on all pages
            pdfContentEditor.ReplaceText("Hello", "World");
            //save output PDF
            pdfContentEditor.Save(dataDir + "ReplaceTextOnAllPages.pdf");
        }
Exemple #12
0
        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");
        }
Exemple #13
0
        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 + "ReplaceText-Page.pdf");
            //replace text on all pages
            pdfContentEditor.ReplaceText("Hello", 1, "World");
            //save output PDF
            pdfContentEditor.Save(dataDir + "ReplaceText.pdf");
        }
        public static void CreateLocalLinks()
        {
            // ExStart:CreateLocalLinks
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();

            // 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(new FileStream(dataDir + "Concatenated_Table_Of_Contents.pdf", FileMode.Open));
            // Create link for first document
            contentEditor.CreateLocalLink(new System.Drawing.Rectangle(150, 650, 100, 20), 2, 1, System.Drawing.Color.Transparent);
            // ExEnd:CreateLocalLinks
        }
        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 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");

            //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 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/");

            // 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 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 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 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 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");
            
        }
Exemple #24
0
        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");
        }
Exemple #25
0
        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 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");
        }
Exemple #27
0
        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");
        }
Exemple #28
0
        public static void CreateLocalLinks()
        {
            // ExStart:CreateLocalLinks
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();

            // 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(new FileStream(dataDir + "Concatenated_Table_Of_Contents.pdf", FileMode.Open));
            // Create link for first document
            contentEditor.CreateLocalLink(new System.Drawing.Rectangle(150, 650, 100, 20), 2, 1, System.Drawing.Color.Transparent);
            // ExEnd:CreateLocalLinks
        }
        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");

            //delete attachments
            contentEditor.DeleteAttachments();

            //save updated PDF
            contentEditor.Save(dataDir + "output.pdf");
        }
Exemple #31
0
        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");
        }
Exemple #32
0
        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 + "DeleteAllAttachments.pdf");

            //delete attachments
            contentEditor.DeleteAttachments();

            //save updated PDF
            contentEditor.Save(dataDir + "DeleteAllAttachments_out.pdf");
        }
 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()
        {
            // 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: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()
        {
            // 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 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()
        {
            // 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");
        }
Exemple #39
0
        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 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 Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");
            //open document
            PdfContentEditor contentEditor = new PdfContentEditor();

            contentEditor.BindPdf(dataDir + "input.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 + "output.pdf");
        }
        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: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            
        }
Exemple #44
0
        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");
        }
Exemple #45
0
        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 + "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");
        }
        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                                 
        }
        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: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                                 
        }
Exemple #50
0
        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");

            //Get Stamp info for the first stamp
            StampInfo[] infos = pdfContentEditor.GetStamps(1);

            //Get the image from Stamp Info

            System.Drawing.Image image = infos[0].Image;

            //Save the extracted image
            image.Save(dataDir + "image.jpg");
        }
        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 + "ExtractImage-ImageStamp.pdf");

            //Get Stamp info for the first stamp
            StampInfo[] infos = pdfContentEditor.GetStamps(1);

            //Get the image from Stamp Info

            System.Drawing.Image image = infos[0].Image;

            //Save the extracted image
            image.Save(dataDir + "image.jpg");
        }
        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");

            //Get Stamp info for the first stamp
            StampInfo[] infos = pdfContentEditor.GetStamps(1);

            //Get the image from Stamp Info

            System.Drawing.Image image = infos[0].Image;

            //Save the extracted image
            image.Save(dataDir+ "image.jpg");
        }
        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 #54
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: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 #56
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
        }
        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
        }
        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 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");
        }
        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);
        }