Article View: borland.public.cppbuilder.nativeapi
Article #14877Re: How to use postscript inside BCB to print graphics ?
From: Richard Yu
Date: Tue, 29 Jul 2003 16:27
Date: Tue, 29 Jul 2003 16:27
117 lines
4964 bytes
4964 bytes
thanks,
that's the pOutputFile problem,
"Vladimir Afanasyev" <avv@systema.kiev.ua> wrote in message
news:3f26304d$1@newsgroups.borland.com...
>
> Hi,
> Your code incorrect.
> This way you try send data in file with stange name "ffff".
> Another problem place it is testing result of OpenPrinter Win32
> API function - "else" if name of printer incorrect:
>
> BOOL RetCode = FALSE;
> HANDLE Printer = NULL;
> LPTSTR aName="Xerox Phaser 8200DX";
> LPCSTR Str="test me";
> DWORD err;
> if (OpenPrinter(aName, &Printer, NULL))
> {
> DWORD Jobid = 0;
> DOC_INFO_1 DocInfo = {0};
>
> DocInfo.pDocName = "The Document Name";
> DocInfo.pOutputFile = NULL;
> if ((Jobid = StartDocPrinter(Printer, 1, (LPBYTE) &DocInfo)) != 0)
> {
> DWORD Written;
> DWORD NumBytes = lstrlen(Str);
>
> WritePrinter(Printer, (void*) Str, NumBytes, &Written);
>
> if (Written == NumBytes)
> RetCode = TRUE;
>
> }
>
> EndDocPrinter(Printer);
> ClosePrinter(Printer);
> }
> else
> {
> err=GetLastError();
> if(err==ERROR_INVALID_PRINTER_NAME)ShowMessage("Invalid Printer
Name");
> else ShowMessage("Error:"+IntToStr(err));
> }
>
> Similar code works on my PC for LaserJet. Using next code you
> can test is it printer support Postscript:
>
>
> HANDLE hPrinter;
> PRINTDLG pd;
> DEVMODE *dv;
> int nEscapeCode;
> TCHAR szTechnology[MAX_PATH] = TEXT("");
>
> ZeroMemory(&pd, sizeof(PRINTDLG));
> pd.lStructSize = sizeof(PRINTDLG);
> pd.hwndOwner = GetDesktopWindow();
> pd.hDevMode = NULL; // Don't forget to free or store hDevMode.
> pd.hDevNames = NULL; // Don't forget to free or store hDevNames.
> pd.Flags = PD_RETURNDC ;
> pd.nCopies = 4;
> pd.nFromPage = 0xFFFF;
> pd.nToPage = 0xFFFF;
> pd.nMinPage = 1;
> pd.nMaxPage = 0xFFFF;
>
>
> if (PrintDlg(&pd)==TRUE) {
>
> dv=(LPDEVMODE)pd.hDevMode;
> char** Name=(char**)dv->dmDeviceName;
> ShowMessage(AnsiString((const char*)*Name));
> Edit1->Text=AnsiString((const char*)*Name);
> // If it supports POSTSCRIPT_PASSTHROUGH, it must be PS.
> nEscapeCode = POSTSCRIPT_PASSTHROUGH;
> if( ExtEscape( pd.hDC, QUERYESCSUPPORT, sizeof(int),
> (LPCSTR)&nEscapeCode, 0, NULL ) > 0 )
> {ShowMessage("Escape POSTSCRIPT_PASSTHROUGH is
supported" );
> return;}
>
> ShowMessage("Escape POSTSCRIPT_PASSTHROUGH is not
supported" );
> // If it doesn't support GETTECHNOLOGY, we won't be able to
tell.
> nEscapeCode = GETTECHNOLOGY;
> if( ExtEscape( pd.hDC, QUERYESCSUPPORT, sizeof(int),
> (LPCSTR)&nEscapeCode, 0, NULL ) <= 0 )
> {ShowMessage("Escape GETTECHNOLOGY is not
supported" );
> return;}
> ShowMessage("Escape GETTECHNOLOGY is supported" );
>
> // Get the technology string and check to see if the
word"postscript" is in it.
> if( ExtEscape( pd.hDC, GETTECHNOLOGY, 0, NULL, MAX_PATH,
> (LPSTR)szTechnology ) <= 0 )
> return;
> strupr( szTechnology );
> if( strstr( szTechnology, "POSTSCRIPT" ) == NULL )
> {
> ShowMessage("postscript is not supported" );
> ShowMessage(AnsiString("Using technology
is:")+szTechnology);
> return;}
>
> ShowMessage("postscript is supported" );
> ShowMessage(AnsiString("Using technology
is:")+szTechnology);
> }
>
> Vladimir.
>
Technical Details
Message-ID:
<3f26a12b$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3f2554be$1@newsgroups.borland.com> <3f255bd6$1@newsgroups.borland.com> <3f257a84$1@newsgroups.borland.com> <3f26304d$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,434d7e072e9595a X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-07-29 09:32:24 PST From: "Richard Yu" <richard@colorselector.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3f2554be$1@newsgroups.borland.com> <3f255bd6$1@newsgroups.borland.com> <3f257a84$1@newsgroups.borland.com> <3f26304d$1@newsgroups.borland.com> Subject: Re: How to use postscript inside BCB to print graphics ? Date: Tue, 29 Jul 2003 09:27:09 -0700 Lines: 119 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 NNTP-Posting-Host: 24.207.7.224 Message-ID: <3f26a12b$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1059496235 24.207.7.224 (29 Jul 2003 09:30:35 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail