ApryseSDK / webviewer-ui

WebViewer UI built in React
Other
416 stars 353 forks source link

Load document outside viewer #156

Closed duytq1303 closed 5 years ago

duytq1303 commented 5 years ago

When i load document before get in viewer with redux actions ( setDocumentFile ). The first time tool annotator works well. But when i get back and setDocumentFile again outside viewer. I can't use any annotator tools. How can i fix it ?

ZhijieZhang commented 5 years ago

Hi there,

setDocumentFile is not a part of the APIs and is just an internal action that will be dispatched when calling API loadDocument.

To clarify, are you trying to load the document outside the viewer programmatically? If yes, you should be using loadDocument.

The first time tool annotator works well. But when i get back and setDocumentFile again outside viewer. I can't use any annotator tools.

Could you elaborate more on this? When we are testing, we are still able to use annotator tools after loading other documents. It would be helpful if you can provide us a code snippet that reproduces the issue you are seeing.

duytq1303 commented 5 years ago

hi mate, i've already check my code and here what i did. it's working fine at the first time but when i get back and get in viewer again. I can't use any tool which interact with the canvas layer ( freehandtool, texttool).

screen shot 2019-02-08 at 12 47 10 am
duytq1303 commented 5 years ago

and i also try to use loadDocument api and here is my console

screen shot 2019-02-07 at 9 16 57 am
ZhijieZhang commented 5 years ago

Hi there,

Sorry for the delay in our reply and thanks for your detailed information.

We also tried to use the loadDocument API with the same URL as in your screenshot but we didn't see any error in the console. Here is a screenshot: screen shot 2019-02-08 at 1 15 51 pm

If you commented out your code and then call readerControl.loadDocument in the console, are you able to see the same error message?

One thing you could do is try the following code in your clickDocument function:

try {
  this.props.openLoading();
  const file = await getFileService.getDocument(document);
  window.readerControl.loadDocument(file);
  this.props.closeLoading();
  this.props.history.push('/viewer');
}

It is kind of tricky to give a suggestion based on the code snippet you posted. If the above option doesn't work for you, could you send us a sample project which can reproduce the issue you are seeing? That way, we can debug easier and investigate further.

duytq1303 commented 5 years ago

oh hi, i've tried to replace my code like your suggestion but it's still unlucky. After that, i create example prj that i fork from PDFTron github and integrate react router. Here is my github of example prj. https://github.com/duytq1303/webviewer-ui I'm trying to load document in Test component and get in Viewer after that. Thank you for your supporting mate.

ZhijieZhang commented 5 years ago

Hi,

We tried your sample project and were able to reproduce the issue you are seeing. The error occurred because after calling loadDocument, CoreControls.js will process the document and display the document in the viewer but the viewer is not in the DOM.

Instead of modifying this UI project directly, we recommend you integrating it into your project. This repo gives a basic example about how you can set up WebViewer UI in a react project: https://github.com/PDFTron/webviewer-react-sample

To fix the issue, you need to pass the document URL as a prop to the App component in the above sample repo and inside wvReadyHandler call loadDocument with the URL you passed.

Please let me know how this works for you, or if you have any other questions.

duytq1303 commented 5 years ago

Hi, I don't want your way because i've modified a lots in this project. So can't use your way. Btw i think you're right when CoreControls.js process document and interact to the viewer but viewer do not mount. However, the first time i still can work with annotator and only annotators interact with canvas can't use at the second time. So i think we still have a way to fix this.

ZhijieZhang commented 5 years ago

Hi there,

Just want to follow up if you managed to resolve this issue or it still bothers you?

Thanks

duytq1303 commented 5 years ago

Oh you can close this issue. Thanks

On Tue, Jun 18, 2019 at 07:14 Zhijie Zhang notifications@github.com wrote:

Hi there,

Just want to follow up if this issue still bothers you?

Thanks

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/PDFTron/webviewer-ui/issues/156?email_source=notifications&email_token=AGUWAN7ERVPAHNWBSCSBNNDP3ASHDA5CNFSM4GUAW27KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODX4ZOBA#issuecomment-502896388, or mute the thread https://github.com/notifications/unsubscribe-auth/AGUWAN6JK34ZIKC7QLYKE2TP3ASHDANCNFSM4GUAW27A .

--

Trần Quang Duy Project Leader | Designveloper - www.designveloper.com http://www.designveloper.com/

Email: duytq@dgroup.co duytq@dgroup.co Mobile: (84) 938396889 Address: Floor 5 & 8, 144-146 Nguyen Thai Binh street, Nguyen Thai Binh Ward, District 1, Ho Chi Minh City, Vietnam

Confidentiality Notice: The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. Thank you for your cooperation!