Free Support Forum - groupdocs.com

DOC/DOCX preview by using Javascript and Java Libraries

Hi Team ,

We are trying to implement GroupDocs for viewing DOC/DOCX pages by using Java Libraries and we are calling these Java Libraries by Javascript code.

But while implementing we are facing some issues in given examples servlet code provided in GroupDocs.Viewer Java Demos file in Java Libraries .

Some config java files seems to be missing in the code while calling ViewerServlet.Java .

Can you please help with this or please tell us the alternate way to implement this . If we can implement the same by Spring .

Hello,

Thank you for your inquiry.

Could you please specify, which version of the GroupDocs.Viewer for Java library you use? Also will be useful if you describe your use case with more details and also share with us your code examples .

We will wait for your details.

---------

Best regards,
Evgen Efimov

http://groupdocs.com
Your Document Collaboration APIs
Follow us on LinkedIn, Twitter, Facebook and Google+

Hi,

Wer are using GroupDocs.Viewer_3.2.2-Java vesion , And we are trying to show DOC/ DOCX files in Siebel Open UI by invoking Servlet file from Java Script code used in Siebel Open UI .

But while implementing examples given in GroupDocs.Viewer_2.14.0-Java-Examples in servlet we are facing below issues .

1)- In ViewerServlet.Java , these packages are missing and not able to find in examples viewer samples folder under Servlet .

import com.groupdocs.viewer.handlers.ViewerHandler;
import com.groupdocs.viewer.samples.javaweb.config.Configuration;
import com.groupdocs.viewer.samples.javaweb.domain.media.MediaType;

import com.groupdocs.viewer.config.ServiceConfiguration;

import com.groupdocs.viewer.config.IServiceConfiguration;

Please verify these above files where can we import from ?

Should we need to add extra jars in addition to this jar (GroupDocs.Viewer.jar) in classpath ?

Hi Saurab,


Sorry for the inconvenience.

The demos you downloaded will not work with GroupDocs.Viewer for Java 3.x series. I have added a note from where you downloaded old demos to avoid confusions: http://groupdocs.com/Community/files/9/java-libraries/groupdocs_viewer_for_java/entry750.aspx

Please follow this post for more details on how to use GroupDocs.Viewer for Java latest version.

Regards

Hi ,


I have tried to install Java Libraries from below given link
https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Java/tree/master/Examples/GroupDocs.Viewer.Examples.Java

But still some jar files (com.microsoft.azure.keyvault.core.IKey,com.microsoft.azure.keyvault.core.IKeyResolver) are missing from the below packages .

package com.microsoft.azure.storage.table;<o:p></o:p>

package com.microsoft.azure.storage.queue;

package com.microsoft.azure.storage.blob;


Please provide us the jar or tell us the alternative way .


Thanks In Advance

Saurabh Dixit

Hi Saurabh,


We apologize for inconvenience.

We have updated the external libraries, which are used in the example project, on GitHub repository. Please download the updated project containing all external jar files and let us know if your issue is resolved.

We shall be waiting for your response.

Warm Regards
Hi Team,

Thanks for the prompt reply on provided jars.
Now I have downloaded the latest GroupDocs.Viewer for Java 3.2.2 from here: http://groupdocs.com/Community/files/9/java-libraries/groupdocs_viewer_for_java/default.aspx . But while running in eclipse it is giving me error for properties files .Can you please check on below error .

Exception: com.groupdocs.viewer.internal.c.f.j.db.exc.UnrecognizedPropertyException: Unrecognized field "auto_ContentControls" (class com.groupdocs.viewer.domain.WordsFileData), not marked as ignorable (13 known properties: "pageCount", "maxWidth", "pages", "auto_DateModified", "auto_DateCreated", "maxHeight", "contentControls", "auto_PageCount", "auto_MaxWidth", "auto_Pages", "dateModified", "dateCreated", "auto_MaxHeight"])
at [Source: com.groupdocs.viewer.internal.c.a.ms.core.i.c.a@1cb5951; line: 1, column: 2303] (through reference chain: com.groupdocs.viewer.domain.WordsFileData["auto_ContentControls"])

class com.groupdocs.viewer.exception.GroupDocsException: com.groupdocs.viewer.internal.c.f.j.db.exc.UnrecognizedPropertyException: Unrecognized field "auto_ContentControls" (class com.groupdocs.viewer.domain.WordsFileData), not marked as ignorable (13 known properties: "pageCount", "maxWidth", "pages", "auto_DateModified", "auto_DateCreated", "maxHeight", "contentControls", "auto_PageCount", "auto_MaxWidth", "auto_Pages", "dateModified", "dateCreated", "auto_MaxHeight"])

at [Source: com.groupdocs.viewer.internal.c.a.ms.core.i.c.a@1cb5951; line: 1, column: 2303] (through reference chain: com.groupdocs.viewer.domain.WordsFileData["auto_ContentControls"]) ---> com.groupdocs.viewer.internal.c.f.j.db.exc.UnrecognizedPropertyException: Unrecognized field "auto_ContentControls" (class com.groupdocs.viewer.domain.WordsFileData), not marked as ignorable (13 known properties: "pageCount", "maxWidth", "pages", "auto_DateModified", "auto_DateCreated", "maxHeight", "contentControls", "auto_PageCount", "auto_MaxWidth", "auto_Pages", "dateModified", "dateCreated", "auto_MaxHeight"])

at [Source: com.groupdocs.viewer.internal.c.a.ms.core.i.c.a@1cb5951; line: 1, column: 2303] (through reference chain: com.groupdocs.viewer.domain.WordsFileData["auto_ContentControls"])

--- End of inner exception stack trace ---

com.groupdocs.viewer.helper.d.g(Unknown Source)

com.groupdocs.viewer.helper.d.getFileData(Unknown Source)

com.groupdocs.viewer.helper.c.b(Unknown Source)

com.groupdocs.viewer.handler.ViewerHandler.a(Unknown Source)

com.groupdocs.viewer.handler.ViewerHandler.getDocumentInfo(Unknown Source)

Main.ViewGenerator.renderDocumentInformation(ViewGenerator.java:54)

Main.MainClass.main(MainClass.java:18)

at com.groupdocs.viewer.helper.d.g(Unknown Source)

at com.groupdocs.viewer.helper.d.getFileData(Unknown Source)

at com.groupdocs.viewer.helper.c.b(Unknown Source)

at com.groupdocs.viewer.handler.ViewerHandler.a(Unknown Source)

at com.groupdocs.viewer.handler.ViewerHandler.getDocumentInfo(Unknown Source)

at Main.ViewGenerator.renderDocumentInformation(ViewGenerator.java:54)

at Main.MainClass.main(MainClass.java:18)

Caused by: com.groupdocs.viewer.internal.c.f.j.db.exc.UnrecognizedPropertyException: Unrecognized field "auto_ContentControls" (class com.groupdocs.viewer.domain.WordsFileData), not marked as ignorable (13 known properties: "pageCount", "maxWidth", "pages", "auto_DateModified", "auto_DateCreated", "maxHeight", "contentControls", "auto_PageCount", "auto_MaxWidth", "auto_Pages", "dateModified", "dateCreated", "auto_MaxHeight"])

at [Source: com.groupdocs.viewer.internal.c.a.ms.core.i.c.a@1cb5951; line: 1, column: 2303] (through reference chain: com.groupdocs.viewer.domain.WordsFileData["auto_ContentControls"])

at com.groupdocs.viewer.internal.c.f.j.db.exc.UnrecognizedPropertyException.from(Unknown Source)

Hi,

I am trying to implement a Showcase example which demonstrates how HTML5 output can be integrated with Spring MVC. Here goes this showcase example: https://github.com/aliahmedgroupdocs/GroupDocs.Viewer-for-Java/tree/master/Showcase/GroupDocs.Viewer-for-Java-Front-End .
So I have created one spring project in eclipse .But I am not able find org.eclipse.jetty.http.metadata.response jar file for ViewerController.java in controller .

import org.eclipse.jetty.http.metadata.response;

And while in pom.xml , we are getting below error
Failure to transfer org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from/to central (http://repo.maven.apache.org/maven2): connect timed out

So for this can you please provide us the updated jar file and what changes we need to do in pom.xml

Hi Saurabh,


We are sorry that you are facing such issues.

Firstly, please clone GroupDocs.Viewer for Java showcase project from official repository.
Furthermore, add following dependencies and plugin in your pom.xml.

org.eclipse.jetty
jetty-server
9.3.0.v20150612

com.groupdocs
groupdocs-viewer
3.2.2

org.eclipse.jetty
jetty-maven-plugin
9.3.0.v20150612

As far as connect timed out error is concerned, it can be resolved by following the given steps:
  1. Right click on the project
  2. Go to Maven -> Update Maven Project
  3. Select "Force Update of Snapshots/Releases"
  4. Press OK
Hope these steps will resolve your issues.

Keen to hear from you.
Many Thanks


Hi Saurab,


Adding more to my colleague, for your convenience, we have also released first version of the documentation of Spring MVC Front End. Please feel free to have a look at:

http://www.groupdocs.com/docs/display/viewerjava/GroupDocs.Viewer+for+Java±+Spring+MVC+Front+End

Especially the below two articles sound useful:

http://www.groupdocs.com/docs/display/viewerjava/Technical+Overview
http://www.groupdocs.com/docs/display/viewerjava/GroupDocs.Viewer+for+Java+Front+End+JavaScript+API+Parameters

Hope it helps.

Best Regards

Hi Team,


I have checked pom.xml and all dependencies are correct only as project is up to date only .

But I am still facing issue for jetty jar VERSION 9.3.0.v20150612 and it is still giving me error while importing package for org.eclipse.jetty.http.metadata.response .

And tries to update maven project as specified above steps .But still it is failing to build the project giving below error
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6
Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6

In Addition to above,


In ViewerController.java , I am getting error while executing below specified code

return ResponseEntity.ok().contentType(MediaType.parseMediaType(Utils.GetImageMimeTypeFromFilename(resourceName)))<o:p></o:p>

.body(new InputStreamResource(stream));

It is giving error stating The method ok() is undefined for the type ResponseEntity (org.springframework.http.ResponseEntity)
while this ok class file is present under GroupDocs.Viewer.jar\com\groupdocs\viewer\internal\a\a\e\ok.class

Ca you please suggest from which jar files this ok method is fetching ContentType and which spring version are you using in this MVC model ??

Hi Saurabh,


But I am still facing issue for jetty jar VERSION 9.3.0.v20150612 and it is still giving me error while importing package for org.eclipse.jetty.http.metadata.response .
In order to test this issue at our end, we want you to share the steps, you are trying to import the package?

As far as following error is concerned,

Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6
Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6

it seems that settings.xml file is missing you local maven repository folder .m2 (that is located here C:\Users\user name.m2).
In order to add local maven repository in settings.xml file, follow the given steps:
  • In Eclipse go to Windows -> Preferences
  • On right panel expand Maven, select user settings
  • Set your local maven repository path, as shown in this link (http://prntscr.com/bpzlnu)
  • Press OK
  • Now, right click on your project and go to Maven -> Update Project

Please try these steps and share your experience.
Many Thanks

Hi Saurabh,


Ca you please suggest from which jar files this ok method is fetching ContentType and which spring version are you using in this MVC model ??
This is how ContentType is being fetched (from Spring MVC 4.2.5): org.springframework.http.ResponseEntity.BodyBuilder.ContentType. We are also using Spring MVC 4.2.5.
Please make sure you have same version at your end.

Best Wishes

Hi Team,


Spring issue got resolved after version upgrade .
And after installing maven in my local it is not working on specified link http://localhost:8080/action but started to work on http://localhost:8080/viewer/action .

But still from document-viewer.jsp , it is not calling java script and css files from below code
<c:url value="/resources/Scripts/jquery-1.9.1.min.js" var=“jquery” />
<c:url value="/resources/Content/CSS/dialog.css" var=“dialogCss” />
Hence it is not loading any images while files are present on the given path correctly.
Please suggest .

Hi Saurabh,


Glad to hear that your framework issues are resolved now.
We will try our best to resolve this new issue as well. Please make sure, your resources folder is not missing any required scripting file. Aside this we would like to know, how you are binding document-viewer from your controller.

Have a great weekend ahead.

Best Wishes

Hi Team,


For me , it is giving error while accessing GroupDocs Viewer Page at this url http://localhost:8080/viewer/action

It is failing to load these resources while inspecting on same page by hitting F12.

http://localhost:8080/viewer/resources/Content/images/sprites.png
Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:8080/viewer/resources/Content/images/mainbg.png
Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:8080/viewer/resources/Content/images/spinner.gif
Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:8080//ViewDocument
Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:8080//LoadFileBrowserTreeData
Failed to load resource: the server responded with a status of 404 (Not Found)
Can you please help , because I m hitting them on http://localhost:8080/viewer/ViewDocument , still it is not working,

Hi ,


In Addition to above , I have checked that Resources folder is not missing .
And from controller (ViewerControler.java) , ir is calling document-viewer.jsp in below method.

public ModelAndView redirectToViewer() {

ModelAndView mv = new ModelAndView(“document-viewer”);

return mv;
}
And it is getting accessible at http://localhost:8080/viewer/action url not on

Triggers at page load,http://localhost:8080/action
as mentioned in your document http://www.groupdocs.com/docs/display/viewerjava/Technical+Overview
Can you please suggest on this ???

Hi Saurabh,


Please add @RequestMapping("/action") over following code snippet.

public ModelAndView redirectToViewer() {

ModelAndView mv = new ModelAndView(“document-viewer”);

return mv;
}

This annotation will map web request on public ModelAndView redirectToViewer() method. And then it will be accessible at http://localhost:8080/action.
Please see this screenshot.

Kind Regards

Hi Team,


It is already there in code .
@RequestMapping("/action")
public ModelAndView redirectToViewer() {

ModelAndView mv = new ModelAndView(“document-viewer”);

return mv;
}
Still it is loading at http://localhost:8080/viewer/action only