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).'" >'.$pdf_title_str.'</a>';
CodePudding user response:
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) . '" >' . $pdf_title_str . '</a>';
CodePudding user response:
<?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