@@ -1931,46 +1931,51 @@ protected internal virtual void ApplyRelativePositioningTranslation(bool reverse
19311931 }
19321932
19331933 protected internal virtual void ApplyDestination ( PdfDocument document ) {
1934- Object destination = this . GetProperty < Object > ( Property . DESTINATION ) ;
1935- if ( destination == null ) {
1934+ ICollection < Object > destinations = this . GetProperty < ICollection < Object > > ( Property . DESTINATION ) ;
1935+ if ( destinations == null ) {
19361936 return ;
19371937 }
1938- String destinationName = null ;
1939- PdfDictionary linkActionDict = null ;
1940- if ( destination is String ) {
1941- destinationName = ( String ) destination ;
1942- }
1943- else {
1944- if ( CHECK_TUPLE2_TYPE . GetType ( ) . Equals ( destination . GetType ( ) ) ) {
1945- // 'If' above is the only autoportable way it seems
1946- Tuple2 < String , PdfDictionary > destTuple = ( Tuple2 < String , PdfDictionary > ) destination ;
1947- destinationName = destTuple . GetFirst ( ) ;
1948- linkActionDict = destTuple . GetSecond ( ) ;
1938+ foreach ( Object destination in destinations ) {
1939+ String destinationName = null ;
1940+ PdfDictionary linkActionDict = null ;
1941+ if ( destination == null ) {
1942+ continue ;
19491943 }
1950- }
1951- if ( destinationName != null ) {
1952- int pageNumber = occupiedArea . GetPageNumber ( ) ;
1953- if ( pageNumber < 1 || pageNumber > document . GetNumberOfPages ( ) ) {
1954- ILogger logger = ITextLogManager . GetLogger ( typeof ( iText . Layout . Renderer . AbstractRenderer ) ) ;
1955- String logMessageArg = "Property.DESTINATION, which specifies this element location as destination, see ElementPropertyContainer.setDestination." ;
1956- logger . LogWarning ( MessageFormatUtil . Format ( iText . IO . Logs . IoLogMessageConstant . UNABLE_TO_APPLY_PAGE_DEPENDENT_PROP_UNKNOWN_PAGE_ON_WHICH_ELEMENT_IS_DRAWN
1957- , logMessageArg ) ) ;
1958- return ;
1944+ if ( destination is String ) {
1945+ destinationName = ( String ) destination ;
1946+ }
1947+ else {
1948+ if ( CHECK_TUPLE2_TYPE . GetType ( ) . Equals ( destination . GetType ( ) ) ) {
1949+ // 'If' above is the only autoportable way it seems
1950+ Tuple2 < String , PdfDictionary > destTuple = ( Tuple2 < String , PdfDictionary > ) destination ;
1951+ destinationName = destTuple . GetFirst ( ) ;
1952+ linkActionDict = destTuple . GetSecond ( ) ;
1953+ }
1954+ }
1955+ if ( destinationName != null ) {
1956+ int pageNumber = occupiedArea . GetPageNumber ( ) ;
1957+ if ( pageNumber < 1 || pageNumber > document . GetNumberOfPages ( ) ) {
1958+ ILogger logger = ITextLogManager . GetLogger ( typeof ( iText . Layout . Renderer . AbstractRenderer ) ) ;
1959+ String logMessageArg = "Property.DESTINATION, which specifies this element location as destination, " + "see ElementPropertyContainer.setDestination." ;
1960+ logger . LogWarning ( MessageFormatUtil . Format ( iText . IO . Logs . IoLogMessageConstant . UNABLE_TO_APPLY_PAGE_DEPENDENT_PROP_UNKNOWN_PAGE_ON_WHICH_ELEMENT_IS_DRAWN
1961+ , logMessageArg ) ) ;
1962+ return ;
1963+ }
1964+ PdfArray array = new PdfArray ( ) ;
1965+ array . Add ( document . GetPage ( pageNumber ) . GetPdfObject ( ) ) ;
1966+ array . Add ( PdfName . XYZ ) ;
1967+ array . Add ( new PdfNumber ( occupiedArea . GetBBox ( ) . GetX ( ) ) ) ;
1968+ array . Add ( new PdfNumber ( occupiedArea . GetBBox ( ) . GetY ( ) + occupiedArea . GetBBox ( ) . GetHeight ( ) ) ) ;
1969+ array . Add ( new PdfNumber ( 0 ) ) ;
1970+ document . AddNamedDestination ( destinationName , array . MakeIndirect ( document ) ) ;
1971+ }
1972+ bool isPdf20 = document . GetPdfVersion ( ) . CompareTo ( PdfVersion . PDF_2_0 ) >= 0 ;
1973+ if ( linkActionDict != null && isPdf20 && document . IsTagged ( ) ) {
1974+ // Add structure destination for the action for tagged pdf 2.0
1975+ PdfStructElem structElem = GetCurrentStructElem ( document ) ;
1976+ PdfStructureDestination dest = PdfStructureDestination . CreateFit ( structElem ) ;
1977+ linkActionDict . Put ( PdfName . SD , dest . GetPdfObject ( ) ) ;
19591978 }
1960- PdfArray array = new PdfArray ( ) ;
1961- array . Add ( document . GetPage ( pageNumber ) . GetPdfObject ( ) ) ;
1962- array . Add ( PdfName . XYZ ) ;
1963- array . Add ( new PdfNumber ( occupiedArea . GetBBox ( ) . GetX ( ) ) ) ;
1964- array . Add ( new PdfNumber ( occupiedArea . GetBBox ( ) . GetY ( ) + occupiedArea . GetBBox ( ) . GetHeight ( ) ) ) ;
1965- array . Add ( new PdfNumber ( 0 ) ) ;
1966- document . AddNamedDestination ( destinationName , array . MakeIndirect ( document ) ) ;
1967- }
1968- bool isPdf20 = document . GetPdfVersion ( ) . CompareTo ( PdfVersion . PDF_2_0 ) >= 0 ;
1969- if ( linkActionDict != null && isPdf20 && document . IsTagged ( ) ) {
1970- // Add structure destination for the action for tagged pdf 2.0
1971- PdfStructElem structElem = GetCurrentStructElem ( document ) ;
1972- PdfStructureDestination dest = PdfStructureDestination . CreateFit ( structElem ) ;
1973- linkActionDict . Put ( PdfName . SD , dest . GetPdfObject ( ) ) ;
19741979 }
19751980 DeleteProperty ( Property . DESTINATION ) ;
19761981 }
0 commit comments