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

Need help with IMPRINTER

Forums › TWAIN Classic › Need help with IMPRINTER

  • This topic has 6 replies, 4 voices, and was last updated 11 years, 3 months ago by ScannerProgrammer.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • October 12, 2009 at 9:49 pm #22545 Reply
    ScannerProgrammer
    Participant
    • Topics - 7
    • Replies - 9
    • Total Posts - 16

    I have gotten as far as setting the capabilities for cap_printerenabled to true.

    However I need to be able to print a custom string ( date, scan document count etc)

    Once I set the printer_enabled where do I go from there?

    October 13, 2009 at 9:31 pm #25049 Reply
    gabe
    Participant
    • Topics - 9
    • Replies - 583
    • Total Posts - 592

    this is one of the areas of the spec that I never really understood, at least from the windows environment. with the number of devices that support this capability vs the number of non-twain solutions to doing this why do this in twain? I have similar views on multi-image tiff conversions (or really almost any sort of image filetype conversions) – do them outside of twain and avoid the vendor specific issues, leave the twain interaction to getting a valid image of high enough quality in low enough time..
    but then maybe I just never ‘got’ the value of these capabilities.

    Do you really need to do this in twain?

    .

    October 14, 2009 at 1:24 am #25050 Reply
    ScannerProgrammer
    Participant
    • Topics - 7
    • Replies - 9
    • Total Posts - 16

    The users that I work for would like to be able to print information on the back of scanned pages as to keep a physical record of things being scanned.

    I’m sure there are better and easier ways to accomplish this same goal but this is what they want so I have to give it to them.

    October 14, 2009 at 3:31 pm #25051 Reply
    Kaij
    Participant
    • Topics - 9
    • Replies - 132
    • Total Posts - 141

    You can set the text with the capability CAP_PRINTERSTRING. Please refer to page 9-70 of the TWAIN 2.0 specification.

    Best regards,

    Kaij

    October 14, 2009 at 4:33 pm #25052 Reply
    ScannerProgrammer
    Participant
    • Topics - 7
    • Replies - 9
    • Total Posts - 16

    This is what I have so far

    using TwainLib;

    if (HasCapability(CAPABILITIES.PRINTER))
    {
    SetCap(CAPABILITIES.PRINTER, (short)PRINTER.ENDORSER_BOTTOMAFTER);
    SetCap(CAPABILITIES.PRINTERENABLED, (short)BOOL.True);
    }

    if (HasCapability(CAPABILITIES.PRINTERINDEX))
    {
    SetCap(CAPABILITIES.PRINTERINDEX, (short)1);
    SetCap(CAPABILITIES.PRINTERMODE, (short)PRINTERMODE.SINGLESTRING);

    }

    all of that works but as far as printer string

    if(HasCapability(CAPABILITIES.PRINTERSTRING))
    {
    string date = DateTime.Today.ToString(“ddMMMyyyy”);

    Capability cp = new Capability(CAPABILITIES.PRINTERSTRING, TYPES.STR255, date);

    It takes me to this area

    public Capability(CAPABILITIES capName, TYPES iType, object value)
    {
    Cap = (short)capName;
    ConType = (short)CONTAINERS.ONEVALUE;
    Int32 strptr = default(Int32);
    switch (iType)
    {
    case TYPES.FIX32:
    conHandle = Marshal.AllocHGlobal(2 + Marshal.SizeOf(typeof(Fix32)));
    Marshal.WriteInt16(conHandle, 0, (short)iType);
    Marshal.WriteInt16(conHandle, 2, ((Fix32)value).Whole);
    Marshal.WriteInt16(conHandle, 4, (short)((Fix32)value).Frac);
    break;

    default:
    conHandle = GlobalMemory.GlobalAlloc(0x42, 6);
    IntPtr pv = GlobalMemory.GlobalLock(conHandle);
    Marshal.WriteInt16(pv, 0, (short)TYPES.INT16);
    Marshal.WriteInt32(pv, 2, Convert.ToInt32(value)); <--- errors here saying cannot convert string to int

    GlobalMemory.GlobalUnlock(conHandle);

    break;

    October 15, 2009 at 1:54 pm #25053 Reply
    jimwatters
    Participant
    • Topics - 2
    • Replies - 72
    • Total Posts - 74

    I am not familiar with the Marshal method you are using to allocate and fill the capability. But it looks to me that you are not allocating enough memory.

    There is an example in the spec in section 2-19 for STR32 that should be easy to change to STR255.

    Marshal.WriteInt32(pv, 2, Convert.ToInt32(value));

    If Value is a STR255 then you probably want to use a method similar to
    Marshal.WriteString(pv, 255, value);

    You might also want to do a MSG_GET on CAP_PRINTERSTRING and see what is supported. There might be some predefined strings in the enumeration.

    Regards,
    Jim Watters

    **************************************************
    JFL Peripheral Solutions Inc.
    http://www.jflinc.com/
    Your Expert Source of Custom Software and Services
    for TWAIN Applications, Data Sources,
    Peripheral Drivers and Support Software.
    **************************************************

    October 15, 2009 at 4:11 pm #25054 Reply
    ScannerProgrammer
    Participant
    • Topics - 7
    • Replies - 9
    • Total Posts - 16

    @jimwatters wrote:

    I am not familiar with the Marshal method you are using to allocate and fill the capability. But it looks to me that you are not allocating enough memory.

    There is an example in the spec in section 2-19 for STR32 that should be easy to change to STR255.

    Marshal.WriteInt32(pv, 2, Convert.ToInt32(value));

    If Value is a STR255 then you probably want to use a method similar to
    Marshal.WriteString(pv, 255, value);

    You might also want to do a MSG_GET on CAP_PRINTERSTRING and see what is supported. There might be some predefined strings in the enumeration.

    Regards,
    Jim Watters

    **************************************************
    JFL Peripheral Solutions Inc.
    http://www.jflinc.com/
    Your Expert Source of Custom Software and Services
    for TWAIN Applications, Data Sources,
    Peripheral Drivers and Support Software.
    **************************************************

    The marshal method just writes the handle into memory. My issue is I just need to see how someone (who has set an imprinter through code) did theirs.

    Parts of this twain spec are greek to me. Some others are easy to understand. This is the greek part.

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 total)
Reply To: Need help with IMPRINTER
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

  • Big Ass Photos – Free Huge Butt Porn, Big Booty Pics
  • EPSON V600 TWAIN and WIA on Windows 10
  • When and how to use WaitForEvents command ?
  • Problem enumerating list of installed scanners in windows server 2012
  • Failed to create TWAIN progress! Error code is 1260.
  • 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.