@@ -780,14 +780,14 @@ internal virtual PdfDestination CopyDestination(PdfObject dest, IDictionary<PdfP
780
780
PdfDestination d = null ;
781
781
if ( dest . IsArray ( ) ) {
782
782
PdfObject pageObject = ( ( PdfArray ) dest ) . Get ( 0 ) ;
783
- foreach ( PdfPage oldPage in page2page . Keys ) {
784
- if ( oldPage . GetPdfObject ( ) == pageObject ) {
785
- // in the copiedArray old page ref will be correctly replaced by the new page ref
786
- // as this page is already copied
787
- PdfArray copiedArray = ( PdfArray ) dest . CopyTo ( toDocument , false , NullCopyFilter . GetInstance ( ) ) ;
788
- d = new PdfExplicitDestination ( copiedArray ) ;
789
- break ;
790
- }
783
+ //12.3.2.2 Explicit destinations
784
+ if ( pageObject . IsNumber ( ) ) {
785
+ //Handle remote and embedded destinations
786
+ d = CreateDestinationFromPageNum ( dest , toDocument ) ;
787
+ }
788
+ else {
789
+ //Handle all other destinations
790
+ d = CreateDestinationFromPageRef ( dest , page2page , toDocument , pageObject ) ;
791
791
}
792
792
}
793
793
else {
@@ -840,6 +840,23 @@ internal virtual PdfDictionary FillAndGetOcPropertiesDictionary() {
840
840
}
841
841
//\endcond
842
842
843
+ private PdfDestination CreateDestinationFromPageNum ( PdfObject dest , PdfDocument toDocument ) {
844
+ return new PdfExplicitDestination ( ( PdfArray ) dest . CopyTo ( toDocument , false , NullCopyFilter . GetInstance ( ) ) ) ;
845
+ }
846
+
847
+ private static PdfDestination CreateDestinationFromPageRef ( PdfObject dest , IDictionary < PdfPage , PdfPage > page2page
848
+ , PdfDocument toDocument , PdfObject pageObject ) {
849
+ foreach ( PdfPage oldPage in page2page . Keys ) {
850
+ if ( oldPage . GetPdfObject ( ) == pageObject ) {
851
+ // in the copiedArray old page ref will be correctly replaced by the new page ref
852
+ // as this page is already copied
853
+ PdfArray copiedArray = ( PdfArray ) dest . CopyTo ( toDocument , false , NullCopyFilter . GetInstance ( ) ) ;
854
+ return new PdfExplicitDestination ( copiedArray ) ;
855
+ }
856
+ }
857
+ return null ;
858
+ }
859
+
843
860
private bool IsEqualSameNameDestExist ( IDictionary < PdfPage , PdfPage > page2page , PdfDocument toDocument , PdfString
844
861
srcDestName , PdfArray srcDestArray , PdfPage oldPage ) {
845
862
PdfArray sameNameDest = ( PdfArray ) toDocument . GetCatalog ( ) . GetNameTree ( PdfName . Dests ) . GetNames ( ) . Get ( srcDestName
0 commit comments