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);
            }
            
        }
Ejemplo n.º 3
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");
 }
Ejemplo n.º 4
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 text on all pages
     pdfContentEditor.ReplaceText("Hello", 1, "World");
     //save output PDF
     pdfContentEditor.Save(dataDir+ "ReplaceText.pdf");
 }
Ejemplo n.º 5
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");
     
 }
Ejemplo n.º 6
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");

            //delete attachments
            contentEditor.DeleteAttachments();

            //save updated PDF
            contentEditor.Save(dataDir+ "output.pdf");
        }
Ejemplo n.º 7
0
 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");
     
     
 }
Ejemplo n.º 8
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");
        }
Ejemplo n.º 9
0
 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 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
        }
Ejemplo n.º 11
0
        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");
        }
Ejemplo n.º 12
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");
     //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");
 }
Ejemplo n.º 13
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");
        }
Ejemplo n.º 14
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");
            
        }
Ejemplo n.º 15
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");

            //delete attachments
            contentEditor.DeleteAttachments();

            //save updated PDF
            contentEditor.Save(dataDir + "output.pdf");
        }
Ejemplo n.º 16
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");
        }
Ejemplo n.º 17
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");
        }
Ejemplo n.º 18
0
        public static void Run()
        {
            // ExStart:ReplaceImage
            // 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");
            // ExEnd:ReplaceImage
        }
Ejemplo n.º 19
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");
        }
Ejemplo n.º 20
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");
        }
Ejemplo n.º 21
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");
        }
Ejemplo n.º 22
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
        }
Ejemplo n.º 23
0
        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()
        {
            // 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            
        }
Ejemplo n.º 25
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");
     
     
 }
Ejemplo n.º 26
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");

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

            //save output PDF file
            contentEditor.Save(dataDir+ "output.pdf");
        }
Ejemplo n.º 27
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+ "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: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_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");
        }
Ejemplo n.º 30
0
        public static void Run()
        {
            // ExStart:DeleteAllImages
            // 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");
            // ExEnd:DeleteAllImages
        }
Ejemplo n.º 31
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");

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

            //save output PDF file
            contentEditor.Save(dataDir + "output.pdf");
        }
Ejemplo n.º 32
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
        }
Ejemplo n.º 33
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");
            
            
        }
Ejemplo n.º 34
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");
        }
        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            
        }
Ejemplo n.º 36
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");

            //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");
        }
Ejemplo n.º 37
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: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);
        }
Ejemplo n.º 39
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: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                                 
        }
Ejemplo n.º 41
0
        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                                 
        }
Ejemplo n.º 42
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()
        {
            // 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           
            
        }
Ejemplo n.º 44
0
        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
        }
Ejemplo n.º 45
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 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
                     
        }
Ejemplo n.º 48
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
        }
Ejemplo n.º 49
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: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
        }
Ejemplo n.º 51
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 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);
        }
Ejemplo n.º 53
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");

            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");
        }
Ejemplo n.º 54
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();
        }
Ejemplo n.º 55
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");
        }
Ejemplo n.º 56
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");

            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");
        }
Ejemplo n.º 57
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");
        }
Ejemplo n.º 58
0
        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);
        }
Ejemplo n.º 59
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));
            }
        }
        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
        }