Rank: Newbie
Groups: Registered
Joined: 7/25/2018(UTC) Posts: 6 
|
I had this same problem with the old free PdfViewer Pdfium wrapper which instigated my purchase of your better SDK The problem is I use 3rd party PDF creation software and I need to itterate around create/view/create/view untill report is done Because both systems use the same filename for this I get filelocked errors (guess i could fil up the disk with tep files bt dotn want to) bit of code below shows the problem im facing Code:void Report_Generate(Object ^sender, EventArgs ^e)
{
Report_Initialise();
CalibrateStatusReport(0);
MoreStuff();
//////// Crashed here PDF file locked 2d time around
report->Publish(ReportFileName, exportFileFormat); // 3rd party generator
//////// loadDocument but leaves pdf locked
pdfViewer1->LoadDocument(Path::GetFullPath(ReportFileName),"");
//////// WHat i need is a way for LoadDocument to close the PDF after load :¬(
pdfViewer1->ClosePDFFileAfterLoadingIt(); // So its not locked
}
Any ideas? I belive its left open by the pdfium library but in c++ i dont know how to destroy the lock I guess i could recreate a new pdfviewer1 but i dunno if that would release the file lock anyway destryoing the old pdfviewer1 in C++/CLR is a bit wacky Im a bit of a noob so pleas help if you can Mac UPDATE>>>>>>>>>>>>>>>>>> found a brute force way to destroy the lock Code: if(pdfViewer1->Document!=nullptr)delete pdfViewer1->Document;
Not ideal realy would like LoadDocument to not lock the file afer its loaded Edited by moderator Thursday, July 26, 2018 3:03:02 AM(UTC)
| Reason: Not specified
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
Probably you noticed how even a very large PDF document with hundreds thousands of pages loads very fast. This becomes possible because there is not need to parse the entire document body. At first, only the cross-reference table is read and all the rest of data is loaded when needed. As a result, the document does not load into memory completely, the file remains locked and the document can not be changed after opening. In your case it is possible to do the follows Code: void Report_Generate(string ReportFileName)
{
reportPath.Publish(ReportFileName);
byte[] data = System.IO.File.ReadAllBytes(ReportFileName);
pdfViewer1.LoadDocument(data);
}
Of course, you can always close the document in the viewer before saving the report Code: void Report_Generate(string ReportFileName)
{
pdfViewer1.CloseDocument();
reportPath.Publish(ReportFileName);
pdfViewer1.LoadDocument(ReportFileName);
}
|
|
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 7/25/2018(UTC) Posts: 6 
|
Hi Paul,
Perfect answer :¬) Thank you for this fast support
|
|
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close