TWAIN Working Group

Newsletter Signup
Donate
Help keep TWAIN free
  • About TWAIN
    • What’s New?
    • News
    • Events
    • Membership
    • Consider a Donation
    • Contact Us
  • Why TWAIN?
  • Developers
    • Driver Developer
    • Application Developer
    • TWAIN Features
    • Specification & Tools
    • Self Certification Process
  • Support Forums
  • Scanner End-User
  • Find Certified Drivers
    • Facebook
    • LinkedIn
    • Vimeo

Transfer of PDF from C#

Forums › TWAIN Classic › Transfer of PDF from C#

  • This topic has 3 replies, 3 voices, and was last updated 5 years, 6 months ago by brianmanee.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • March 28, 2012 at 1:37 pm #22738 Reply
    sjuan76
    Participant
    • Topics - 1
    • Replies - 1
    • Total Posts - 2

    Hello everybody.

    I have a Kodak i1220+. I want to scan files and retrieve them as PDFs.

    I am using this project http://www.codeproject.com/Articles/171666/Twain-for-WPF-Applications-Look-Ma-No-Handles for my application.

    Right now, the first issue I see is that I get a memory buffer but no indication of its size, so I setup to add a TW_IMAGEMEMXFER structure and to import an appropiate function


    [StructLayout(LayoutKind.Sequential, Pack = 2)]
    internal class TwMemory
    {
    public int Flags;
    public int Length;
    public IntPtr TheMem;
    }

    [StructLayout(LayoutKind.Sequential, Pack = 2)]
    internal class TwImageMemXFer
    {
    public short Compression;
    public int BytesPerRow;
    public int Columns;
    public int Rows;
    public int XOffset;
    public int YOffset;
    public int BytesWritten;
    public TwMemory Memory;
    }


    [DllImport("twain_32.dll", EntryPoint = "#1")]
    private static extern TwRC DSmemxfer([In, Out] TwIdentity origin, [In] TwIdentity dest, TwDG dg, TwDAT dat, TwMSG msg,
    [In, Out] TwImageMemXFer pxfr);

    I added a call to my function right after the function that calls DG.Image / DAT.ImageNativeXFer / MSG.Get


    rc = DSixfer(appid, srcds, TwDG.Image, TwDAT.ImageNativeXfer, TwMSG.Get, ref hbitmap);
    if (rc != TwRC.XferDone)
    {
    CloseSrc();
    return pics;
    }

    rc = DSmemxfer( appid, srcds, TwDG.Image, TwDAT.ImageMemXfer, TwMSG.Get, pimagememx);
    if (rc != TwRC.Success)
    {
    CloseSrc();
    return pics;
    }

    All I get is a scanner driver error code 8739 (tested against a Ricoh NRG MP 161), and I have been left wondering if I somehow have made a mistake while implementing the function or it is other kind of error (v.g., not calling my function in the right moment).

    Any suggestions?

    Also if someone can points me to code that imports image in a format other than DIB/BMP it would be interesting.

    Thanks in advance.

    March 30, 2012 at 11:07 am #25559 Reply
    sjuan76
    Participant
    • Topics - 1
    • Replies - 1
    • Total Posts - 2

    Ok, I have been reading a little more and this time I didn’t skip the BOOORING parts of the spec, so I found it out.

    Just for the benefit of whoever finds this post, a brief answer:

    Twain has transfer modes, the native mode (TwDAT.ImageNativeXfer in my code) receives only an OS-dependent format; for example for windows a DIB image. From the header the application can retrieve the size of the image –> the number of bytes; so far I have seen no method that tells the size of the buffer returned by the native transfer mode.

    The TwDAT.ImageMemXfer just points that the transfer must be done using memory mode, which is a completely different transfer method. It returns a bitmap.

    To get the PDF (or other custom formats) from the scanner, one should use the DiskFile transfer mode.

    July 29, 2015 at 6:27 am #25560 Reply
    abbyleem3@yahoo.com
    Participant
    • Topics - 0
    • Replies - 9
    • Total Posts - 9

    You means you need to scan files to PDF with C#, right?
    I only know a PDF creating control with C#.
    So sorry I can’t help you.
    But welcome anyone to share solutions.

    August 12, 2015 at 8:19 am #25561 Reply
    brianmanee
    Participant
    • Topics - 0
    • Replies - 1
    • Total Posts - 1

    Hope this will help you…..PDF from C#

    Brian

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: Reply #25559 in Transfer of PDF from C#
Your information:




Quick Links

Service Providers
TWAIN Support Forums
Membership
Contact Us
Privacy Policy

Newsletter Signup

TWAIN Working Group Family

TWAIN Working Group
TWAIN Direct®
TWAIN Resources
TWAIN Certified Drivers
PDF/raster

  • Facebook
  • GitHub
  • LinkedIn
  • Vimeo

Recent Topics

  • Scanner starts transfer when console gets closed (CITRIX)
  • Kodak RFS 3600
  • Didn’t save enough file scan
  • EPSON V600 TWAIN and WIA on Windows 10
  • When and how to use WaitForEvents command ?
  • Quarterly Newsletter
  • TWAIN Working Group Membership
  • Logo Usage
  • TWAIN License
  • Contact Us
Privacy Policy • Privacy Tools • Copyright © 2021 TWAIN Working Group • by iHwy, LLC • Log in

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.