2 回答

TA貢獻1951條經驗 獲得超3個贊
我這里有一個代碼圍欄,它使用免費的Adobe DC視圖SDK準確顯示了此功能。除非覆蓋本機瀏覽器查看器,否則無法控制 PDF 體驗。我示例的相關代碼如下。在我的示例中,PDF 是從另一個域獲取的,但“content”參數將接受解析為 PDF 內容的數組緩沖區的任何 Promise。您的PDF可以存儲在任何地方或動態創建,然后顯示在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貢獻1877條經驗 獲得超1個贊
我發現服務器正在使用水晶報告來生成PDF并“導出”它。它使用了一個函數,方法調用中的第三個參數是 。ExportToHttpResponse(...)
bool asAttachment
該參數被設置為 true。我將其更改為 false,并且響應開始設置為,并且上述顯示方法開始工作。inline
添加回答
舉報