Replies: 1
When a user (any user) logins to their My Account page and attempts to view an invoice (PDF), they get that error message (Error. Failed to Load PDF Document). Because of this, users can’t view the invoice/PDF from the front end.
To resolve this issue replace the following:
function wcpdf_pdf_headers( $filename, $mode = ‘inline’, $pdf = null ) {
switch ($mode) {
case ‘download’:
header(‘Content-Description: File Transfer’);
header(‘Content-Type: application/pdf’);
header(‘Content-Disposition: attachment; filename=”‘.$filename.'”‘);
header(‘Content-Transfer-Encoding: binary’);
header(‘Connection: Keep-Alive’);
header(‘Expires: 0’);
header(‘Cache-Control: must-revalidate, post-check=0, pre-check=0’);
header(‘Pragma: public’);
break;
case ‘inline’:
default:
header(‘Content-Type: application/pdf’);
header(‘Content-Disposition: inline; filename=”‘.$filename.'”‘);
break;
}
}
with the following:
function wcpdf_pdf_headers( $filename, $mode = ‘inline’, $pdf = null ) {
switch ($mode) {
case ‘download’:
header(‘Content-Description: File Transfer’);
header(‘Content-Type: application/pdf’);
header(‘Content-Disposition: attachment; filename=”‘.$filename.'”‘);
header(‘Content-Transfer-Encoding: binary’);
header(‘Connection: Keep-Alive’);
header(‘Expires: 0’);
header(‘Cache-Control: must-revalidate, post-check=0, pre-check=0’);
header(‘Pragma: public’);
header(‘HTTP/1.1 200 OK’);
break;
case ‘inline’:
default:
header(‘Content-Type: application/pdf’);
header(‘Content-Disposition: inline; filename=”‘.$filename.'”‘);
header(‘HTTP/1.1 200 OK’);
break;
}
}