documentLoadCompleted.groupdocs not getting called

I am using below script without "UseHtmlBasedEngine(true)" to load my document in document viewer. which works fine but when i add UseHtmlBasedEngine(true) line in the script, my documentLoadCompleted.groupdocs event is not getting called. Please help.

@(Viewer.ClientCode()

.TargetElementSelector("#attachment-viewer")

.EnableRightClickMenu(false)

.ShowThumbnails(false)

.ShowFolderBrowser(false)

.ShowSearch(false)

.ShowViewerStyleControl(false)

.SupportTextSelection(Model.objADRMS.ExtractPermission)

.UseHtmlBasedEngine(true)

.ShowHeader(true)

.PreloadPagesCount(1)

.EnableStandardErrorHandling(true)

.IgnoreDocumentAbsence(true)

.ZoomToFitWidth()

.ShowDownload(Model.objADRMS.ExportPermission)

.ShowPrint(Model.objADRMS.PrintPermission)

)


var containerElement = $("#attachment-viewer");

containerElement.groupdocsViewer("on", "documentLoadCompleted.groupdocs",

function (e) {

var documentPageCount = containerElement.groupdocsViewer("getDocumentPageCount");

alert("documentPageCount: " + documentPageCount);

});

Hello,


Thank you for your request. First of all I want to notify you that we have released a next generation Viewer library and if possible you should migrate on it. The library, documentation and examples you can find here

If you can’t migrate wright now to fix the issue please use such JavaScript code:

$(document).ready(function () {
var containerElement = $(“#attachment-viewer”);

containerElement.groupdocsViewer(“on”, “documentLoadCompleted.groupdocs”,
function (e) {
var documentPageCount = containerElement.groupdocsViewer(“getDocumentPageCount”);

alert("documentPageCount: " + documentPageCount);
})
});

The main thing that you missed is that that the JavaScript methods and events of the Viewer should be called after the web page is loaded that the all Viewer libs. are loaded.

Best regards.

Hi,


Thanks for the reply. we are using GroupDocs.Annotation for .NET 2.1.1. and above suggested code is not working in our application.

Hi again,


Thank you from the update. According on the code from your first post and the fact that you have posted the request in the Viewer area I assumed that you use the Viewer. Unfortunately the Annotation library doesn’t have such methods and events.

Best regards.

Hello,

As we need annotation and viewer feature both, we are referencing GroupDocs.Annotation for .NET 2.1.1 and using “Groupdocs.Web.Annotation.dll”.

We are facing several issues which are as below

Issues:

· printButtonClick.groupdocs is not getting fired
· Arabic content is not rendered properly and displays junk characters
· Is there a way to change file name on “downloadButtonClick.groupdocs”?

also documentLoadCompleted.groupdocs event behavior is strange. It is fired for some of the documents. For example it is fired for Quick_Start_Guide_To_Using_GroupDocs.docx word document and is not getting fired for attached Scanner Integration_v1.docx document. Please find sample code as below.

@using Groupdocs.Web.UI

@{

ViewBag.Title = "Index";

Layout = "~/Views/Shared/_Layout.cshtml";

}

@section groupdocs {

@Html.CreateViewerScriptLoadBlock().LoadJquery(false).LoadJqueryUi(false)

}

@(Html.ViewerClientCode()

.TargetElementSelector("#viewer-widget")

.EnableRightClickMenu(false)

.ShowThumbnails(false)

.ShowFolderBrowser(false)

.ShowSearch(false)

.ShowViewerStyleControl(false)

.SupportTextSelection(true)

.UseHtmlBasedEngine(true)

.ShowHeader(true)

.PreloadPagesCount(1)

.EnableStandardErrorHandling(true)

.IgnoreDocumentAbsence(true)

.ZoomToFitWidth()

.ShowDownload(true)

.ShowPrint(true)

.FilePath("Scanner Integration.docx")

)

<div id="viewer-widget" class="groupdocs_viewer_wrapper grpdx" style="width: 100%; height: 100%;" >

</div>

<script>

$(function () {

var containerElement = $("#viewer-widget");

//document complete event fired

containerElement.groupdocsViewer("on", "documentLoadCompleted.groupdocs",

function (e) {

alert("documentLoadCompleted event fired");

});

//download button click

containerElement.groupdocsViewer("on", "downloadButtonClick.groupdocs",

function (e, zoom) {

alert("Download button was clicked");

});

//print button click

containerElement.groupdocsViewer("on", "printButtonClick.groupdocs",

function (eventDescr, pdfPrintingMode) {

alert('Print button was clicked using ' + (pdfPrintingMode ? 'PDF' : 'HTML') + '-printing mode.');

});

});

</script>


We need to use viewer, annotation and signature together. If you can provide such demo which uses all these 3 features together then that will be really helpful.

I have attached pdf file and other related filefor which we are getting issue along with this post.

Hi,


Thank you for asking. First of all if you use several GroupDocs libraries i the same project you need to use aliases, more info about how to use it you can find here. All our libraries uses the same main NameSpace “GroupDocs” since that when you use several our libraries they can conflict because the app doesn’t know which library exactly it should call.

As for the JavaScript actions - since you use several our libraries in the same project, using of the aliases should resolve this issue too.

Best regards.

Hi,


Thanks for the reply. As of now we have added only one library mentioned in above post and still above issues are there.

Please help us to solve below issues :
· printButtonClick.groupdocs is not getting fired
· Arabic content is not rendered properly and displays junk characters
· Is there a way to change file name on “downloadButtonClick.groupdocs”?

Source code and other attachments are same as above post.

Hi,


Which library exactly you have added, because the JavaScript events will be fired only with the Viewer library, if you added the Annotation library they will not work. Also you can add both libraries and then when you add the Viewer code to the web page the events will work. If you will have this issue again please share with me full project example that I can reproduce the issue.

Thank you

Hi,


Thanks for the reply. I have created a demo project which describes all issues mentioned above.
I have placed the demo project at: https://www.dropbox.com/s/cpzr219u5rhxvol/GroupdocsViewerDemo.zip?dl=0

Please let me know if you need anything else to reproduce the issue.

Hi,


Thank you for the example project. I have checked your project and found out that you use the Annotation library and the Viewer code instead of the Viewer library. As I said in a previous posts to use JavaScript events of the Viewer you should add it as a reference, the Annotation library based on the Viewer library but its JavaScript events doesn’t available from the Annotation library. Yes, you can use only the Annotation library if you need to view or annotate the document but if you need Viewer JavaScript events and methods - you need the Viewer library.

Please remove Annotation library and add the Viewer library or if you need both - add both libraries and use aliases for them.

Best regards.

Hi,


Thanks for the reply. now i know where i need to make changes. But still i have one query remaining. Is there a way to change file name on “downloadButtonClick.groupdocs” event?
I tried stop the default download behavior and make an ajax call to my custom method from above event to change file name, but that didn’t work.


Hi,


As per your suggestion I have removed the Annotation library from my solution and added Viewer library of version 2.19.0. Still I am facing the same issue for print button click event. I have created another demo project where I have added Viewer library instead of Annotation. I have placed the demo project at https://www.dropbox.com/s/d62272jt12bkoen/GroupdocsViewerDemo_05_03_2016.zip?dl=0.

Please help us to solve below issues:
  • “printsBottonClick.groupdocs” is not getting fired
  • Is there any way to change file name on "downloadButtonClick.groupdocs"

Thanks,
Aradhana


Hi Aradhana,


Sorry for the delay. Here is a fixed project example.

As for the changing download file name - unfortunately such feature doesn’t available.

Best regards.

Hi,


Thanks for the reply. That example is really helpful and the print button click is working in the example. But i am unable to find what change you have made to make the print button work???
Can you please explain that part a bit?

Also, is there a way to unbind default download button click event and bind other button event?

Hi,


Glad to hear that. In your initial project was a mess with the references and I have created exactly the same project from a scratch.

As for the binding - yes, you can do that. To achieve this you should disable the download button with .ShowDownload(false), then create your own download button and add a JavaScript function which will be called by click on the button, this function should trigger the Viewer donwload event as you do in the example.

Best regards.