pdf delete after stream read
Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan
Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
pdf delete after stream read
Hello~!
I want to load a PDF file, and then delete PDF file.
But, after the stream source file loading are original pdf file not deleted.
- I tested 'FullDemo' sample program (Ver. 5.5.315.0)
Please help.
I want to load a PDF file, and then delete PDF file.
But, after the stream source file loading are original pdf file not deleted.
- I tested 'FullDemo' sample program (Ver. 5.5.315.0)
Please help.
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: pdf delete after stream read
Hello npssystem,
Please provide the code sample of what you need to be done and then we'll further assist you.
Please provide the code sample of what you need to be done and then we'll further assist you.
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: pdf delete after stream read
Hi~!
Sample Code(xChange Editor Setup) :
C:\Program Files (x86)\Tracker Software\Editor SDK\Samples\CSharp\FullDemo\FullDemo.sln
1. 'IStream-Source Demo' CheckBox Checked in UI-Document Tab
2. 'Browse...' Button Select PDF File
3. 'Open' Button Click....
FileStream srcStream = new FileStream(tSrcToOpen.Text, FileMode.Open);
if (srcStream != null)
{
IStreamWrapper srcIStream = new IStreamWrapper(srcStream);
pdfCtl.OpenDocFrom(srcIStream);
}
4. Deleting Selected PDF File
<- Not be deleting.
'xChange Viewer' was possible stream open and delete file.
Sample Code(xChange Editor Setup) :
C:\Program Files (x86)\Tracker Software\Editor SDK\Samples\CSharp\FullDemo\FullDemo.sln
1. 'IStream-Source Demo' CheckBox Checked in UI-Document Tab
2. 'Browse...' Button Select PDF File
3. 'Open' Button Click....
FileStream srcStream = new FileStream(tSrcToOpen.Text, FileMode.Open);
if (srcStream != null)
{
IStreamWrapper srcIStream = new IStreamWrapper(srcStream);
pdfCtl.OpenDocFrom(srcIStream);
}
4. Deleting Selected PDF File
<- Not be deleting.
'xChange Viewer' was possible stream open and delete file.
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: pdf delete after stream read
In Viewer the opened stream was copied to temp file thus you could delete the original file.
In the Editor, the OpenDocFrom does not make a copy by default so you cannot delete the original file.
Also, you are using C# so the memory work is handled by the garbage collector which is it's downside.
In the Editor, the OpenDocFrom does not make a copy by default so you cannot delete the original file.
Also, you are using C# so the memory work is handled by the garbage collector which is it's downside.
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: pdf delete after stream read
'xChange Viewer' set option 'UseStreamDirectly'.
Is not copied temp file.
but, I can delete the stream opened PDF file.
Is there any way I delete a stream opened PDF file?
Please tell me how to delete the stream opend PDF file.
Is not copied temp file.
but, I can delete the stream opened PDF file.
Is there any way I delete a stream opened PDF file?
Please tell me how to delete the stream opend PDF file.
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: pdf delete after stream read
I don't believe it was possible to delete the original file in the Viewer with UseStreamDirectly.
If you can provide a sample of the Viewer's code with this kind of work routine then maybe we can manage to tell you how to do this in the Editor.
If you can provide a sample of the Viewer's code with this kind of work routine then maybe we can manage to tell you how to do this in the Editor.
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: pdf delete after stream read
Hi npssystem,
We've investigated this issue and it seems that it shouldn't work as it does right now in Viewer - the problem is with .Net memory manager and it will take a considerable amount of time to find the solution to it.
The correct behavior of this scenario is like we've described earlier.
If you can describe your problem more thoroughly then we'll try to find a solution that will meet your requirements.
We've investigated this issue and it seems that it shouldn't work as it does right now in Viewer - the problem is with .Net memory manager and it will take a considerable amount of time to find the solution to it.
The correct behavior of this scenario is like we've described earlier.
If you can describe your problem more thoroughly then we'll try to find a solution that will meet your requirements.
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: pdf delete after stream read
Hello, npssystem.
Thanks for sample project.
When you using the "UseStreamsDirecly=true" it means: if you opened pdf from stream then our pdfControl will remain the reference to this stream object passed by you, until the document will be closed. Remaining the reference to an original input stream - means blocking the corresponding file for deletion..
Regarding to your sample: we tried to get working example but couldn't. Problem is because NET's Garbage Collector catches the FileStream and IStreamWrapper objects and keeps alive them for long period even document is closed. We tried to lock the source file in way:
readStream = New FileStream(TextBoxSourceFileName.Text, FileMode.Open, FileAccess.ReadWrite, FileShare.Read)
// FileShare.Read - only reading of source file is allowed for other users while readStream is opened, deletion isn't allowed
...
UseStreamsDirectly = true
...
OpenDocument
// readStream.Close() -- we disabled this line because in readStream should be opened all time while document opened, in normal situation if you using UseStreamsDirectly=true...
// also we overrided destructor for IStreamWrapper
Protected Overrides Sub Finalize()
m_stream.Close()
m_stream = Nothing
End Sub
BUT after using of CloseAllDocuments() the IStreamWrapper/FileStream are still alive and original file still not closed because IStreamWrapper::Finalize isn't occured even source IStream is definitely released by our pdfControl...
-------
Only one solution I suggest for you - you may not use UseStreamsDirectly but manual control "lifetime" of the FileStream object:
1. readStream = New FileStream(TextBoxSourceFileName.Text, FileMode.Open, FileAccess.ReadWrite, FileShare.Read)
2. OpenDoc(IStreamWrapper(readStream)) // IStreamWrapper - without custom finalizing
3. Using of document...
4. CloseDoc with readStream.Close() to unlock the file object for other users in the system
-------
Unfortunately, but sometimes the GC isn't convenience but headache only..
Cheers.
Thanks for sample project.
When you using the "UseStreamsDirecly=true" it means: if you opened pdf from stream then our pdfControl will remain the reference to this stream object passed by you, until the document will be closed. Remaining the reference to an original input stream - means blocking the corresponding file for deletion..
Regarding to your sample: we tried to get working example but couldn't. Problem is because NET's Garbage Collector catches the FileStream and IStreamWrapper objects and keeps alive them for long period even document is closed. We tried to lock the source file in way:
readStream = New FileStream(TextBoxSourceFileName.Text, FileMode.Open, FileAccess.ReadWrite, FileShare.Read)
// FileShare.Read - only reading of source file is allowed for other users while readStream is opened, deletion isn't allowed
...
UseStreamsDirectly = true
...
OpenDocument
// readStream.Close() -- we disabled this line because in readStream should be opened all time while document opened, in normal situation if you using UseStreamsDirectly=true...
// also we overrided destructor for IStreamWrapper
Protected Overrides Sub Finalize()
m_stream.Close()
m_stream = Nothing
End Sub
BUT after using of CloseAllDocuments() the IStreamWrapper/FileStream are still alive and original file still not closed because IStreamWrapper::Finalize isn't occured even source IStream is definitely released by our pdfControl...
-------
Only one solution I suggest for you - you may not use UseStreamsDirectly but manual control "lifetime" of the FileStream object:
1. readStream = New FileStream(TextBoxSourceFileName.Text, FileMode.Open, FileAccess.ReadWrite, FileShare.Read)
2. OpenDoc(IStreamWrapper(readStream)) // IStreamWrapper - without custom finalizing
3. Using of document...
4. CloseDoc with readStream.Close() to unlock the file object for other users in the system
-------
Unfortunately, but sometimes the GC isn't convenience but headache only..
Cheers.
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.