C# Aspose XYZExplicitDestination.CreateDestination书签不’;我不为第一个工作

C# Aspose XYZExplicitDestination.CreateDestination书签不’;我不为第一个工作,c#,.net,aspose,aspose.pdf,C#,.net,Aspose,Aspose.pdf,我在pdf中添加了一些书签,如果我使用GoToAction添加,它确实可以工作,但当我使用XYZExplicitDestination时,它不会工作(我想使用它来避免缩放更改) 因此,这篇文章适用于所有页面: string dataDir = "C:\\Whatever"; // Open document Document pdfDocument = new Document(dataDir + "filename.pdf");

我在pdf中添加了一些书签,如果我使用GoToAction添加,它确实可以工作,但当我使用XYZExplicitDestination时,它不会工作(我想使用它来避免缩放更改)

因此,这篇文章适用于所有页面:

    string dataDir = "C:\\Whatever";

    // Open document
    Document pdfDocument = new Document(dataDir + "filename.pdf");

    // Create a parent bookmark object
    OutlineItemCollection pdfOutline = new OutlineItemCollection(pdfDocument.Outlines);
    pdfOutline.Action = new GoToAction(pdfDocument.Pages[1]);
    pdfOutline.Title = "Parent Bookmark - Page 1";

    // Create a child bookmark object
    OutlineItemCollection pdfChildOutline = new OutlineItemCollection(pdfDocument.Outlines);
    pdfChildOutline.Title = "Child Outline - Page 1";
    pdfChildOutline.Action = new GoToAction(pdfDocument.Pages[1]);

    OutlineItemCollection pdfChildOutline3 = new OutlineItemCollection(pdfDocument.Outlines);
    pdfChildOutline3.Title = "Child Outline page 3";
    pdfChildOutline3.Action = new GoToAction(pdfDocument.Pages[3]);

    // Add child bookmark in parent bookmark's collection
    pdfOutline.Add(pdfChildOutline);
    pdfOutline.Add(pdfChildOutline3);

    // Add parent bookmark in the document's outline collection.
    pdfDocument.Outlines.Add(pdfOutline);

    dataDir = dataDir + "AddChildBookmark_out.pdf";
    // Save output
    pdfDocument.Save(dataDir);
但这一条不适用于第一个书签:

字符串dataDir=“C:\Whatever”

知道为什么吗?这只是第一个父母和第一个孩子,那些不起作用的


我使用的版本是19.4.0.0。如果我们使用pdfDocument.Pages[n].MediaBox.Height,最新版本(21.3.0)也会出现这种情况,问题就解决了

有关更多信息:


我们相信您已经在Aspose.PDF论坛()上发布了类似的查询。我们将很快作出回应。这是Asad Ali,我是Aspose的开发者福音传道者。
    // Open document
    Document pdfDocument = new Document(dataDir + "Filename.pdf");

    // Create a parent bookmark object
    OutlineItemCollection pdfOutline = new OutlineItemCollection(pdfDocument.Outlines);
    pdfOutline.Destination = new XYZExplicitDestination(0, 0, 0, 1); //Sets the inherit zoom for the bookmarks for contents
    pdfOutline.Title = "Parent Bookmark - Page 1";

    // Create a child bookmark object
    OutlineItemCollection pdfChildOutline = new OutlineItemCollection(pdfDocument.Outlines);
    pdfChildOutline.Title = "Child Outline - Page 1";
    pdfChildOutline.Destination = new XYZExplicitDestination(0, 0, 0, 1); //Sets the inherit zoom for the bookmarks for contents

    OutlineItemCollection pdfChildOutline3 = new OutlineItemCollection(pdfDocument.Outlines);
    pdfChildOutline3.Title = "Child Outline page 3";
    pdfChildOutline3.Destination = new XYZExplicitDestination(2, 0, 0, 1); //Sets the inherit zoom for the bookmarks for contents


    // Add child bookmark in parent bookmark's collection
    pdfOutline.Add(pdfChildOutline);
    pdfOutline.Add(pdfChildOutline3);

    // Add parent bookmark in the document's outline collection.
    pdfDocument.Outlines.Add(pdfOutline);

    dataDir = dataDir + "AddChildBookmark_out.pdf";
    // Save output
    pdfDocument.Save(dataDir);