Open imeavinash opened 3 weeks ago
Hello! I apologize for the delay! Thank you very much for your support for us!
Currently, our SDK does not support initialization using the upload_id and JWT token, so the DOM element parameter 'el' must be used to initialize the SDK. However, your suggestion is very good, and we will try to promote the optimization of this feature.
At present, it is also not supported to remove the ChatDOC brand logo, but we are working hard to develop this feature, and we expect to provide this option within the next few weeks. Once the feature is implemented, we will notify you at the first time, and also please continue to pay attention to our updates.
In addition, in order to better help you solve the problems encountered when using the ChatDOC SDK, could you please describe your specific usage method and parameter settings in detail?
I hope our reply is helpful to you. Have a nice day!
Hi,
Thanks for your reply. I will wait for the feature to remove chatdoc branding.
Please look at the following code. I am using it to display the pdf on the frontend in an HTML element in Bubble.io. When try to draw sources, I am calling the drawsourcebox function but it throws error saying can't find function sdk.drawsources.
https://c90f8055fa6c93515b054c0333df9374.cdn.bubble.io/f1718226173604x938927707629781200/main9.js
This is a link to bundle file. I made this file by creating a node project in replit -> installing chtadoc sdk -> making bundle using webpack.
Link to the repl - https://replit.com/@imeavinash/chatdocbundling2?v=1
<!DOCTYPE html>
======================================
This is the javascript i am running when i am trying to draw the sourcebox -
const pageNum = properties.param1; // Replace with dynamic data from Bubble.io const left = properties.param2; // Replace with dynamic data from Bubble.io const top = properties.param3; // Replace with dynamic data from Bubble.io const right = properties.param4; // Replace with dynamic data from Bubble.io const bottom = properties.param5; // Replace with dynamic data from Bubble.io
// Function to send a message to the iframe function sendMessageToIframe(action, data) { const iframe = document.getElementById('pdf-container2'); if (!iframe) { console.error('Iframe not found'); return; }
const message = { action, ...data };
function postMessageToIframe() { if (iframe.contentWindow) { iframe.contentWindow.postMessage(message, 'https://ethixia.com'); } else { console.error('Iframe contentWindow is not accessible'); } }
postMessageToIframe();
// Wait for the iframe to load completely // if (iframe.contentWindow) { // If iframe is already loaded //postMessageToIframe(); // } else { // Attach onload event to iframe //iframe.onload = postMessageToIframe; //} }
// Example usage function openPdfInIframe(fileurl) { sendMessageToIframe('openpdf', { url: fileurl }); }
function drawSourceBoxInIframe(pagenum, left, top, right, bottom) { sendMessageToIframe('drawsourcebox', { pagenum, left, top, right, bottom }); }
//drawSourceBoxInIframe(1, 100, 100, 200, 200); window.frames[0].frameElement.contentWindow.drawSourceBoxInIframe(pageNum, left, top, right, bottom);
==================================
This is the error i am getting. I am showing the above html to show the pdfviewer in an iframe html element. And I am trying to update sources.
Look at the last line of the error -main9.js:1 Uncaught (in promise) Error: Method drawSources not found.
at Proxy.
main9.js is the bundle file as described earlier.
Uncaught SecurityError: Failed to read a named property 'frameElement' from 'Window': Blocked a frame with origin "https://ethixia.com" from accessing a cross-origin frame.
listener @ run_debug.js:728Understand this error
VM1880:52 Uncaught DOMException: Failed to read a named property 'frameElement' from 'Window': Blocked a frame with origin "https://ethixia.com" from accessing a cross-origin frame.
at eval (eval at
It seems that the drawSources method is being called before the PDF viewer has finished loading. You can call it within the EVENT_TYPES.VIEWER_CREATED event like this example:
sdk.on(EVENT_TYPES.VIEWER_CREATED, () => { sdk.drawSources(sources); });
Hi,
I am working on a Bubble.io app for my client where i have integrated the chatdoc API and documentviewer. Bubble.io is a no code tool. I had some issues in integrating the SDK. Somehow I was able to integrate it and use it to initialize the SDK using only the el: DOM element parameter. I would like to be able to initialize the SDK using the upload_id and JWT token too. Also, can we remove the branding "Powered by Chatdoc API from the document viewer"? Also, after initialising the SDK, I am unable to draw sources. I have integrated the SDK by first preparing a bundle using webpack in a node project where i installed chatdoc SDK. Then i am using that bundle.js file as a source in my front end js script.
Any help in these will be highly appreciated. Thanks.