Free Support Forum - groupdocs.com

How to "destroy" existed viewer?


#1

Is it possible to “destroy” existed viewer? If I’m not mistaken an open viewer holds some resources. Let’s suppose that I want to release these resources. How can I do it?


BTW, what does the exception mean?
[: Unable to create folder in the local file storage: path = \OUR-IP-ADDRESS\Archives\Client-6\Company-1\Archive-1\In\pdf-tester.pdf\2014-05-05T07_57_23\100@x.Pdf.]

#2

Hello Igor,

Thank you for your request. You can destroy existed Viewer via JavaScript. Simply remove div with Viewer using this JS code:

containerElement.groupdocsViewer("destroy");

containerElement.remove();

Error you get means that you don't have rights to create file in network storage. Please set user rights to read/write for this folder

Also If you have any additional questions please feel free to get back in touch.




#3

Hi Pavel,


I do have full permissions for the Archives folder. I even tried to set these permissions for Everyone and it still doesn’t work.
I see “\2014-05-05T07_57_23</span>100@x.Pd” after the file name. What is it? Maybe this is the issue?


#4

Thank you for the additional info. We had concluded from your question that you are asking about resource disposing that GroupDocs.Viewer holds, not about cleaning a HTML page. If I understood you correctly, the following text is an answer. If no, please clarify your request.


In general, there are two items which GroupDocs.Viewer needs: the target document that should be displayed and the temporary folder where GroupDocs.Viewer stores the document’s cache. GroupDocs.Viewer creates a temporary folder called “temp” automatically in the “Root Storage” folder, which should be initialized using the “GroupdocsViewer.SetRootStoragePath” static method. Inside the “temp” folder, GroupDocs.Viewer creates one subfolder per document with the target document’s name. And inside this subfolder, GroupDocs.Viewer creates sub-subfolder with the datetime in the name - this datetime indicates the moment when target document’s cache was created.

Assuming that GroupDocs.Viewer holds only the latest current cache for the current document, the document that is displaying at this moment. Any other resources, all other cache and even target documents themselves, can be removed, replaced, renamed and so on - GroupDocs.Viewer doesn’t need them.

In answer to your second question - no, you have not. In order to create temp folder with all subfolders and cache files within them GroupDocs.Viewer requires permission to create, read, write and so on.

If you are using ASP.NET Development Server, aka Cassini, make sure that you are running MS Visual Studio with Administrator rights.

If you are using IIS - check the permission for the project folder. In order to resolve this issue and allow access to this folder please fulfill the following steps:
1. Open your IIS manager.
2. Right click on your web-site -> Edit permissions -> Security tab.
3. Add full access for Users group. .

If this does not help you, you can also change the identity of your application pool. Change the identity to a user or account which definitely has all the necessary permissions for the “inetpub” folder and all its subfolders (if you are hosting your web-site in the “inetpub” folder, of course).

Hope it helps. If you have more questions please feel free to contact us.



#5

Hi Igor,


It’s also worth trying the following when setting the root storage path:

Viewer.SetRootStoragePath(@"\MainPathToDocuments", @“c:\TempAreaForProcessing”);

So instead of using the share, use a different locally available temp storage area for files that have been processed for viewing, there might also be issues with combined length of the referenced filenames, since IIS has issues with filenames (including the paths) that are longer than 260 chars.

You could also try setting a shorted sharename for the temp files if you don’t want to place them on a local disk.

Please let me know if you have any other questions and I’ll be glad to help,

Take care,

Derek

Derek Hyland, Venture Lead, GroupDocs (Aspose Pty Ltd)
Office: +1 (214) 329 9760
Skype: derekh.aspose


#6

hi,


In regards to the temporary area for processing, and the files/folders created there by GroupDocs as a part of previewing the document - is there a way to delete/clean up these programmatically using GroupDocs API? I’m noticing that our current cache clean-up only seems to remove the actual original document copies (below temp/FromStream), not the items below Processing/temp/FromStream levels.

regards,
Greg



#7

p.s. On a somewhat unrelated note, these GroupDocs forums don’t seem to be behaving too well for me when using the latest version of Firefox - they’re showing incorrect information about who has the last post in the thread/topic, and clicking ‘Reply’ button seemed to take me to the main forum page…


#8

Hi Greg,

Thank you for your interest in GroupDocs. You can remove cache of GroupDocs.Viewer using method “public void RemoveOldEntries(TimeSpan olderThan)” that is located in the class “DocumentCache” (Description of GroupDocs.Viewer DocumentCache class). If you want to remove “temp” folder at all, you should do it by yourself using a “Directory.Delete” method. If you want to leave “temp” folder, but to remove all its content, you can follow these suggestions: How to delete all files and folders in a directory?

If you will have more questions please feel free to contact us.



#9

hi Denis,

thanks for your response on the forum Earlier today I was doing a bit of experimenting with setting the following two config items to point to different locations: “DocumentViewerRootStoragePath” and “DocumentViewerWorkingDirectoryPath” After separating the two out, looks like the path pointed to by DocumentViewerRootStoragePath will contain ‘temp’ folder and vs.bin file, while the path pointed to by DocumentViewerWorkingDirectoryPath will contain the two folders (Cache, Processing). So, am I understanding correctly that the API call you mentioned in your forum response - “RemoveOldEntries”, will be removing older-than-time-period only b elow the folder referenced by DocumentViewerWorkingDirectoryPath config option (i.e. old ? While the folder below DocumentViewerRootStoragePath (e.g. ‘temp’) needs to be manually cleaned up by the consumer application?


This message was posted using Email2Forum by denisgvardionov.

#10

Hi Greg,


In general, you are right. The main idea behind the separation of "RootStoragePath" and "WorkingDirectoryPath" is to locate target documents that should be viewed apart from the GroupDocs.Viewer's internal mechanics (like the "Cache" and "Processing" subfolders in the WorkingDirectoryPath folder). One location for target documents, and another for the things that should not matter to the end-user.

One more thing that you should take into accout is the fact that GroupDocs.Viewer can handle documents not only as files in the "RootStoragePath" folder, but also as byte streams (which implements System.IO.Stream) and web resources. So in order to handle these documents, GroupDocs.Viewer creates a "temp" subfolder inside the "RootStoragePath" folder and there the "FromStream" and "FromUrl" sub-subfolders. Finally, when clicking the "Open file" button (located in the top left corner of the GroupDocs.Viewer's web interface), you will be able to browse all documents from the "RootStoragePath" folder and all other documents that were received from streams and/or web resources.


On the other hand, the "WorkingDirectoryPath" folder is "hidden" from you, you can manage it only indirectly using GroupDocs.Viewer's methods. The "RemoveOldEntries" method cleans out the old cache in the "WorkingDirectoryPath" folder, but it doesn't clean the folder structure - only files. If you want to remove the "WorkingDirectoryPath" folder itself with all its content, use the standard .NET System.IO methods that I mentioned in the previous post. Removing cache-related folders in OK, it doesn't "hurt" the GroupDocs.Viewer; it will recreate them if they don't exist.