Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

275
Views
How to open pdf in a popup in php

Basically I am using BSK PDF Manager Plugin in Wordpress and want to open the the pdfs in a popup when someone click them.

 
 /* This is the href code of the plugin and what I tried to open 
 
$pdf_title_str = '<a href="'.esc_url($file_url).'"'.esc_attr($open_target_str.$nofollow_tag_str).'  title="'.esc_attr($pdf_item_obj_title).'" class="bsk-pdfm-pdf-link-for-title pdf-id-'.esc_attr($pdf_item_obj->id).'">'.$pdf_title_str.'</a>';

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

<?php

$filePath = 'file/example.pdf';

if (!file_exists($filePath)) {
    echo "The file $filePath does not exist";
    die();
}

$filename="example.pdf";
header('Content-type:application/pdf');
header('Content-disposition: inline; filename="'.$filename.'"');
header('content-Transfer-Encoding:binary');
header('Accept-Ranges:bytes');

readfile($filePath);
?>

you can try with this code

about 4 years ago · Juan Pablo Isaza Report

0

I would go with what @CBroe suggested: update your code with target to open the link (your PDF) in a new window/tab:

$pdf_title_str = '<a target="_blank" href="' . esc_url($file_url) . '"' . esc_attr($open_target_str . $nofollow_tag_str) . '  title="' . esc_attr($pdf_item_obj_title) . '" class="bsk-pdfm-pdf-link-for-title pdf-id-' . esc_attr($pdf_item_obj->id) . '">' . $pdf_title_str . '</a>';
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!