在同一个请求中发送HTML和PDF文件是否正确?

I have to send a PDF to the user, but this PDF is generated by a command line tool executed from PHP (server side). When the user clicks on a link this is executed:

window.open($(this).attr('href'), "mywindow",
            "height=600,width=600,menubar=0,location=0,status=0,toolbar=0");

The new window is generated from PHP:

<?php
ob_start();
?>
 Web page contents to be printed
<?php
$content = ob_get_contents();
ob_end_flush();

$input = "/tmp/input.html";
$output = "/tmp/output.pdf";

file_put_contents($input, $content);
create_pdf($input, $output);

$state = filesize($output);
if ($state !== FALSE && $state != 0) {
    header('Content-Type: application/pdf');
    header('Content-Disposition: inline; filename=file.pdf');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($output));

    ob_clean();
    flush();
    @readfile($output);
}

unlink($input);
unlink($output);

Why this? Because if there is a problem generating the PDF file it will not be sent, but the equivalent HTML file will be rendered (if stament) and if there is a problem sending the PDF (it occurs sometimes) the user will have a printable HTML alternative.

I've tested this on chrome and it works perfect (shows the inline PDF when it has been generated or shows the equivalent webpage when it's not generated). The Firefox I have doesn't support inline PDF (no plugin) so it just ask the user to download the PDF and closes the window (expected result).

My doubt is if this way to generate an alternative to PDF is valid or it could be "banned" in future versions?

You can send any content you like from any URL provided that the headers returned to the client are appropriate for the content.