Force navigator to open . pdf

Asked

Viewed 107 times

0

I need to open a . pdf file directly in the browser. The problem is that this file is generated from an external link and already comes with download option.

I’m trying to open it this way:

<?php
$file = $_GET['arquivo']; // aqui to pegando o link por onde o arquivo é gerado
    header('Content-Disposition: inline; filename="'.$file.'"');
    readfile("{$file}");
  ?> 

But of the PDF reading error.

Follow the link to the file I need to open: https://boletoonline.caixa.gov.br/ecobranca/SIGCB/imprimir/0934772/14000000110730423

Displays the following errors:

Warning: readfile(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in /home/suains55/public_html/webservicecaixa/view.php on line 8

Warning: readfile(): Failed to enable crypto in /home/suains55/public_html/webservicecaixa/view.php on line 8

Warning: readfile(https://boletoonline.caixa.gov.br/ecobranca/SIGCB/imprimir/0934772/14000000110730423): failed to open stream: operation failed in /home/suains55/public_html/webservicecaixa/view.php on line 8

Can anyone help?

1 answer

-1

Buddy, try this way:

header('Cache-Control: public');
header('Content-type: application/pdf');
$ativar_ssl=array(
    "ssl"=>array(
        "verify_peer"=>false,
        "verify_peer_name"=>false,
    ),
);

$resposta = base64_encode(file_get_contents("https://boletoonline.caixa.gov.br/ecobranca/SIGCB/imprimir/0934772/14000000110730423", false, stream_context_create($ativar_ssl)));

echo base64_decode($resposta);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.