Closed Bug 1767219 Opened 3 years ago Closed 3 years ago

pdf blob does not save

Categories

(Firefox :: PDF Viewer, defect)

Firefox 99
defect

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: santiago.toral, Unassigned, NeedInfo)

Details

(Keywords: regression, regressionwindow-wanted)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0

Steps to reproduce:

Hello, I have a php program than makes a pdf wit mpdf library. I send an ajax call in javascript to the php service and when I get the blob results the pdf displays ok in the viewer but it doen't save the pdf. The code may be something like this:

$.ajax({
type: 'POST',
url: 'http://localhost/reports_mpdf/reports/report_assessment.php',
responseType: "blob",
data: {
"reportObject": JSON.stringify(<?php echo json_encode($reportObject->jsonSerialize()); ?>),
"userid": <?php echo $userid; ?>
},
xhrFields: {
responseType: 'blob'
},
success: function (response, status, xhr) {
var a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";

            var blob = new Blob([response], {type: 'application/pdf'});
            blob.name = "report_<?php echo $userid; ?>.pdf";
            const urlFile = URL.createObjectURL(blob);
            console.log(urlFile);
            window.open(urlFile);
            
            a.href = urlFile;
            a.download = "<?php echo $name." ".$surname; ?>.pdf";
            a.click();
            window.URL.revokeObjectURL(urlFile);
        },
        error: function(xhr, status, error) {
            var err = eval("(" + xhr.responseText + ")");
            console.log(xhr.responseText);
        }
    });  

Actual results:

I try to save the pdf blob but nothing happens. I also have a warning like this:
Warning: Invalid absolute docBaseUrl: "blob:http://localhost...

Expected results:

In previous versions of firefox I had no problems with this code. The pdf was saved without any problem.

The Bugbug bot thinks this bug should belong to the 'Firefox::PDF Viewer' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → PDF Viewer

It isn't a pdf.js issue but more likely a file handling one.

Component: PDF Viewer → File Handling

(In reply to Santiago from comment #0)

Hello, I have a php program than makes a pdf wit mpdf library. I send an ajax call in javascript to the php service and when I get the blob results the pdf displays ok in the viewer but it doen't save the pdf.

Are your Firefox settings configured to open PDFs directly in Firefox?

Flags: needinfo?(santiago.toral)

Nop, Adobe Acrobat DC is the predetermined pdf viewer. I open the pdf in Firefox with JS. I think the bug is in the Firefox pdf viewer.
Thanks.

Flags: needinfo?(santiago.toral)

The severity field is not set for this bug.
:Gijs, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(gijskruitbosch+bugs)

(In reply to Santiago from comment #4)

Nop, Adobe Acrobat DC is the predetermined pdf viewer. I open the pdf in Firefox with JS. I think the bug is in the Firefox pdf viewer.
Thanks.

I'm confused why the PDF would open in Firefox at all if your Firefox settings indicate that your preferred PDF viewer is Adobe, but OK. Can you link to a live / website example that reproduces this issue?

Component: File Handling → PDF Viewer
Flags: needinfo?(gijskruitbosch+bugs) → needinfo?(santiago.toral)

Oh, and from reading the code, one tangential question: if you temporarily comment out the revokeObjectURL call, does the save operation start working?

(In reply to Santiago from comment #0)

Expected results:

In previous versions of firefox I had no problems with this code. The pdf was saved without any problem.

Could you try to find a regression range using https://mozilla.github.io/mozregression/?

QA Whiteboard: [qa-regression-triage]

We don't have enough information to proceed.

Status: UNCONFIRMED → RESOLVED
Closed: 3 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.