Printing A Word Document
BlitzMax Forums/BlitzMax Programming/Printing A Word Document
| ||
Hi! I would like to print a Word (.doc) document from my program... but i haven't idea how to do it :( Can someone one help me? Thanks! |
| ||
I don't know the exact details of how to do this, but you can launch Word (on Windows) with the appropriate parameters via a system call. MS Office also provides APIs that you can use to 'automate' it or to integrate it into other applications. The MSDN Library will be able to give you all the details that you need: http://msdn2.microsoft.com/en-gb/library/default.aspx Of course, both ways only work when you have MS Office installed on your system. Printing Word documents without a local Word installation... I'm sure you don't want to go there. |
| ||
Here's some general printer stuff I made years ago for a userlib (its in C++) for Blitz+:-//Printer DLL //Written By Michael Denathorn 2005 //Sends text to the printer, also handle page breaks too #include <windows.h> #include <gdiplus.h> #include <stdio.h> using namespace Gdiplus; //Globals PRINTDLG pd; DOCINFO di; ULONG_PTR gdiToken; #define BBDECL extern "C" _declspec(dllexport) #define BBCALL _stdcall BBDECL int BBCALL _DabzOpenPrinter(void) { GdiplusStartupInput gdiplusStartupInput; GdiplusStartup(&gdiToken, &gdiplusStartupInput, NULL); ZeroMemory(&di, sizeof(di)); di.cbSize = sizeof(di); di.lpszDocName = "Dabz Printer Lib"; ZeroMemory(&pd, sizeof(pd)); pd.lStructSize = sizeof(pd); pd.Flags = PD_RETURNDC; if(!PrintDlg(&pd)) { printf("Failure\n"); return(0); } return(1); } BBDECL int BBCALL _DabzStartDoc(void) { StartDoc(pd.hDC, &di); return(1); } BBDECL int BBCALL _DabzStartPage(void) { StartPage(pd.hDC); return(1); } BBDECL int BBCALL _DabzEndPage(void) { EndPage(pd.hDC); return(1); } BBDECL int BBCALL _DabzEndDoc(void) { EndDoc(pd.hDC); return(1); } BBDECL int BBCALL _DabzClosePrinter(void) { if(pd.hDevMode) GlobalFree(pd.hDevMode); if(pd.hDevNames) GlobalFree(pd.hDevNames); if(pd.hDC) DeleteDC(pd.hDC); GdiplusShutdown(gdiToken); return(1); } BBDECL int BBCALL _DabzPrintText( const char *str, int posX, int posY) { TextOut(pd.hDC,posX,posY,str,strlen(str)); return(1); } Hope that helps in some way! :) Dabz |