How to jump to same window having a column in Shiny using hyperlinks instead of a new window?

I created a Shiny app using pdf search where entering a word displays related sentences of that word from PDF file. Also, I created hyperlinks which give the page number of word available as output. However, by clicking it, I am going to a new window that shows the page of PDF. I want the page to be displayed on the right column with pdf as shown in the screenshot instead of opening on a new window.

Can someone please suggest a solution for this?

library(pdfsearch)
library(shiny)
library(DT)
library(tidyverse)
library(dplyr)



file <- system.file('pdf', 'intro.pdf', package = 'pdfsearch')



word_sentence <-function(word) {keyword_search(file,    
                                               keyword = word,
                                               path = TRUE)}




addResourcePath("pdf", "C:/Users/jack/Documents/shinyapp/www")



ui<- shinyUI(fluidPage(dashboardBody(
  img(src='spsimage.jpg', align = "left"),style = "padding-top:20px",
  
  br(),
  br(),
  br(),
  br(),
  br(),
  br(),
  fluidRow(
    
    
    column(width=6,style = "max-height: 90vh; overflow-y: auto;",
           h4("Search Results"), 
           wellPanel(
             textInput("inputString","Enter a word here",value=" "),
             tags$style("#mytext { white-space: pre-line; }"),
             DTOutput("mytext")
           )),
    column(width=6,style="max-height: 90vh; overflow-y: auto;",
           h5("PDF Document"),
           htmlOutput("pdfview")
    )
  )
) 
)
)


server <- function(input, output, session) {
  output$mytext <- renderDT({
    results <- word_sentence(input$inputString)
    results <- results %>% 
      select(line_text, page_num,line_num)%>%
      rename(Text = line_text,
             Page = page_num,
             Line=line_num)
    page_link<-paste0('pdf/call_center.pdf#page=',results$Page)
    results$Page<-paste0("<a href ='",page_link,"' target=\"pdfview\"",">",results$Page,"</a>")
    
    datatable(results,escape= FALSE,options=list(searching=FALSE))
    
  })
  
  output$pdfview<-renderUI({
    tags$iframe(id="displaypdf",style="height:1000px; width:100%",src="pdf/intro.pdf")
    
  })
  
}
 
shinyApp(ui,server)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.