none
Examples, or guiidance on sending a docx file to a thermal receipt printer? RRS feed

  • Question

  • I bought a USB thermal receipt printer, and now trying to understand how to send templated docx files to for printing. It seems to be harder than it should.  Anyone got some suggestions on  places to look for a guide or something? 

    I have been searching, but I am not coming up with anything which I consider helpful.

    All I want to do is the send the file to the printer when needed, and in the background.

    I tried  Gembox free version, but it seems their idea of what a "paragraph" consists of is a bit skewed, and not looking to put out several hundred for their library

    I do have Office/Word installed if that helps.

    Thanks!

    Sunday, October 7, 2018 10:40 PM

All replies

  • Although not "thermal receipt printer", in my experience of using label printer, you just add the correct paper size to the "printer management", then select the correct paper size in Word Automation, and it would be printed correctly.

    Monday, October 8, 2018 1:48 AM
    Answerer
  • While I do appreciate the response, but I don't see how  just setting the paper size is not printing a file. In addition, while all the receipts will be of the same width, they will not be the same length.

    • Edited by KNERDY Monday, October 8, 2018 2:42 AM
    Monday, October 8, 2018 2:36 AM
  • Well, "and it would be printed correctly" means if you follow the forementioned steps, it should enable you to print the document correctly. Of course you still have to print it. And I just describe what I did on the "label printer" case.

    Do you know that you can have different paper size setting in Word sections?

    Maybe you can set the PaperSize to wdPaperCustom (41) and then set the PageWidth and PageHeight accordingly.


    Monday, October 8, 2018 2:56 AM
    Answerer
  • Hi KNERDY,

    Thank you for posting here.

    For your question, you could download the source file from the code project for reference about how to print word.

    https://www.codeproject.com/Articles/20287/Generating-Word-Reports-Documents

    https://www.codeproject.com/Articles/10180/How-to-print-text-in-C

    https://www.codeproject.com/Articles/10999/Printing-Word-Documents-in-C

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Stanly Fan Tuesday, October 9, 2018 3:20 AM
    • Unproposed as answer by KNERDY Thursday, October 11, 2018 9:51 PM
    Monday, October 8, 2018 6:10 AM
    Moderator
  • Thank you Wendy. I will study this.
    Monday, October 8, 2018 11:28 PM
  • Hi KNERDY,

    If your question has been solved, please mark the useful reply as answer to close the thread. This will make answer searching easier in the forum and be beneficial to community members.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, October 9, 2018 1:56 AM
    Moderator
  • At first I just took a quick glance at that link you paste here. Upon a further look, you do realize this is a C# forum section?
    Tuesday, October 9, 2018 11:30 PM
  • Hi KNERDY,

    This is C# forum. I provide some suggestion using C#. If you do not want to do that using C#, please provide more information, I will move it to suitable forum. 

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, October 10, 2018 6:48 AM
    Moderator
  • Hello Wendy. The response was to the others who posted a link to c++ examples.
    Thursday, October 11, 2018 3:42 PM
  • Hello Wendy. Only one of the examples you provided contains about sending a document to a printer.

    However, as being new to c#, I find the example a bit poor. It seems many examples presume everyone knows what libraries they need to use. That example includes no such thing. 

    In addition, the example is using Word.ApplicationClass

    According to a Microsoft Blog,

    "A comment on Mike Howard's blog exhibits a common problem that I see time and time again: developers are creating instances of Word.ApplicationClass or Excel.ApplicationClass in their projects.

    Even though it's the wrong thing to do, I don't blame them for doing that. I blame IntelliSense."

    What is up with that?

    I also see Word.ApplicationClass is a part of the Microsoft.Office.Interop.Word Namespace, but VS 2017 cannot find such a namespace, nor is intellisence offering up anything.

    Edit: I see that kink you provided for printing indicates "Add Reference to its COM component and develop against these." I am not seeing  Microsoft.Office.Interop.Word in COM, nor in Assemblies even though I do have Office 2016 installed locally.





    • Edited by KNERDY Friday, October 12, 2018 3:44 AM
    Thursday, October 11, 2018 3:46 PM
  • There aren't much difference when talking about COM automation, as long as I give you the namespace of the class and the relevent class member names to use.

    And btw, did you realize that there is "programming language selector" on the upper right corner of the page? When you first access the page it's defaulted to C++, but after you change that once it'll default to the new language of your choice. There aren't anything on the URL that I aware of which can change the selection when the page is first loaded.

    I don't really expect that I have to teach you how to use docs.microsoft.com pages.




    Friday, October 12, 2018 1:06 AM
    Answerer
  • Hi KNERDY,

    For the Word.Application, please refer to the link below.

    https://docs.microsoft.com/en-us/dotnet/api/microsoft.office.interop.word.applicationclass?view=word-pia

    If it still show C++, please change the language. I make a gif about how to change the language.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, October 12, 2018 7:11 AM
    Moderator
  • Well, they seem to have changed the pages. In the past the examples, and usage were all in one page, and the change language is very small up in the corner where I was not expecting it.
    Friday, October 12, 2018 2:40 PM

  • Still does not help on how to get the COM into the project because as I said, I cannot find it despite Office 2016 being installed.
    Friday, October 12, 2018 6:00 PM
  • @Knerdy,

    If the thermal printer that you purchased has a standard print driver you can print directly from Microsoft Word.  Both Epson and Star Micronics offer print drivers for thermal printers, but you did not say which printer you are working with so I do not know if this will be of any help.

    Otherwise, printing to thermal printers typically requires a PointOfService API which is intended for printing receipts.

    Terry Warwick, Microsoft

    Monday, October 15, 2018 1:54 PM
  • I would rather do printing in the background.

    I will research the PointofService API

    Thank you

    Wednesday, October 17, 2018 7:44 PM
  • Hi KNERDY,

    If your question has been solved, please mark the useful reply as answer to close the thread. This will make answer searching easier in the forum and be beneficial to community members.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, October 18, 2018 8:38 AM
    Moderator