in

Archived Data Techniques Forums

Scan to File name and need literature

Last post 08-15-2008 9:02 AM by support. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 08-14-2008 4:44 PM

    Scan to File name and need literature

    Im looking to see how I can scan an image to a PDF file but I can not find any literature.  I have bought the PDF export addon and have imageman.net and twain. 

     

    How do I do it?

     

    And is there anywhere I can get some literature on what I can do with this code... the entry PDF docs dont say much.

  • 08-15-2008 9:02 AM In reply to

    Re: Scan to File name and need literature

    Hi,

     

    Basically you'll scan the image into an Image object and then use ImageMan.Net to save that object as a PDF file.

    There are several options for saving the file, the high level approach is to call the ImageCollection Save method and specify a filename to save with a .PDFextension. The low level approach would be to create an instance of the PDFEncoder class and then call the Save method.

     

    Here's some info on saving files from the help:

    ImageMan.Net supports saving images to files or .Net streams. Images can be saved using the Viewer control, the ImageCollection class or using an encoder class.

     

    Using the Viewer Control

    The overloaded Save method of the Viewer control provides the ability to save all or some of the  images in the Images collection to a file or a stream.  

     

    Saving a File using a default extension

    This method tries to determine the image Encoder to use by looking at the filename's extension. The extension specified must match that of one of the encoders in the RegisteredEncoders collection or an exception will be thrown.

    [C#]

    viewer1.Save( "file.png"); 

     

    [Visual Basic]

    viewer1.Save "file.png"

     

    Saving a File using a non standard extension or with custom attributes

    By creating a specific image Encoder you can control how the image is saved by setting any format specific properties such as the Quality factor in JPG or the Compression type in TIFF or PNG images.

     

    This method also allows you to save images into files using a non standard image extension.

     

    [C#]

    JpgEncoder jpg = new JpgEncoder(50);                // Set the JPG Quality factor to 50

    viewer1.Save("image.jpg", jpg);

     

    [Visual Basic]

    Dim jpg As JpgEncoder = New JpgEncoder(50)           ' Set the JPG Quality factor to 50

    viewer1.Save("image.jpg", jpg)


     

    Saving specific pages of a multi page image

    This overload of the Save method allows you to specify the range of pages to be saved. The parameter after the filename is the starting page index (0-based) and the next parameter is the number of pages to write. If the image format doesnt support multi page images then an exception will be thrown if you try to write > 1 page to a file.

     

    [C#]

    viewer1.Save( "image.png", 0, 2); 

     

    [Visual Basic]

    viewer1.Save "image.png", 0, 2

     

    Using the ImageCollection

    The overloaded Save method of the ImageCollection class provides the ability to save all or some of the images in the collection to a file or a stream just like the Save method of the Viewer class..  

     

    Saving a File using a default extension

    This method tries to determine the image Encoder to use by looking at the filename's extension. The extension specified must match that of one of the encoders in the RegisteredEncoders collection.

    [C#]

    imageCollection1.Save( "file.png"); 

     

    [Visual Basic]

    imageCollection.Save "file.png"

     

    Saving a File using a non standard extension or with custom attributes

    By creating a specific image Encoder you can control how the image is saved by setting any format specific properties such as the Quality factor in JPG or the Compression type in TIFF or PNG images.

     

    This method also allows you to save images into files using a non standard image extension.

     

    [C#]

    JpgEncoder jpg = new JpgEncoder(50);                // Set the JPG Quality factor to 50

    imageCollection.Save("fimage.jpg", jpg);

     

    [Visual Basic]

    Dim jpg As JpgEncoder = New JpgEncoder(50)           ' Set the JPG Quality factor to 50

    imageCollection.Save("fimage.jpg", jpg)

     

    Saving a page of a multi page image

    This overload of the Save method allows you to specify the range of pages to be saved. The parameter after the filename is the starting page index (0-based) and the next parameter is the number of pages to write. If the image format doesnt support multi page images then an exception will be thrown if you try to write > 1 page to a file.

     

    [C#]

    viewer1.Save( "file.png", 0, 2); 

     

    [Visual Basic]

    viewer1.Save "file.png", 0, 2

    Using an Image Encoder

    Saving images using an encoder object provides the most control over the image writing process. All encoders support the ImEncoder interface and those that support writing multi page files also support the ImMultiPageEncoder interface.

    In addition to the properties of the ImEncoder interface many encoders will include additional properties to support format specific options such as compression, types, etc.

     

    [C#]

    ImImage image;

    ...

    JpgEncoder jpg = new JpgEncoder(50);       // Create Jpeg Encoder with Quality Factor of 50

     

    FileStream stream = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read);

     

    jpg.Save( stream, image, null );                   // Save the image to the stream with no ProcessCallBack handler

     

    [Visual Basic]

    Dim image As ImImage

    ...

     

    Dim jpg As JpgEncoder = New JpgEncoder(50)           ' Create Jpeg Encoder with Quality Factor of 50

     

    Dim stream As FileStream = New FileStream(filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read)

     

    jpg.Save(stream, image, Nothing)                               ' Save the image to the stream with no ProcessCallBack handler

    Saving all the images in an ImageCollection using an encoder

     

    [C#]

     

    FileStream stream = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read);

     

    TifEncoder tif = new TifEncoder();

    tif.Compression = DTI.ImageMan.Codecs.Tif.Compression.Group4;

     

    foreach( ImImage img in Images ) {

    stream.Seek( 0, SeekOrigin.Begin );    // Seek back to 0 for each page of the image

    tif.Save( stream, img, null );

    }

     

    [Visual Basic]

    Dim stream As FileStream = New FileStream(filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read)

     

    Dim tif As TifEncoder = New TifEncoder()

    tif.Compression = DTI.ImageMan.Codecs.Tif.Compression.Group4

     

    For Each img As ImImage In Images

    stream.Seek(0, SeekOrigin.Begin)      ' Seek back to 0 for each page of the image

    tif.Save(stream, img, Nothing)           ' Save the image to the stream with no ProcessCallBack handler

    Next img

     

    Sean
    Data Techniques Online Support
Page 1 of 1 (2 items)
Copyright 2009 Data Techniques, Inc. All Rights Reserved.