ApiExamples.ExBookmarks.AddBookmarkWithWhiteSpaces C# (CSharp) Метод

AddBookmarkWithWhiteSpaces() приватный Метод

private AddBookmarkWithWhiteSpaces ( SaveFormat saveFormat ) : void
saveFormat SaveFormat
Результат void
        public void AddBookmarkWithWhiteSpaces(SaveFormat saveFormat)
        {
            Document doc = new Document();

            InsertBookmarks(doc);

            if (saveFormat == SaveFormat.Pdf)
            {
                //Save document with pdf save options
                doc.Save(MyDir + @"\Artifacts\Bookmark_WhiteSpaces.pdf", AddBookmarkSaveOptions(SaveFormat.Pdf));

                //Bind pdf with Aspose PDF
                PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();
                bookmarkEditor.BindPdf(MyDir + @"\Artifacts\Bookmark_WhiteSpaces.pdf");

                //Get all bookmarks from the document
                Bookmarks bookmarks = bookmarkEditor.ExtractBookmarks();

                Assert.AreEqual(3, bookmarks.Count);

                //Assert that all the bookmarks title are with witespaces
                Assert.AreEqual("My Bookmark", bookmarks[0].Title);
                Assert.AreEqual("Nested Bookmark", bookmarks[1].Title);

                //Assert that the bookmark title without witespaces
                Assert.AreEqual("Bookmark_WithoutWhiteSpaces", bookmarks[2].Title);
            }
            else
            {
                MemoryStream dstStream = new MemoryStream();
                doc.Save(dstStream, AddBookmarkSaveOptions(saveFormat));

                //Get bookmarks from the document
                BookmarkCollection bookmarks = doc.Range.Bookmarks;

                Assert.AreEqual(3, bookmarks.Count);

                //Assert that all the bookmarks title are with witespaces
                Assert.AreEqual("My Bookmark", bookmarks[0].Name);
                Assert.AreEqual("Nested Bookmark", bookmarks[1].Name);

                //Assert that the bookmark title without witespaces
                Assert.AreEqual("Bookmark_WithoutWhiteSpaces", bookmarks[2].Name);
            }
        }