VintaSoft Twain .NET SDK Discussions
Questions, comments and suggestions concerning VintaSoft Twain .NET SDK.
Board index < VintaSoft Twain < VintaSoft Twain .NET SDK Discussions
try
{
vsTwain1.StartDevice();
vsTwain1.ShowUI = false;
if (vsTwain1.SelectSource())
{
vsTwain1.DisableAfterAcquire = true;
vsTwain1.MaxImages = 1;
vsTwain1.AutoCleanBuffer = true;
vsTwain1.OpenDataSource();
vsTwain1.PixelType = PixelType.BW;
if (vsTwain1.FeederPresent)
{
vsTwain1.FeederEnabled = true;
vsTwain1.AutoFeed = true;
vsTwain1.XferCount = 1;
vsTwain1.PdfMultiPage = false;
if (vsTwain1.FeederLoaded)
{
vsTwain1.ShowIndicators = true;
//if (vsTwain1.AcquireModal()) - wrong code
while (vsTwain1.AcquireModal()) - correct code
{
try
{
this.Cursor = Cursors.WaitCursor;
MemoryStream mem = new MemoryStream();
mem = vsTwain1.GetImageAsStream(0, ImageFileFormat.PDF);
string dirPath = "\\\\192.168.254.5\\RelatedDocuments\\EmployerDocuments\\" + myController.CurrentEmployer.Office + "\\";
string dateString = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString("00") + DateTime.Now.Day.ToString("00");
string filePath = myController.CurrentEmployer.EmployerId + dateString + ".pdf";
myController.SaveScannedRecord(Int32.Parse(ScanItemTypeComboBox.SelectedValue.ToString()), filePath);
vsTwain1.SaveImage(0, dirPath + filePath);
}
catch (TwainException ex)
{
MessageBox.Show(ex.Message);
}
}
vsTwain1.StopDevice();
MessageBox.Show("Scan completed.");
}
}
}
Best regards, Alexander
Do I need to set the MaxImages property to the number of pages being scanned?Yes, you should set the MaxImages property if you want to store pages in the internal buffer of the library but make sure that you have enough memory. The best way is to store images in the MemoryStream or file.
Well I have it now scanning multiple pages and creating only one pdf file but it always only saves the last page.What scanner do you have? Maybe Brother?