Page 1 of 1

Loading images to an specific instance.

Posted: Fri Apr 20, 2018 7:46 pm
by Alex
Hi, I'm trying to load documents from a database, I have a table in angular that displays the data on my table, so when I click on an specific record I want to load the image attached to that record on the docuvieware I've got. So how I'm I supposed to do this? The way I'm doing it right now is creating a new docuvieware each time I click. But is there any way I only have one instance, and send the desired file to that specific vieware?

Thanks.

Re: Loading images to an specific instance.

Posted: Mon Apr 23, 2018 9:06 pm
by Alex
No answer yet, so, what I'm trying to do, is to load a file from an array of bytes to an specific vieware. So far what I've accomplished is to create more, and more viewares but no to load it to the original one. Here's a bit of code of what I've been doing.

Code: Select all

public DocuViewareRESTOutputResponse PostShow(DisplayDocuvieware displayConfig)
        {
            if (!DocuViewareManager.IsSessionAlive(displayConfig.SessionId))
            {
                Console.WriteLine("La session is inactive");
            }
            GdPicture14.WEB.DocuVieware docuviewareInstance = new GdPicture14.WEB.DocuVieware(displayConfig.SessionId);

            using (StringWriter controlOutput = new StringWriter())
            {
                if (displayConfig.File != null)
                {
                    Stream str = new MemoryStream(displayConfig.File);
                    docuviewareInstance.ID = displayConfig.ControlId;
                    docuviewareInstance.LoadFromStream(str, true);
                }
                docuviewareInstance.RenderControl(controlOutput);
                DocuViewareRESTOutputResponse output = new DocuViewareRESTOutputResponse
                {
                    HtmlContent = controlOutput.ToString()
                };
                return output;
            }
        }
The DisplayDocuveware only has the sessionID, the ControlID and the array of bytes I'm trying to load. I'm using the sample rest api for the Angular project.

Re: Loading images to an specific instance.

Posted: Tue Jan 22, 2019 4:36 pm
by Cedric
I'm not sure if this still an issue but you shouldn't have to recreate a new instance each time you want to display another document, you just need to reuse the previous one if it has been created.

I would strongly recommend to follow what is done in the dedicated tutorial here: https://www.docuvieware.com/guides/aspn ... 20API.html

It demonstrates how to properly serve a DocuVieware control through a REST service and how to retrieve an existing session if it exists.