- Mark as New
- Bookmark
- Subscribe
- Permalink
- Email to a Friend
- Report Inappropriate Content
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Email to a Friend
- Report Inappropriate Content
Question or Problem Statement:
One of our customers gets the quote template pdf file from Zuora by REST API and then inserts the pdf file to quote attachment object, but when he click the file link to view the pdf file, the error "Failed to load PDF document" occurred and this error only encountered in Chrome, Firefox worked well.
Solution:
We checked the customer's code:
http = new Http();
req = new HttpRequest();
//same authorization we set up earlier, we can reuse it
req.setHeader('Authorization', authorizationHeader);
req.setEndpoint(previewAttachmentURL); //the URL Zuora responds with upon success
req.setMethod('GET');
req.setHeader('Content-Type', 'application/pdf');
req.setTimeout(80000);
req.setCompressed(true); //I've tried both true and false here.
res = http.send(req);
Blob zuorasPDF = res.getBodyAsBlob();
Attachment zPDF = new Attachment();
zPDF.Name = Quote.Name + '.pdf';
zPDF.ContentType = 'pdf';
zPDF.IsPrivate = false;
zPDF.ParentId = Quote.zqu__Opportunity__c;
zPDF.Body = zuorasPDF;
insert zPDF;
The contentType value "pdf" is not correct, there is one limitation for chrome pdf review, but Firefox was more flexible in handling. So the error only occurred in Chrome.
To fix this issue, change the contentType value to 'application/pdf' or just do not set the contentType value for the attachment record.
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Email to a Friend
- Report Inappropriate Content
Question or Problem Statement:
One of our customers gets the quote template pdf file from Zuora by REST API and then inserts the pdf file to quote attachment object, but when he click the file link to view the pdf file, the error "Failed to load PDF document" occurred and this error only encountered in Chrome, Firefox worked well.
Solution:
We checked the customer's code:
http = new Http();
req = new HttpRequest();
//same authorization we set up earlier, we can reuse it
req.setHeader('Authorization', authorizationHeader);
req.setEndpoint(previewAttachmentURL); //the URL Zuora responds with upon success
req.setMethod('GET');
req.setHeader('Content-Type', 'application/pdf');
req.setTimeout(80000);
req.setCompressed(true); //I've tried both true and false here.
res = http.send(req);
Blob zuorasPDF = res.getBodyAsBlob();
Attachment zPDF = new Attachment();
zPDF.Name = Quote.Name + '.pdf';
zPDF.ContentType = 'pdf';
zPDF.IsPrivate = false;
zPDF.ParentId = Quote.zqu__Opportunity__c;
zPDF.Body = zuorasPDF;
insert zPDF;
The contentType value "pdf" is not correct, there is one limitation for chrome pdf review, but Firefox was more flexible in handling. So the error only occurred in Chrome.
To fix this issue, change the contentType value to 'application/pdf' or just do not set the contentType value for the attachment record.