How to memorize bookmarks- delete them and save the memorized

Hi,

I tried different ways, but it didn´t find a working solution. I like to read the existing bookmarks, memorize them, delete from the original document and after that to concernate the mypdf.pdf with some other pdf. But when I try to tead fn into the stream I got an error that fn is used by another procces. editor.save(fn) allready cause an error.

What is the right way to do this? The best for me would to use a filestream (FileAccess.ReadWrite) for the whole operation. but the error was the same.

My last code...

Thanks, Daniel

friend sub(byRef thisbookmark as Aspose.Pdf.Kit.BookMark,byval pagescount as integer)

dim fn as String ="c:\mypdf.pdf"

Dim editor As New PdfBookmarkEditor

editor.bind(fn)

try

Dim thisbookmarkcollection As New Aspose.Pdf.Kit.Bookmarks

thisbookmarkcollection = editor.ExtractBookmarks()

For Each bookmark As Aspose.Pdf.Kit.Bookmark In thisbookmarkcollection

bookmark.Action = "GoTo"

bookmark.PageNumber = pagescount + bookmark.PageNumber

Next bookmark

thisbookmark.ChildItem = thisbookmarkcollection

editor.DeleteBookmarks()

editor.Save(FN)

editor = nothing

catch

editor = nothing

end try

Dim myStream As FileStream = New FileStream(FN, FileMode.Open, FileAccess.Read)

If myStream.CanRead Then

add2ExportObject(myStream, FN)

end if

end sub

Hi Daniel,

You’re trying to use the same file as input and output with PdfBookmarkEditor class. I would like to share with you that you can’t use the same file as input and output at the same time. Please try to save the output in a different file.

I’m sure this will resolve your issue. If you still find any problems, please do let us know.
Regards,