I made a print preview for graphic/xprint that works great by writing to a text file 'commands' in the form of 4 letters surrounded by [ ]. with the rest of the
information following. the files were divided into report1.txt and so on for
report2.txt to reportn.txt for n pages.
Example:
"[FONT]Courier New,12,0"
"[SPOS]";STR$(5*72);",";STR$(6*120)
when read by the preview part it executes
GRAPHIC FONT Courier New,12,0
GRAPHIC SET POS (360,720)
when printed to printer it executes
XPRINT FONT Courier New,12,0
XPRINT SET POS (360,720)
There is a more detailed example somewhere in the
forums.
The one I currently use, no longer uses a scrollbar. Rather, I have a page down/page up button to view the bottom or
top of the page when zoomed in.
Announcement
Collapse
No announcement yet.
xprint to grapic print preview
Collapse
X
-
Yeah, I'm doing a print routine right now and it seems like I'm consuming several small forests in the process of getting everything just the way I want it. It would also be nice if one could do graphic windows with custom coordinates on the printer page, just like you can on the screen. This would make calculations for graphs vastly easier. Maybe in some future version
Leave a comment:
-
>A XPRINT graphic preview would sure be nice.
There is - or at least was - exactly one of those here somewhere.. written by Borje Hagsten. It was not only a print PREVIEW, it also did PRINT (on printer).
If you can't find it I think I have the source code here... somewhere.
MCM
Leave a comment:
-
A XPRINT graphic preview would sure be nice. I still use ddoc because
calculating all this stuff isn't easy. My number 1 wish list item would
be a XPRINT graphic designer. A form can be designed in RTF or HTML
format, but that is of no help, either since they aren't natively supported.
Leave a comment:
-
I dont know for sure, when I click the graphic window i get a flash then an empty dialog box. The preview works fine.
I made a small change to preview1 sub
Code:SUB previewprint 'using control add graphic LOCAL hGrWin AS LONG LOCAL LOGO AS STRING,L1 AS STRING,L2 AS STRING,L3 AS STRING, L4 AS STRING LOCAL TB1 AS SINGLE,tb2 AS SINGLE,TB3 AS SINGLE, TB4 AS SINGLE,TB5 AS SINGLE LOCAL x,y ,ncWidth,ncHeight AS SINGLE LOCAL I AS LONG GRAPHIC SCALE (1,1)-(80,66) LOCAL xx!,yy!,x1!,xleft!,y1!,ww!,hh! LOGO$="TOM SMITHSON NURSERY INC" L1$="8485 S.E. 282ND" L2$="GRANDVIEW, OREGON 97080" L3$="(503) 619-0860" L4$="FAX (503) 619-0861" TB1= (INT((88/2)-LEN(LOGO$)/2)/2) tb2 = INT((85/2)-LEN(L1$)/2) tb3 = INT((85/2)-LEN(L2$)/2) tb4 = INT((85/2)-LEN(L3$)/2) tb5 = INT((85/2)-LEN(L4$)/2) TB1= INT((79 -LEN(LOGO$))/2.4) tb2 = INT((79-LEN(L1$))/2) tb3 = INT((79-LEN(L2$))/2) tb4 = INT((79-LEN(L3$))/2) tb5 = INT((79-LEN(L4$))/2) GRAPHIC CLEAR RGB(255,255,255) GRAPHIC COLOR 0,RGB(255,255,255) ' FOR I = 1 TO 10 GRAPHIC PRINT :GRAPHIC PRINT GRAPHIC FONT "courier new",24,1 ' GRAPHIC GET POS TO x,y ' GRAPHIC SET POS (TB1,y) 'center the logo large text GRAPHIC GET POS TO x1!,y1! GRAPHIC TEXT SIZE LOGO$ TO xx!,yy! GRAPHIC GET CLIENT TO ww!,hh! x1!=(ww!-xx!)/2 GRAPHIC SET POS (x1!+xleft!,y1!) 'set the position plus left offset GRAPHIC PRINT LOGO$ 'print the text GRAPHIC FONT "Courier New",11,1 GRAPHIC GET POS TO x,y GRAPHIC SET POS (TB2,y) GRAPHIC PRINT L1$ GRAPHIC GET POS TO x,y GRAPHIC SET POS (TB3,y) GRAPHIC PRINT L2$ GRAPHIC GET POS TO x,y GRAPHIC SET POS (TB4,y) GRAPHIC PRINT L3$ GRAPHIC GET POS TO x,y GRAPHIC SET POS (TB5,y) GRAPHIC PRINT L4 ' NEXT END SUB
Leave a comment:
-
Thanks, Fred.
What I am after is a 1 to1 conversion from xprint to graphic print- the least amount of change possible.
I think the compiler writers must have had something like this in mind when the xprint and graphic print commands are almost identical.
I will keep on it for awhile. I have some ideas about pageinating in the graphic window.
I still do now know why I can see the printed text in my graphic window only once, unless I click on the preview button or exit the code altogether.
In the sample code for graphic window, the window is displayed for a given number of seconds, then is ended. How can I correctly hold the graphic window open until I choose to close it?
John Tate
Leave a comment:
-
John, what I did was take my original Report.txt that contains the command
'scripts' and divide it into report1.txt report2.txt etc for the pages. I tell the
program how many pages based on the FEEDs and the print them.
I have it working for most of the commands, even landscape as of this weekend. Most of my reports are written in pbdll6.0 or 6.1 and the preview print dll in 8.04.
I basically have a select clause for the preview and one for the xprint.
It has zoom in/out. I was thinking about selling it as a third-party program but just don't know how much interest there would be in it.
Some examples of reports i've printed with this preview print include not only financial statements which are mostly text,
but also 941 and 944 facsimile (Employer's Quarterly/annual withholding tax report), 940 facsimile (Federal Employer
Annual unemployment), W-2, 1099 facsimiles.Last edited by Fred Buffington; 28 Apr 2008, 04:40 PM.
Leave a comment:
-
xprint to grapic print preview
Since I just found my way around xprint stuff, it occurred to me that since the xprint commands were a lot like the graphic print commands, there might be a way to make a "print preview". After getting the xprint to paper correct, why not copy that routine to a new preview routine, do a find and replace xprint for graphic, then add the word, print, where necessary for the output, and you have yourself a preview showing in a graphic window.
It works fine for one "page" (one window's worth), but I am at a loss as to how to pageinate the data in either a graphic window or a "blank" graphic.
Also, when calling the sub using a graphic window, text is only printed once, unless I exit the program and view again. It will not print the text the second time, if I stay in the program.
I cobbled together some sample code to demonstrate.
Code:#PBFORMS CREATED V1.50 '------------------------------------------------------------------------------ ' The first line in this file is a PB/Forms metastatement. ' It should ALWAYS be the first line of the file. Other ' PB/Forms metastatements are placed at the beginning and ' end of "Named Blocks" of code that should be edited ' with PBForms only. Do not manually edit or delete these ' metastatements or PB/Forms will not be able to reread ' the file correctly. See the PB/Forms documentation for ' more information. ' Named blocks begin like this: #PBFORMS BEGIN ... ' Named blocks end like this: #PBFORMS END ... ' Other PB/Forms metastatements such as: ' #PBFORMS DECLARATIONS ' are used by PB/Forms to insert additional code. ' Feel free to make changes anywhere else in the file. '------------------------------------------------------------------------------ #COMPILE EXE #DIM ALL '------------------------------------------------------------------------------ ' ** Includes ** '------------------------------------------------------------------------------ #PBFORMS BEGIN INCLUDES #IF NOT %DEF(%WINAPI) #INCLUDE "WIN32API.INC" #ENDIF #PBFORMS END INCLUDES '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ ' ** Constants ** '------------------------------------------------------------------------------ #PBFORMS BEGIN CONSTANTS %IDD_DIALOG1 = 101 %IDC_BUTTON1 = 1001 %IDCANCEL = 2 %IDD_DIALOG2 = 102 %idc_graphic1 = 1002 %IDC_PREVIEW = 1003 %IDC_BUTTON2 = 1004 %IDC_BUTTON3 = 1005 %IDC_SCROLLBAR1 = 1006 #PBFORMS END CONSTANTS '------------------------------------------------------------------------------ GLOBAL gInvoicenum AS LONG '------------------------------------------------------------------------------ ' ** Declarations ** '------------------------------------------------------------------------------ DECLARE CALLBACK FUNCTION ShowDIALOG1Proc() DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG DECLARE CALLBACK FUNCTION ShowDIALOG2Proc() DECLARE FUNCTION ShowDIALOG2(BYVAL hDlg AS DWORD) AS LONG #PBFORMS DECLARATIONS '------------------------------------------------------------------------------ DECLARE SUB COMPANYLOGO DECLARE SUB previewprint DECLARE SUB previewprint2 '------------------------------------------------------------------------------ ' ** Main Application Entry Point ** '------------------------------------------------------------------------------ FUNCTION PBMAIN() ShowDIALOG1 %HWND_DESKTOP END FUNCTION '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ ' ** CallBacks ** '------------------------------------------------------------------------------ CALLBACK FUNCTION ShowDIALOG1Proc() LOCAL hGrwin AS LONG SELECT CASE AS LONG CBMSG CASE %WM_INITDIALOG ' Initialization handler CASE %WM_NCACTIVATE STATIC hWndSaveFocus AS DWORD IF ISFALSE CBWPARAM THEN ' Save control focus hWndSaveFocus = GetFocus() ELSEIF hWndSaveFocus THEN ' Restore control focus SetFocus(hWndSaveFocus) hWndSaveFocus = 0 END IF CASE %WM_COMMAND ' Process control notifications SELECT CASE AS LONG CBCTL ' /* Inserted by PB/Forms 04-27-2008 19:19:10 CASE %IDC_BUTTON3 'graphic print to graphic window IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN previewprint2 END IF ' */ ' /* Inserted by PB/Forms 04-26-2008 21:42:00 CASE %IDC_PREVIEW 'graphic print to blank graphic IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN showdialog2(CBHNDL) END IF ' */ CASE %IDC_BUTTON1 'xprint to paper IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN COMPANYLOGO END IF CASE %IDCANCEL IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN DIALOG END CBHNDL, 0 END IF END SELECT END SELECT END FUNCTION '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ ' ** Dialogs ** '------------------------------------------------------------------------------ FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG LOCAL lRslt AS LONG #PBFORMS BEGIN DIALOG %IDD_DIALOG1->-> LOCAL hDlg AS DWORD DIALOG NEW hParent, "Dialog1", 70, 70, 265, 121, TO hDlg CONTROL ADD BUTTON, hDlg, %IDC_BUTTON1, "print", 20, 65, 50, 15 CONTROL ADD BUTTON, hDlg, %IDCANCEL, "exit", 100, 100, 50, 15 CONTROL ADD BUTTON, hDlg, %IDC_PREVIEW, "PREVIEW", 100, 65, 50, 15 CONTROL ADD BUTTON, hDlg, %IDC_BUTTON3, "GRAPHWINDOW", 175, 65, 75, 15 #PBFORMS END DIALOG DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt #PBFORMS BEGIN CLEANUP %IDD_DIALOG1 #PBFORMS END CLEANUP FUNCTION = lRslt END FUNCTION '------------------------------------------------------------------ '---------------------------------------- SUB COMPANYLOGO LOCAL LOGO AS STRING,L1 AS STRING,L2 AS STRING,L3 AS STRING, L4 AS STRING LOCAL TB1 AS SINGLE,tb2 AS SINGLE,TB3 AS SINGLE, TB4 AS SINGLE,TB5 AS SINGLE LOCAL x,y AS SINGLE XPRINT ATTACH DEFAULT XPRINT SCALE (1,1)-(80,66) LOGO$="TOM SMITHSON NURSERY INC" L1$="8485 S.E. 282ND" L2$="GRANDVIEW, OREGON 97080" L3$="(503) 619-0860" L4$="FAX (503) 619-0861" TB1= (INT((88/2)-LEN(LOGO$)/2)/2) tb2 = INT((85/2)-LEN(L1$)/2) tb3 = INT((85/2)-LEN(L2$)/2) tb4 = INT((85/2)-LEN(L3$)/2) tb5 = INT((85/2)-LEN(L4$)/2) 'tb1= 7 XPRINT:XPRINT XPRINT GET POS TO x,y XPRINT SET POS (tb1+3,y) XPRINT FONT "courier new",24,1 XPRINT LOGO$ XPRINT FONT "courier new",11,1 XPRINT GET POS TO x,y XPRINT SET POS (tb2,y) XPRINT L1$ XPRINT GET POS TO x,y XPRINT SET POS (tb3,y) XPRINT L2$ XPRINT GET POS TO x,y XPRINT SET POS (tb4,y) XPRINT L3$ XPRINT GET POS TO x,y XPRINT SET POS (tb5,y) XPRINT L4$ XPRINT CLOSE END SUB ' 10 lines used here '------------------------------------------------------------------------------ CALLBACK FUNCTION ShowDIALOG2Proc() SELECT CASE AS LONG CBMSG CASE %WM_INITDIALOG ' Initialization handler GRAPHIC ATTACH CBHNDL, %idc_graphic1 previewprint CASE %WM_NCACTIVATE STATIC hWndSaveFocus AS DWORD IF ISFALSE CBWPARAM THEN ' Save control focus hWndSaveFocus = GetFocus() ELSEIF hWndSaveFocus THEN ' Restore control focus SetFocus(hWndSaveFocus) hWndSaveFocus = 0 END IF CASE %WM_COMMAND ' Process control notifications SELECT CASE AS LONG CBCTL ' /* Inserted by PB/Forms 04-27-2008 19:44:12 CASE %IDC_SCROLLBAR1 ' */ ' /* Inserted by PB/Forms 04-27-2008 17:40:34 CASE %IDC_BUTTON2 IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN END IF ' */ ' /* Inserted by PB/Forms 04-26-2008 21:42:00 CASE %idc_graphic1 ' */ ' /* Inserted by PB/Forms 04-26-2008 21:37:32 CASE %IDCANCEL IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN DIALOG END CBHNDL, 0 END IF ' */ END SELECT END SELECT END FUNCTION '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ FUNCTION ShowDIALOG2(BYVAL hParent AS DWORD) AS LONG LOCAL lRslt AS LONG #PBFORMS BEGIN DIALOG %IDD_DIALOG2->-> LOCAL hDlg AS DWORD DIALOG NEW hParent, "Dialog2", 4, 47, 672, 386, %WS_POPUP OR %WS_BORDER _ OR %WS_DLGFRAME OR %WS_CLIPSIBLINGS OR %WS_VSCROLL OR %WS_VISIBLE OR _ %DS_MODALFRAME OR %DS_CENTER OR %DS_3DLOOK OR %DS_NOFAILCREATE OR _ %DS_SETFONT, %WS_EX_WINDOWEDGE OR %WS_EX_CONTROLPARENT OR _ %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg CONTROL ADD GRAPHIC, hDlg, %idc_graphic1, "print preview", 10, 15, 500, 350, _ %WS_CHILD OR %WS_VISIBLE, %WS_EX_LEFT OR %WS_EX_LTRREADING OR _ %WS_EX_RIGHTSCROLLBAR CONTROL ADD BUTTON, hDlg, %IDCANCEL, "exit", 470, 365, 50, 15 CONTROL ADD BUTTON, hDlg, %IDC_BUTTON2, "next page", 340, 365, 55, 15 #PBFORMS END DIALOG DIALOG SHOW MODAL hDlg, CALL ShowDIALOG2Proc TO lRslt #PBFORMS BEGIN CLEANUP %IDD_DIALOG2 #PBFORMS END CLEANUP FUNCTION = lRslt END FUNCTION '------------------------------------------------------------------------------ SUB previewprint 'using control add graphic LOCAL hGrWin AS LONG LOCAL LOGO AS STRING,L1 AS STRING,L2 AS STRING,L3 AS STRING, L4 AS STRING LOCAL TB1 AS SINGLE,tb2 AS SINGLE,TB3 AS SINGLE, TB4 AS SINGLE,TB5 AS SINGLE LOCAL x,y ,ncWidth,ncHeight AS SINGLE LOCAL I AS LONG GRAPHIC SCALE (1,1)-(80,66) LOGO$="TOM SMITHSON NURSERY INC" L1$="8485 S.E. 282ND" L2$="GRANDVIEW, OREGON 97080" L3$="(503) 619-0860" L4$="FAX (503) 619-0861" TB1= (INT((88/2)-LEN(LOGO$)/2)/2) tb2 = INT((85/2)-LEN(L1$)/2) tb3 = INT((85/2)-LEN(L2$)/2) tb4 = INT((85/2)-LEN(L3$)/2) tb5 = INT((85/2)-LEN(L4$)/2) TB1= INT((79 -LEN(LOGO$))/2.4) tb2 = INT((79-LEN(L1$))/2) tb3 = INT((79-LEN(L2$))/2) tb4 = INT((79-LEN(L3$))/2) tb5 = INT((79-LEN(L4$))/2) FOR I = 1 TO 10 GRAPHIC PRINT :GRAPHIC PRINT GRAPHIC FONT "courier new",24,1 GRAPHIC GET POS TO x,y GRAPHIC SET POS (TB1,y) GRAPHIC PRINT LOGO$ GRAPHIC FONT "Courier New",11,1 GRAPHIC GET POS TO x,y GRAPHIC SET POS (TB2,y) GRAPHIC PRINT L1$ GRAPHIC GET POS TO x,y GRAPHIC SET POS (TB3,y) GRAPHIC PRINT L2$ GRAPHIC GET POS TO x,y GRAPHIC SET POS (TB4,y) GRAPHIC PRINT L3$ GRAPHIC GET POS TO x,y GRAPHIC SET POS (TB5,y) GRAPHIC PRINT L4 NEXT END SUB '------------------------------------------ SUB previewprint2 'using graphic window LOCAL hGrWin AS LONG LOCAL LOGO AS STRING,L1 AS STRING,L2 AS STRING,L3 AS STRING, L4 AS STRING LOCAL TB1 AS SINGLE,tb2 AS SINGLE,TB3 AS SINGLE, TB4 AS SINGLE,TB5 AS SINGLE LOCAL x,y ,ncWidth,ncHeight AS SINGLE LOCAL I AS LONG GRAPHIC WINDOW "print preview",5,5,900,500 TO hGrWin GRAPHIC ATTACH hGrWin,0,REDRAW GRAPHIC SCALE (1,1)-(80,66) LOGO$="TOM SMITHSON NURSERY INC" L1$="8485 S.E. 282ND" L2$="GRANDVIEW, OREGON 97080" L3$="(503) 619-0860" L4$="FAX (503) 619-0861" TB1= (INT((88/2)-LEN(LOGO$)/2)/2) tb2 = INT((85/2)-LEN(L1$)/2) tb3 = INT((85/2)-LEN(L2$)/2) tb4 = INT((85/2)-LEN(L3$)/2) tb5 = INT((85/2)-LEN(L4$)/2) TB1= INT((79 -LEN(LOGO$))/2.4) tb2 = INT((79-LEN(L1$))/2) tb3 = INT((79-LEN(L2$))/2) tb4 = INT((79-LEN(L3$))/2) tb5 = INT((79-LEN(L4$))/2) FOR I = 1 TO 10 GRAPHIC PRINT :GRAPHIC PRINT GRAPHIC FONT "courier new",24,1 GRAPHIC GET POS TO x,y GRAPHIC SET POS (TB1,y) GRAPHIC PRINT LOGO$ GRAPHIC FONT "Courier New",11,1 GRAPHIC GET POS TO x,y GRAPHIC SET POS (TB2,y) GRAPHIC PRINT L1$ GRAPHIC GET POS TO x,y GRAPHIC SET POS (TB3,y) GRAPHIC PRINT L2$ GRAPHIC GET POS TO x,y GRAPHIC SET POS (TB4,y) GRAPHIC PRINT L3$ GRAPHIC GET POS TO x,y GRAPHIC SET POS (TB5,y) GRAPHIC PRINT L4 NEXT END SUB
Tags: None
Leave a comment: