Is there a way to stream content from a URL similar to how a one can with the viewer module ?
<%= new WidgetFactory()
.Annotation()
.AccessRights(Groupdocs.Common.AnnotationReviewerRights.All)
.ElementId(“annotation-widget”)
.FilePath(“Quick_Start_Guide_To_Using_GroupDocs.pdf”)
.ShowHeader(false)
.Width(600)
.Height(800)
.ToHtmlString() %>
I know there is a stream method instead of a filePath, but it looks like this method takes in a Stream instead of a URL.
I am using the example project GroupDocs.Demo.Annotation.WebForms
Hi,
Thankyou, this did work, however it only worked for Office documents and PDF documents. Any idea on why this would be the case ?
Additionally, it seems as though the annotation module is always built with a parameter of “use_pdf : true” when it the script block is returned to the browser. Is there no way to use an html mode similar to that of the Viewer module ?
Below is my Default.aspx file code:
<%@ Page Title=“Home Page” Language=“C#” MasterPageFile="~/Site.master" AutoEventWireup=“true”
CodeBehind=“Default.aspx.cs” Inherits=“Groupdocs.Demo.Annotation.Webforms._Default” %>
<%@ Import Namespace=“Groupdocs.Web.Annotation” %>
<%@ Import Namespace="" %>
<asp:Content ID=“BodyContent” runat=“server” ContentPlaceHolderID=“MainContent”>
<%
System.Net.WebClient myWebClient = new System.Net.WebClient();
Stream myStream = myWebClient.OpenRead(“urlToFile”);
%>
<%= new WidgetFactory()
.Annotation()
.AccessRights(Groupdocs.Common.AnnotationReviewerRights.All)
.ElementId(“annotation-widget”)
//.FilePath(“Quick_Start_Guide_To_Using_GroupDocs.pdf”)
.Stream(myStream, “test”)
.ShowHeader(false)
.Width(600)
.Height(800)
.ZoomToFitHeight(true)
.ToHtmlString()
%>
<%
myStream.Close();
%>
</asp:Content>
Hi John,
Unfortunately Annotation doesn’t support HTML rendering mode, since that you can’t change “use_pdf : true” to false.
As for the stream - the method that I suggested have nothing with the Annotation library - its a common
ASP.NET method. If you share with me several URLs for different file types which fails on your side I can check them.
Best regards.
Hi,
Thanks for the help, below are a couple files that I could not successfully render.
http://www.joomlaworks.net/images/demos/galleries/abstract/7.jpg
http://ww1.prweb.com/prfiles/2014/04/10/11752526/gI_134971_best-image-web-hosting.png
http://textfiles.com/100/914bbs.txt
http://www.w3schools.com/xml/note.xml
http://knockoutjs.com/examples/helloWorld.html
Thanks,
John
Hi John,
Thank you for the URLs I will check them and then return to you.
Thank you.
Hi,
I tried what you instructed for the document URLs I submitted, but this did not resolve the issue for all of the documents. Even when I gave the fileName the proper extension, some of the objects that were stored in the cache still did not have a valid extension, the content that was inside the cache (when I opened them with notepad++) were valid.
I guess I am trying to figure out why the .Stream method is not setting the proper file extension ?
For each of the urls I provided I deleted the cache before trying each document with the proper file extension set in the fileName parameter of the stream method.
Additionally, I wanted to get an understanding of how the annotations themselves are stored. As my end goal is to store the documents and their annotations in a database.
Hi John,
Thank you for coming back. In such case please delete the file-sessions.json from the root storage, clean/rebuild the project and delete “temp” folder inside the root storage.
Initially the annotations and all data about the users are stored in the SQLCompact database file which is placed in the root storage. To use the annotation with another database please check this
article
Best regards.
Hi,
This did not work either, I was able to remove the temp cache easily by simply deleting the files, however the file-sessions.json is not deleting. I can delete the file and it goes away, however when I open another file and then look at the file-sessions.json it is now the file I deleted with a new line for the file I just viewed. What is the best way to prevent this file from picking up old sessions ?
Additionally, the problem with not rendering certain formats has not been solved. By looking at the file-sessions.json it is evident that the proper file extension is not being set when the file is being saved to the cache.
Below is an example of some entries in the file-sessions.json file
{
“temp\S\090003e980040dd8.docx”: 40,
“temp\S\090003e98000e2ea.pdf”: 41,
“temp\S\090003e980038977.pdf”: 42,
“temp\S\090003e980038979.”: 43,
“temp\S\090003e98003897a.”: 44
}
The entries without extensions were supposed to be .jpg and .txt
UPDATE
I forgot to run the clean before. This seemed to clean out the file-sessions.json file. However, the number did not reset to 0 it continued counting (I assume this is fine).
Additionally, with the certain files the file extension is not appended to the filename in the cache of in the file-seesion.json as described in my previous response.
I have set breakpoints in my WebForms project and know that the fileName I am setting is valid and has a proper extension.
Hi,
I would be glad to upload my project however every time I attempt to upload a zip file of the project I get a 404 error. If you instruct me on how to properly upload the project I will do so.
In the meantime the only file I have altered the in “GroupDocs.Total for .NET Samples\GroupDocs.Annotation for .NET\Samples\Groupdocs.Demo.Annotation.Webforms” project was the default.aspx file (which is copy and pasted below). Additionally the URLs I am trying to render are the ones I posted in a previous thread.
<%@ Page Title=“Home Page” Language=“C#” MasterPageFile=“~/Site.master” AutoEventWireup=“true”
CodeBehind=“Default.aspx.cs” Inherits=“Groupdocs.Demo.Annotation.Webforms._Default” %>
<%@ Import Namespace=“Groupdocs.Web.Annotation” %>
<asp:Content ID=“BodyContent” runat=“server” ContentPlaceHolderID=“MainContent”>
<%
System.Net.WebClient myWebClient = new System.Net.WebClient();
Stream myStream = myWebClient.OpenRead(url);
%>
<%= new WidgetFactory()
.Annotation()
.AccessRights(Groupdocs.Common.AnnotationReviewerRights.All)
.ElementId(“annotation-widget”)
.Stream(myStream, “7.jpg”)
.ShowHeader(false)
.Width(600)
.Height(800)
.ZoomToFitHeight(true)
.ToHtmlString()
%>
<%
myStream.Close();
%>
</asp:Content>
Thanks,
John
After downloading the project and running a clean and a rebuild and then attempting to launch the solution I received error pages about not having references to System.Web.Pages.dll and Microsoft.AspNet,SignalR.Core.
I’ve noticed that they were in my project which I sent to you, but they were not in the correct project you sent back.
Is this supposed to be the case ?
Hi,
Yes, I have cleaned the project and since they were in the “bin” folder they was deleted. Simply add them in correct way via Nuget and all will work correctly.
Best regards.
Hi,
It seems that I am able to download those packages, but they bring in a lot of other packages as well. Is there a list of the packages I need to have installed and of what version for a target framework of .NET framework 4 ?
No matter what combinations of packages I install it seems there is always a missing assembly reference when cleaning and building the project now. Some are easy to add because they actually tell me the name of the package but others do not. A detailed list of the packages you install from the package manager console would be great along with their versions. I believe the errors I am seeing now are solely because or reference files.
Hi John,
I have prepared a zip package with all libraries which you should add to the project for GroupDocs.Annotation, you can download it
here .
Also please note that the correct way to add them and save them after clean/rebuild - put them to any folder out of “bin” folder and reference them from it.
Best regards.