Constructor
new View(params)
Example
let FoxitEmbed; // 通过script标签引入的全局变量
let embedView = new FoxitEmbed.View({
clientId: 'client_id',
divId: 'div_id',
});
Parameters:
| Name |
Type |
Description |
params |
Object
|
Properties
| Name |
Type |
Attributes |
Description |
clientId |
string
|
|
客户端ID。您可以从福昕开发者控制台获取客户端ID。 |
divId |
string
|
|
渲染的元素的ID。 |
locale |
string
|
<optional>
|
语言环境。支持的语言环境有'zh-CN'、'en-US'。默认值为浏览器语言。 |
|
Members
pdfDoc :PDFDoc|undefined
- Description:
PDFDoc实例
Type:
Methods
GetReadAloud()
- Description:
- Deprecated:
addAnnotationIcon()
- Description:
- 添加annotation的图标,目前仅支持stamp类型。
- Deprecated:
(async) addFontMaps(fontMaps) → {Promise.<void>}
- Description:
Example
let embedView; // View实例
embedView.addFontMaps([{
nameMatches: [
/(helvetica)|(helveticabold)|(helveticaoblique)/,
],
name: "helvetica",
glyphs: [
{
bold: 400,
flags: FoxitEmbed.Constants.Font_Styles.FixedPitch,
url: 'NotoSans-Bold.ttf.brotli',
isBrotli: true,
},
{
bold: -1,
flags: FoxitEmbed.Constants.Font_Styles.FixedPitch,
url: 'NotoSans-Regular.ttf'
},
],
charsets:[FoxitEmbed.Constants.Font_Charset.ANSI],
}])
Parameters:
| Name |
Type |
Description |
fontMaps |
Array.<FontMap>
|
字体映射数组 |
Returns:
-
Type
-
Promise.<void>
addListener(event, callback) → {function}
- Description:
Example
let embedView; // View实例
embedView.addListener('Annotation_Clicked', (annotationId) => {
console.log('Annotation_Clicked', annotationId);
});
Parameters:
| Name |
Type |
Description |
event |
string
|
事件名称。请参考 EventNames 中的值 |
callback |
function
|
事件回调函数 |
Returns:
用于移除事件监听的函数
-
Type
-
function
addWatermark()
- Description:
- Deprecated:
(async) destroy() → {Promise.<void>}
- Description:
- 销毁当前的Viewer实例。在多次调用`new FoxitEmbed.View()`进行初始化实例的使用场景中,请确保在不再需要实例时调用此方法,以释放资源。
Returns:
-
Type
-
Promise.<void>
getAnnotationManager()
- Description:
- Deprecated:
getBookmarks()
- Description:
- Deprecated:
getCurrentPage()
- Description:
- Deprecated:
getPageZoom()
- Description:
- Deprecated:
- Description:
Returns:
朗读管理器实例
-
Type
-
ReadManager
getSearchManager(pattern, flagsopt, startPageIndexopt, endPageIndexopt) → {SearchManager}
- Description:
Parameters:
| Name |
Type |
Attributes |
Default |
Description |
pattern |
string
|
|
|
被搜索的关键字 |
flags |
number
|
<optional>
|
0
|
搜索标志。以下标志可以单独使用或组合使用。
0:没有特殊的搜索选项。
1:匹配大小写。
2:全词匹配。
|
startPageIndex |
number
|
<optional>
|
0
|
开始搜索的页面索引 |
endPageIndex |
number
|
<optional>
|
pageCount-1
|
结束搜索的页面索引 |
Returns:
搜索管理器实例
-
Type
-
SearchManager
getUserName()
- Description:
- Deprecated:
gotoLocation()
- Description:
- Deprecated:
initAnnotationIcons()
- Description:
- 初始化annotation的图标,目前仅支持stamp类型。该函数设置后,默认的标准图章将被替换。
- Deprecated:
openBookmark()
- Description:
- Deprecated:
- Description:
Parameters:
| Name |
Type |
Description |
feature |
string
|
功能值。可选值如下:
Bookmark:书签面板
Search:搜索面板
Comment:注释面板
|
(async) previewFile(params, optionsopt) → {Promise.<PDFDoc>}
- Description:
Example
let embedView; // View实例
let pdfDoc = await embedView.previewFile({
content: 'https://example.com/sample.pdf',
});
Parameters:
| Name |
Type |
Attributes |
Description |
params |
Object
|
|
预览文件参数
Properties
| Name |
Type |
Attributes |
Description |
content |
View.PreviewFileContent
|
|
PDF文件的URL或文件对象 |
metaData |
Object
|
<optional>
|
PDF文件的元数据
Properties
| Name |
Type |
Attributes |
Description |
fileName |
string
|
<optional>
|
PDF文件的名称 |
|
fontInfoPath |
string
|
<optional>
|
字体信息csv文件的URL路径。如何需要使用 View#addFontMaps 方法添加自定义字体,则必须设置此参数。
使用方法请参考:如何使用自定义字体。 |
|
options |
Object
|
<optional>
|
配置项
Properties
| Name |
Type |
Attributes |
Default |
Description |
embedMode |
string
|
<optional>
|
FULL_WINDOW
|
模式,可选值如下:
1. FULL_WINDOW:全屏窗口。PDF阅读器显示在浏览器窗口的全屏中,方便用户阅读和操作文档。
2. SIZED_CONTAINER:指定尺寸容器。PDF阅读器嵌入指定大小的容器中(需要指定宽度和高度)。
3. IN_LINE:内联显示。PDF阅读器嵌入在网页内容的中间。在此模式下,所有PDF页面将同时显示。您需要在<div>标记中指定嵌入查看器的宽度,查看器将根据PDF页面的宽度和页数自动调整大小和长度(指定宽度,而不是高度)。
4. LIGHT_BOX:弹出框。PDF阅读器在页面上弹出一个窗口,您可以关闭该窗口并返回上一页。
|
defaultViewMode |
string
|
<optional>
|
CONTINUOUS
|
默认视图模式。可选值如下:
1. CONTINUOUS:连续页面。
2. FIT_WIDTH:适合宽度。
3. FIT_PAGE:适合页面。
4. SINGLE_PAGE:单页。
5. HORIZONTAL_PAGE:横向页面。
|
showToolControls |
boolean
|
<optional>
|
true
|
Deprecated: 请使用 View#setUIGroupVisible 方法代替。 |
showLeftHandPanel |
boolean
|
<optional>
|
true
|
Deprecated: 请使用 View#setUIGroupVisible 方法代替。 |
showDownloadPDF |
boolean
|
<optional>
|
true
|
Deprecated: 请使用 View#setUIElementsVisible 方法代替。 |
showPrintPDF |
boolean
|
<optional>
|
true
|
Deprecated: 请使用 View#setUIElementsVisible 方法代替。 |
theme |
Object
|
<optional>
|
{}
|
Deprecated: 请使用 View#setTheme 方法代替。 |
showIcon |
string
|
<optional>
|
''
|
Deprecated: 请使用 View#setCustomLogo 方法代替。 |
|
Returns:
-
Type
-
Promise.<PDFDoc>
removeAnnotationIcon()
- Description:
- 移除自定义的annotation的图标,目前仅支持stamp类型。
- Deprecated:
search()
- Description:
- 用于在所有的嵌入模式中,以编程方式搜索PDF中的文本。
- Deprecated:
setCustomLogo(logo) → {void}
- Description:
Parameters:
| Name |
Type |
Description |
logo |
Object
|
Logo配置对象
Properties
| Name |
Type |
Description |
url |
string
|
Logo的URL |
|
Returns:
-
Type
-
void
setCustomProgress(progress) → {void}
- Description:
Parameters:
| Name |
Type |
Description |
progress |
Object
|
进度条配置对象
Properties
| Name |
Type |
Attributes |
Description |
url |
string
|
|
进度条的URL |
text |
string
|
<optional>
|
加载文案 |
|
Returns:
-
Type
-
void
- Description:
Example
let embedView; // View实例
embedView.setCustomToolbarButton([
{
position: 'right',
type: 'button',
icon: 'https://www.example.com/icon.svg',
tooltip: 'tooltip',
onClick: () => {
console.log('on click');
},
},
]);
Parameters:
Returns:
-
Type
-
void
setTheme(theme)
- Description:
Parameters:
| Name |
Type |
Description |
theme |
Object
|
主题配置对象
Properties
| Name |
Type |
Attributes |
Default |
Description |
primaryColor |
string
|
<optional>
|
#F58220
|
主题色 |
secondaryColor |
string
|
<optional>
|
#F4F4F4
|
次要颜色 |
|
setUIElementsVisible(elements, visible) → {void}
- Description:
- 设置UI功能是否可见。在使用此函数之前,请确保已调用过previewFile,否则部分功能的设置将被覆盖。
Example
let embedView; // View实例
embedView.setUIElementsVisible([FoxitEmbed.Constants.Features.UndoRedo], false);
Parameters:
| Name |
Type |
Description |
elements |
Array.<string>
|
功能值。请参考 Constants.Features 中的值 |
visible |
boolean
|
是否可见 |
Returns:
-
Type
-
void
setUIGroupVisible(group, visible) → {void}
- Description:
- 设置UI组是否可见。在使用此函数之前,请确保已调用过previewFile,否则部分功能的设置将被覆盖。
Example
let embedView; // View实例
embedView.setUIGroupVisible([FoxitEmbed.Constants.FeatureGroup.Toolbar], false);
Parameters:
Returns:
-
Type
-
void
setUserName()
- Description:
- Deprecated:
(async) updatePreference(preference) → {Promise.<void>}
- Description:
Parameters:
| Name |
Type |
Description |
preference |
Object
|
偏好设置对象
Properties
| Name |
Type |
Description |
beMarkupWithSelectedText |
boolean
|
在添加文本标记注释后,是否使用所选文本作为标记内容 |
|
Returns:
-
Type
-
Promise.<void>
zoomTo()
- Description:
- 缩放当前的Viewer。该函数不能用于inline嵌入模式。
- Deprecated:
Type Definitions
PreviewFileContent
- Description:
PDF文件的URL或文件对象
Type:
-
string
|
File
|
Blob
|
ArrayBuffer
|
TypedArray
|
DataView