2 回答

TA貢獻(xiàn)1951條經(jīng)驗(yàn) 獲得超3個(gè)贊
我這里有一個(gè)代碼圍欄,它使用免費(fèi)的Adobe DC視圖SDK準(zhǔn)確顯示了此功能。除非覆蓋本機(jī)瀏覽器查看器,否則無法控制 PDF 體驗(yàn)。我示例的相關(guān)代碼如下。在我的示例中,PDF 是從另一個(gè)域獲取的,但“content”參數(shù)將接受解析為 PDF 內(nèi)容的數(shù)組緩沖區(qū)的任何 Promise。您的PDF可以存儲在任何地方或動態(tài)創(chuàng)建,然后顯示在HTML頁面中。
document.addEventListener("adobe_dc_view_sdk.ready", function () {
/*
The clientId is tied to a specific domain. To display a PDF hosted
on a different domain using the Adobe View SDK, we need to fetch the file
first then pass it to the "content" parameter as a Promise.
*/
fetch("https://documentcloud.adobe.com/view-sdk-demo/PDFs/Bodea Brochure.pdf")
.then((res) => res.blob())
.then((blob) => {
var adobeDCView = new AdobeDC.View({
// This clientId can be used for any CodePen example
clientId: "YOUR_CLIENT_ID",
// The id of the container for the PDF Viewer
divId: "adobe-dc-view"
});
adobeDCView.previewFile(
{
// The file content
content: { promise: Promise.resolve(blob.arrayBuffer()) },
metaData: { fileName: "Bodea Brochure.pdf" }
},
{
embedMode: "FULL_WINDOW", // possible values are "FULL_WINDOW", "SIZED_CONTAINER" and "IN_LINE"
defaultViewMode: "FIT_WIDTH", // possible values are "FIT_WIDTH" and "FIT_PAGE"
showDownloadPDF: true,
showPrintPDF: true,
showLeftHandPanel: true,
showAnnotationTools: true
}
);
});
});

TA貢獻(xiàn)1877條經(jīng)驗(yàn) 獲得超1個(gè)贊
我發(fā)現(xiàn)服務(wù)器正在使用水晶報(bào)告來生成PDF并“導(dǎo)出”它。它使用了一個(gè)函數(shù),方法調(diào)用中的第三個(gè)參數(shù)是 。ExportToHttpResponse(...)
bool asAttachment
該參數(shù)被設(shè)置為 true。我將其更改為 false,并且響應(yīng)開始設(shè)置為,并且上述顯示方法開始工作。inline
添加回答
舉報(bào)