We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

After merge nested bookmarks are duplicated

Hello to everyone at the support team,

im trying to merge some PDF files with nested bookmarks. The goal is to preserve the existing bookmark structure after the merge.

1. Merge two pdf files s1.pdf and s2.pdf to result.pdf
2. Create new bookmark for document s1.pdf and read existing bookmarks from s1.pdf and assign them as child bookmarks
3. Create new bookmark for document s2.pdf and read existing bookmarks from s2.pdf and assign them as child bookmarks
4. Save bookmarks

For more details see the attached test project.

Aspose.Pddf.dll Version 9.0.0.0
internal bugid#4414

In the result.pdf all nested bookmarks are duplicated. Very strange.

Best regards, Martin Pfeifer




The method Aspose.Pdf.Facades.BookmarkEditor.ExportBookmarksToXML() seems wrong.

Aspose.Pdf.Facades.BookmarkEditor be= new Aspose.Pdf.Facades.BookmarkEditor();
be.BindPdf( “c:\temp\s1.pdf”);
be.Aspose.Pdf.Facades.BookmarkEditor(“c:\temp\s1.xml”);

This produces the following xml

<?xml version="1.0" encoding="ISO8859-1"?>

cTagesordnung
Öffentlicher Teil:
Eröffnung der Sitzung
Genehmigung des Protokolls vom 27.02.2013
Mitteilungen der Verwaltung
Mitteilungen der Kämmerei
Anträge der Fraktionen
Anfragen an die Verwaltung

Eröffnung der Sitzung
Genehmigung des Protokolls vom 27.02.2013
Mitteilungen der Verwaltung
Mitteilungen der Kämmerei
Anträge der Fraktionen
Anfragen an die Verwaltung
Nichtöffentlicher Teil:
Eröffnung der Sitzung
Auftragsvergaben
Mitteilungen und Berichte

Eröffnung der Sitzung
Auftragsvergaben
Mitteilungen und Berichte
Öffentlicher Teil:
Teilnahme am Modellprojekt “Moderne Kommune”
Vereinbarung einer Städtepartnerschaft mit Strasburg, Frankreich
TLF 16
Neubau von Radwegen an den innerstädtischen Hauptverkehrsstraßen
Vorbereitung der 1000-Jahr-Feier in Norderlanden

Teilnahme am Modellprojekt “Moderne Kommune”
Vereinbarung einer Städtepartnerschaft mit Strasburg, Frankreich
TLF 16
Neubau von Radwegen an den innerstädtischen Hauptverkehrsstraßen
Vorbereitung der 1000-Jahr-Feier in Norderlanden



==> every bookmark with bookmark.parent != null is duplicated

Hi Martin,


Thanks for your inquiry. We are looking into the issue and will get back to you soon.

Best Regards,

m.pfeifer:
Aspose.Pdf.Facades.BookmarkEditor.ExportBookmarksToXML() seems wrong.

Aspose.Pdf.Facades.BookmarkEditor be= new Aspose.Pdf.Facades.BookmarkEditor();
be.BindPdf( “c:\temp\s1.pdf”);
be.Aspose.Pdf.Facades.BookmarkEditor(“c:\temp\s1.xml”);
Hi Caroline,

I have tested the scenario using Aspose.Pdf for .NET 9.0.0 where I have used the following code snippet with and as per my observations, the Bookmarks are properly being exported to XML file. For your reference, I have also attached the resultant XML generated over my end. Please note that I have exported bookmarks from s1.pdf file.

[C#]

Aspose.Pdf.Facades.PdfBookmarkEditor
be = new Aspose.Pdf.Facades.PdfBookmarkEditor();<o:p></o:p>

be.BindPdf("c:/pdftest/s1.pdf");

be.ExportBookmarksToXML(“c:\pdftest\Exported_bookmarks.xml”);

Hi Caroline,


I have observed that once PDF files are concatenated, you are creating bookmarks programmatically. However if you concatenate PDF files using Aspose.Pdf.Document class, you do not have to use this approach. Please take a look over following code snippet to concatenate PDF files and I have also attached the resultant PDF generated over my end.

[C#]

//open document<o:p></o:p>

Document document = new Document("c:/pdftest/s1.pdf");

Document document2 = new Document("c:/pdftest/s2.pdf");

document.Pages.Add(document2.Pages);

document.Save(“c:/pdftest/MergedFile.pdf”);

Hi Nayyer,

the solution with

document.Pages.Add(document2.Pages);

works in very simple examples. But we use the dll to concatenate about 60-100 pdf documents. To simplify navigation in the merged document a hierarchical bookmark structure ist very important.

Every document can be reached by a pdf bookmark. If a pdf document contains bookmarks the existing bookmarks must be childs of the pdf document bookmark.

  • bookmark document 1
    • existing bookmark 1 from document 1
    • existing bookmark 2 from document 1
    • existing bookmark 3 from document 1
    • existing bookmark 4 from document 1
  • bookmark document 2
    • existing bookmark 1 from document 2
    • existing bookmark 2 from document 2
    • existing bookmark 3 from document 2
    • existing bookmark 4 from document 2


I think this can’t be done with document.Pages.Add(document2.Pages);


Hi Nayyer,

i’m sorry - the Aspsoe.Pdf.Facades.PdfBookmarkEditor.ExportBookmarksToXML() works perfect.

Hi Martin,


Thanks for your feedback. I am afraid I am not clear whether your requirement has been accomplished or you need some further input form our side.

Best Regards,

Hi,

our problem is not solved.

The proposal from Nayyer to use

document.Pages.Add(document2.Pages)

is not possible for our project. I tried to explain the reason in my yesterday posting. In short - we need a hierarchical bookmark structure.

We need a solutuion to

  1. Concatenate many pdf files (up to 100)
  2. Create a hierarchical bookmark structure for better navigation like in
  • bookmark document 1
    • existing bookmark 1 from document 1
    • existing bookmark 2 from document 1
    • existing bookmark 3 from document 1
    • existing bookmark 4 from document 1
  • bookmark document 2
    • existing bookmark 1 from document 2
    • existing bookmark 2 from document 2
    • existing bookmark 3 from document 2
    • existing bookmark 4 from document 2


Thanks in advance, Martin Pfeifer




Hi Martin,


Thanks for sharing the details.

I
have tested the scenario and I am able to notice the same problem. For the sake
of correction, I have logged this problem as PDFNEWNET-36599 in
our issue tracking system. We will further look into the details of this
problem and will keep you updated on the status of correction. Please be
patient and spare us little time. We are sorry for this inconvenience.<o:p></o:p>

Hello,

i was completly wrong - the problem is caused from our code.

Now everything works fine.

Sorry for your inconvenience.

Martin Pfeifer


Hi Martin,


Thanks for the acknowledgement. We are glad to hear that you have managed to resolve the issue by updating the code. Like you shared the code earlier, can you please share the update code so that we can test the scenario at our end. It will help us in identifying the area which caused this problem.

The issues you have found earlier (filed as PDFNEWNET-36599) have been fixed in Aspose.Pdf for .NET 9.2.0.

The blog post for this release is created over this link


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.