LEADTOOLS Support
Document
Document SDK FAQ
HOW TO: use the Document Writer's progress event?
#1
Posted
:
Friday, February 16, 2018 12:06:38 PM(UTC)
Groups: Tech Support
Posts: 366
Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
The Document Writer has an
event that allows a developer to monitor the progress of document writer operations as well as cancel the operation if necessary.
When converting an LTD file to a desired output file, the percentage values occilate bewtween 0 & 100 multiple times. This is because the Document Writers are firing the progress event while going through each operation.
The following code illustrates each operation so you as the developer will know where the Document Writer is in the conversion & can indicate to the user with a progress bar & label what is happening.
Code:
int progressCounter = 0;
int progressPageNumber = 1;
docWriter.Progress += (sender, e) =>
{
if(progressCounter == 0) //Begin Document
{
Console.Write("\rBegin Document: {0}%", e.Percentage);
}
else if(progressCounter <= NUMBER_DOCUMENT_PAGES) //Processing page
{
Console.Write("\rProcessing Page #{0}: {1}%", progressPageNumber, e.Percentage);
if (e.Percentage == 100)
progressPageNumber++;
}
else if(progressCounter == (NUMBER_DOCUMENT_PAGES + 1)) //End document
{
Console.Write("\rFinalizing document - {0}%", e.Percentage);
}
if (e.Percentage == 100)
{
progressCounter++;
Console.WriteLine("");
}
};
This code will generate output like this:
Begin Document: 100%
Processing Page #1: 100%
Processing Page #2: 100%
Processing Page #3: 100%
Processing Page #4: 100%
Processing Page #5: 100%
Finalizing document - 100%
Edited by moderator Wednesday, December 27, 2023 3:11:25 PM(UTC)
| Reason: updated
Walter Bates
Senior Support Engineer
LEAD Technologies, Inc.
LEADTOOLS Support
Document
Document SDK FAQ
HOW TO: use the Document Writer's progress event?
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.