找回密码
 快速注册
搜索
查看: 71|回复: 4

pdf.js Current View获得url param页数和视口坐标

[复制链接]

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2022-6-22 00:42 |阅读模式
本帖最后由 hbghlyj 于 2023-5-3 22:45 编辑

500px-Mollifier_Illustration.svg[1].png 打开右上角工具栏的书签图标指向的链接,例如原网址是
.../DynamicsLectureNotes2022_updated.pdf
新网址变成
.../DynamicsLectureNotes2022_updated.pdf#page=59&zoom=310,139,339
红色部分是当前视图的信息.
page是页数.
zoom的第一个参数是页面缩放比例(比如100代表100%, 120代表120%), 第二、三个参数是视窗的坐标,见initial zoom parameter for html pdf object
注: 火狐内置的工具栏的书签样子的svg的url为: resource://pdf.js/web/images/toolbarButton-bookmark.svg

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2022-8-25 12:41
Customize the PDF viewer when embedding a PDF
If you want to embed a PDF document on your website you can use an iFrame. The browser will automatically render a PDF viewer.

Google Chrome, Firefox and Safari accept some parameters to customize the viewer. Add the parameters as part of the url fragment (after the #). Multiple parameters can be separated by &.

<iframe src="/path/to/document.pdf#toolbar=0"></iframe>

The following parameters are supported:
ParameterValueDescriptionSupport
toolbar1, 0Show or hide the toolbarChrome
viewFitV, FitH, FitChange the zoom level to fit (vertical, horizontal or both)Chrome
zoomnumberSet a specific zoom level in % (example: 300)Chrome, FireFox
pagenumberSet initial position to a specific page (example: 2)Chrome, FireFox, Safari
nameddeststringSet initial position to a named destination (like a heading)Chrome

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2022-9-13 02:44
zoom第二、三个参数是视窗的坐标

第二个参数是:视窗右边界到页面右边界的距离(如果是正数,代表视窗右边界在页面右边界的右边,这也是通常情况下页面右边界在视窗内; 如果是负数,代表视窗右边界在页面右边界的左边,这时会有横向滚动条)
第三个参数是:视窗上边界到页面下边界的距离(只能为正数,因为滚动到0就翻页了).
单位是像素?
在Adobe文档没有找到相关的说明

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2022-12-25 21:19
hbghlyj 发表于 2022-8-25 05:41
Description                         Support
Show or hide the toolbar     Chrome...


Firefox内置PDF viewer如何hide toolbar? 可以通过CSS实现:support.mozilla.org/en-US/questions/1319804

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2022-12-29 21:13


1#是旧版本, PDF.js 更新到 3.1.22 版本后, Current View 在 Tools 可以找到, 图标变成了

手机版|悠闲数学娱乐论坛(第3版)

GMT+8, 2025-3-4 15:47

Powered by Discuz!

× 快速回复 返回顶部 返回列表