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

            // Create PdfBookmarkEditor
            PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();

            // Open PDF file
            bookmarkEditor.BindPdf(dataDir + "GetBookmarks.pdf");
            // Extract bookmarks
            Aspose.Pdf.Facades.Bookmarks bookmarks = bookmarkEditor.ExtractBookmarks();
            foreach (Aspose.Pdf.Facades.Bookmark bookmark in bookmarks)
            {
                string strLevelSeprator = string.Empty;
                for (int i = 1; i < bookmark.Level; i++)
                {
                    strLevelSeprator += "----";
                }

                Console.WriteLine("{0}Title: {1}", strLevelSeprator, bookmark.Title);
                Console.WriteLine("{0}Page Number: {1}", strLevelSeprator, bookmark.PageNumber);
                Console.WriteLine("{0}Page Action: {1}", strLevelSeprator, bookmark.Action);
            }
            // ExEnd:GetBookmarkPageNumber
        }
        public static void Run()
        {
            // ExStart:AddChildBookmark
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks();
            // Create bookmarks
            Aspose.Pdf.Facades.Bookmarks bookmarks = new Aspose.Pdf.Facades.Bookmarks();
            Bookmark childBookmark1 = new Bookmark();
            childBookmark1.PageNumber = 1;
            childBookmark1.Title = "First Child";
            Bookmark childBookmark2 = new Bookmark();
            childBookmark2.PageNumber = 2;
            childBookmark2.Title = "Second Child";

            bookmarks.Add(childBookmark1);
            bookmarks.Add(childBookmark2);

            Bookmark bookmark = new Bookmark();
            bookmark.Action = "GoTo";
            bookmark.PageNumber = 1;
            bookmark.Title = "Parent";

            bookmark.ChildItems = bookmarks;

            // Create PdfBookmarkEditor class
            PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();
            // Bind PDF document
            bookmarkEditor.BindPdf(dataDir+ "AddChildBookmark.pdf");
            // Create bookmarks
            bookmarkEditor.CreateBookmarks(bookmark);
            // Save updated document
            bookmarkEditor.Save(dataDir+ "AddChildBookmark_out.pdf");
            // ExEnd:AddChildBookmark
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks();
            //create PdfBookmarkEditor
            PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();

            //open PDF file
            bookmarkEditor.BindPdf(dataDir + "ExtractBookmarks.pdf");
            //extract bookmarks
            Aspose.Pdf.Facades.Bookmarks bookmarks = bookmarkEditor.ExtractBookmarks();

            foreach (Bookmark bookmark in bookmarks)
            {
                Console.WriteLine("Title: {0}", bookmark.Title);
                Console.WriteLine("Page Number: {0}", bookmark.PageNumber);
            }
        }
예제 #4
0
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");
            //create PdfBookmarkEditor
            PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();

            //open PDF file
            bookmarkEditor.BindPdf(dataDir + "input.PDF");
            //extract bookmarks
            Aspose.Pdf.Facades.Bookmarks bookmarks = bookmarkEditor.ExtractBookmarks();
            foreach (Aspose.Pdf.Facades.Bookmark bookmark in bookmarks)
            {
                // get the title information of bookmark item
                Console.WriteLine("Title: {0}", bookmark.Title);
                // get the destination page for bookmark
                Console.WriteLine("Page Number: {0}", bookmark.PageNumber);
                // get the information related to associated action with bookmark
                Console.WriteLine("Bookmark Action: " + bookmark.Action);
            }
        }
        public static void Run()
        {
            // ExStart:AddChildBookmark
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks();

            // Create bookmarks
            Aspose.Pdf.Facades.Bookmarks bookmarks = new Aspose.Pdf.Facades.Bookmarks();
            Bookmark childBookmark1 = new Bookmark();

            childBookmark1.PageNumber = 1;
            childBookmark1.Title      = "First Child";
            Bookmark childBookmark2 = new Bookmark();

            childBookmark2.PageNumber = 2;
            childBookmark2.Title      = "Second Child";

            bookmarks.Add(childBookmark1);
            bookmarks.Add(childBookmark2);

            Bookmark bookmark = new Bookmark();

            bookmark.Action     = "GoTo";
            bookmark.PageNumber = 1;
            bookmark.Title      = "Parent";

            bookmark.ChildItems = bookmarks;

            // Create PdfBookmarkEditor class
            PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();

            // Bind PDF document
            bookmarkEditor.BindPdf(dataDir + "AddChildBookmark.pdf");
            // Create bookmarks
            bookmarkEditor.CreateBookmarks(bookmark);
            // Save updated document
            bookmarkEditor.Save(dataDir + "AddChildBookmark_out_.pdf");
            // ExEnd:AddChildBookmark
        }
예제 #6
0
        public static void Run()
        {
            // ExStart:GetFromPDF
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks();
            // Create PdfBookmarkEditor
            PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();

            // Open PDF file
            bookmarkEditor.BindPdf(dataDir + "GetFromPDF.PDF");
            // Extract bookmarks
            Aspose.Pdf.Facades.Bookmarks bookmarks = bookmarkEditor.ExtractBookmarks();
            foreach (Aspose.Pdf.Facades.Bookmark bookmark in bookmarks)
            {
                // Get the title information of bookmark item
                Console.WriteLine("Title: {0}", bookmark.Title);
                // Get the destination page for bookmark
                Console.WriteLine("Page Number: {0}", bookmark.PageNumber);
                // Get the information related to associated action with bookmark
                Console.WriteLine("Bookmark Action: " + bookmark.Action);
            }
            // ExEnd:GetFromPDF
        }
        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
        }
예제 #8
0
        public ActionResult <Response> CreateFileWithNB([FromBody] Request request)
        {
            try
            {
                if (!System.IO.File.Exists(serverDirectory + request.filename))
                {
                    throw new Exception("Source File does not Exist");
                }

                string result = "File_With_NB.pdf";

                PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();
                bookmarkEditor.BindPdf(serverDirectory + request.filename);

                // 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 bm12 = new Bookmark();
                // Set the action type of BookMark
                bm12.Action = "GoTo";
                // Set the BookMark Destination page
                bm12.PageNumber = 3;
                // Set the BookMark title.
                bm12.Title = "Section - 2.1.1";


                Bookmark bm1 = new Bookmark();
                bm1.Action     = "GoTo";
                bm1.PageNumber = 2;
                bm1.Title      = "Section - 1.1";

                Bookmark bm2 = new Bookmark();
                bm2.Action     = "GoTo";
                bm2.PageNumber = 2;
                bm2.Title      = "Section - 2.1";

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

                Aspose.Pdf.Facades.Bookmarks bms2 = new Aspose.Pdf.Facades.Bookmarks();
                bms2.Add(bm12);
                bm2.ChildItems = bms2;

                Aspose.Pdf.Facades.Bookmarks bms0 = new Aspose.Pdf.Facades.Bookmarks();
                bms0.Add(bm1);

                Aspose.Pdf.Facades.Bookmarks bms01 = new Aspose.Pdf.Facades.Bookmarks();
                bms01.Add(bm2);

                // Creating a chapter (Parent Level Bookmark)
                Bookmark bm = new Bookmark();
                bm.Action     = "GoTo";
                bm.PageNumber = 1;
                bm.Title      = "Chapter - 1";
                bm.ChildItems = bms0;
                bookmarkEditor.CreateBookmarks(bm);

                bm            = new Bookmark();
                bm.Action     = "GoTo";
                bm.PageNumber = 1;
                bm.Title      = "Chapter - 2";
                bm.ChildItems = bms01;
                bookmarkEditor.CreateBookmarks(bm);

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

                bookmarkEditor.Save(serverDirectory + result);

                return(new Response()
                {
                    FileContent = string.Empty,
                    FileName = result,
                    Message = "File Created successfully",
                    Success = true
                });
            }
            catch (Exception ex)
            {
                return(new Response()
                {
                    FileContent = string.Empty,
                    FileName = "",
                    Message = "Could not Create file. " + ex.Message,
                    Success = false
                });
            }
        }
        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                      
        }