Skip to content

Commit

Permalink
Merge pull request #5 from PDFTron/update-to-webviewer-7.2
Browse files Browse the repository at this point in the history
Upgraded version of WebViewer to 7.2
  • Loading branch information
andreysaf authored Dec 8, 2020
2 parents 3dc73fb + 9d69584 commit c8cd562
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 45 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@pdftron/webviewer": "^6.3.1",
"@pdftron/webviewer": "^7.2.0",
"@reach/router": "^1.3.3",
"@reduxjs/toolkit": "^1.3.6",
"@testing-library/jest-dom": "^4.2.4",
Expand Down
29 changes: 9 additions & 20 deletions src/components/PrepareDocument/PrepareDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,19 @@ const PrepareDocument = () => {
{
path: 'webviewer',
disabledElements: [
'toolsButton',
'ribbons',
'toggleNotesButton',
'searchButton',
'menuButton',
'contextMenuPopup',
'freeHandToolGroupButton',
'textToolGroupButton',
'shapeToolGroupButton',
'signatureToolButton',
'eraserToolButton',
'stickyToolButton',
'freeTextToolButton',
'miscToolGroupButton',
],
},
viewer.current,
).then(instance => {
const { iframeWindow } = instance;

// select only the view group
instance.setToolbarGroup('toolbarGroup-View');

setInstance(instance);

const iframeDoc = iframeWindow.document.body;
Expand Down Expand Up @@ -164,13 +159,7 @@ const PrepareDocument = () => {

// customize styles of the form field
Annotations.WidgetAnnotation.getCustomStyles = function (widget) {
if (widget instanceof Annotations.TextWidgetAnnotation) {
return {
'background-color': '#a5c7ff',
color: 'white',
'font-size': '20px',
};
} else if (widget instanceof Annotations.SignatureWidgetAnnotation) {
if (widget instanceof Annotations.SignatureWidgetAnnotation) {
return {
border: '1px solid #a5c7ff',
};
Expand Down Expand Up @@ -203,14 +192,14 @@ const PrepareDocument = () => {
return; //don't add field to an invalid page location
}
const page_idx =
page.first !== null ? page.first : docViewer.getCurrentPage() - 1;
page.first !== null ? page.first : docViewer.getCurrentPage();
const page_info = doc.getPageInfo(page_idx);
const page_point = displayMode.windowToPage(point, page_idx);
const zoom = docViewer.getZoom();

var textAnnot = new Annotations.FreeTextAnnotation();
textAnnot.PageNumber = page_idx + 1;
const rotation = docViewer.getCompleteRotation(page_idx + 1) * 90;
textAnnot.PageNumber = page_idx;
const rotation = docViewer.getCompleteRotation(page_idx) * 90;
textAnnot.Rotation = rotation;
if (rotation === 270 || rotation === 90) {
textAnnot.Width = 50.0 / zoom;
Expand Down
22 changes: 12 additions & 10 deletions src/components/SignDocument/SignDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,27 @@ const SignDocument = () => {
{
path: 'webviewer',
disabledElements: [
'toolsButton',
'ribbons',
'toggleNotesButton',
'searchButton',
'menuButton',
'contextMenuPopup',
'freeHandToolGroupButton',
'textToolGroupButton',
'shapeToolGroupButton',
'signatureToolButton',
'eraserToolButton',
'stickyToolButton',
'freeTextToolButton',
'miscToolGroupButton',
'rubberStampToolGroupButton',
'stampToolGroupButton',
'fileAttachmentToolGroupButton',
'calloutToolGroupButton',
'undo',
'redo',
'eraserToolButton'
],
},
viewer.current,
).then(async instance => {
const { docViewer, annotManager, Annotations } = instance;
setAnnotatManager(annotManager);

// select only the insert group
instance.setToolbarGroup('toolbarGroup-Insert');

// load document
const storageRef = storage.ref();
const URL = await storageRef.child(docRef).getDownloadURL();
Expand Down
16 changes: 5 additions & 11 deletions src/components/ViewDocument/ViewDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,16 @@ const ViewDocument = () => {
{
path: 'webviewer',
disabledElements: [
'toolsButton',
'searchButton',
'menuButton',
'ribbons',
'toggleNotesButton',
'contextMenuPopup',
'freeHandToolGroupButton',
'textToolGroupButton',
'shapeToolGroupButton',
'signatureToolButton',
'eraserToolButton',
'stickyToolButton',
'freeTextToolButton',
'miscToolGroupButton',
],
},
viewer.current,
).then(async instance => {
// select only the view group
instance.setToolbarGroup('toolbarGroup-View');

setInstance(instance);

// load document
Expand Down

0 comments on commit c8cd562

Please sign in to comment.