Announcement

Collapse
No announcement yet.

Josef Print Problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Josef Print Problem


    I moved Josef's question here...

    Josef, once I change the variable "pos" to "xpos" (because in PBWin10, POS is a reserved word), the program prints on this end. Some kind of Holiday-Inn info with Mary/Rudolf in the name and an address. Does that sound like the right information?

    I didn't try it with a picture.

    Code:
    Dear Gary,
    I upgraded from PBWIN8 to PBWIN10 and have some problems to run a program in the enclosure.
    Nothing is printed using PBWIN10. Using PBWIN8 al is ok.
    This is a letter header with pictures and text from a file: All together should be printed out.
    Can you / anybody help me please to start this programm with PBWIN10, please?
    
    code here:
    'briefkopfdrucken.bas Stand: 14.11.2006 ufb!!! f. RHO
    ' Falzkante eingefügt: ok!!
    #COMPILE EXE
    $DIM ALL
    $INCLUDE "win32api.inc" 'pb=Paperbreite in pkt.
    GLOBAL nfile&, Datumheute$, Datum$, xp AS LONG, winxp AS LONG, winver$, cm AS LONG, pb AS LONG
    
    'vorgegebene Funktion: cm in ppi umwandeln
    FUNCTION CM2PPI(cXY AS STRING ,nCM AS SINGLE) AS SINGLE
    LOCAL x&, y&
    XPRINT GET PPI TO x&, y&
    SELECT CASE cXY
    CASE "x","X"
    CM2PPI = nCM * x& / 2.54
    CASE "y","Y"
    CM2PPI = nCM * y& / 2.54
    CASE ELSE
    CM2PPI = 0
    END SELECT
    END FUNCTION
    
    'vorgegebene Funktion: ppi in cm umwandeln
    FUNCTION PPI2CM(cXY AS STRING ,nPoints AS SINGLE) AS SINGLE
    LOCAL x&, y&
    XPRINT GET PPI TO x&, y&
    SELECT CASE cXY
    CASE "x","X"
    PPi2CM = nPoints / x& * 2.54
    CASE "y","Y"
    PPi2CM = nPoints / y& * 2.54
    CASE ELSE
    PPi2CM = 0
    END SELECT
    END FUNCTION
    
    'vorgegebene Funktion: ppi in mm umwandeln
    FUNCTION PPI2MM(cXY AS STRING ,nPoints AS SINGLE) AS SINGLE
    PPi2MM = PPI2CM(cXY,nPoints) * 10
    END FUNCTION
    
    
    'vorgegebene Funktion: Betriebssystem feststellen:
    
    
    ' ab hier beginnt die eigene Entwicklerarbeit: heutiges Datum ins richtige Format setzen:
    SUB HeuteDatum
    LOCAL tag AS STRING
    LOCAL month AS STRING
    tag=MID$(DATE$,4,2)
    month=LEFT$(DATE$,2)
    IF LEFT$(month,1)="0" THEN
    month=RIGHT$(month,1)
    END IF
    Datumheute$=tag+". "+month+". "+RIGHT$(DATE$,4)
    Datum$=Datumheute$
    END SUB
    
    ' hier wird die Seite aufgebaut und gedruckt:
    FUNCTION XPrintText( sText AS STRING, sHeader AS STRING, sFont AS STRING, fSize AS LONG, fStyle AS LONG ) AS LONG
    
    LOCAL sPrint, sLine, sTemp AS STRING
    LOCAL i, j, Count, PageLines, Page, POS, hFile, LastPos AS LONG
    LOCAL nLeft, nTop, nRight, nBottom, PageWidth, PageHeight, TxtWidth, TxtHeight AS SINGLE
    LOCAL x, y, PrntMargin AS SINGLE
    LOCAL nwidth&, nheight& , a AS LONG , b AS LONG , c AS LONG, ncWidth!, ncHeight!
    
    'einen Drucker zuweisen
    XPRINT ATTACH CHOOSE
    IF LEN(XPRINT$) = 0 THEN
    FUNCTION = 0
    EXIT FUNCTION ' Druckerfehler !?
    ELSE
    i = MSGBOX( XPRINT$+$CRLF+$CRLF+$CRLF+"Diesen Drucker verwenden?",%MB_YESNO ,"eingestellter Drucker")
    IF i = %IDNO THEN
    XPRINT CLOSE
    XPRINT ATTACH CHOOSE
    IF LEN(XPRINT$) = 0 THEN
    MSGBOX "es wurde kein Drucker ausgewählt!",64,"Druckerauswahl Error"
    EXIT FUNCTION
    END IF
    END IF
    END IF
    '================================ Papier- und Seiteneinstellungen für den Ausdruck:
    XPRINT GET CLIENT TO ncWidth!, ncHeight!
    XPRINT SCALE (0,0)-(210,297) ' alle Werte in mm angeben, wohin gedruckt werden soll! Hochformat!
    'get page specs
    XPRINT FONT sFont, fSize, fStyle ' set the font first
    XPRINT GET LINES TO PageLines ' 57 MSGBOX STR$(PageLines),64,"PageLines"
    XPRINT GET MARGIN TO nLeft, nTop, nRight, nBottom 'get margins
    XPRINT GET CLIENT TO PageWidth, PageHeight 'get print area
    PrntMargin = PageWidth * 0.06 ' MSGBOX STR$(PrntMargin),64,"PrntMargin"
    PageWidth = PageWidth - ( PrntMargin*2 ) ' MSGBOX STR$(PageWidth),64,"PageWidth"
    '================================
    ' pb=pagewidth/137.71 ' pagewidth=6464 "Punkte" ----- pb= 21 cm
    ' cm=pb*137.71/21 ' Höhe = 137,71 Punkte/cm
    ' msgbox str$(cm)+" = Punkte pro cm"
    '============================================================================
    'break up long lines *** hier: vorgegebene Routine zur Textpositionierung:
    sPrint = ""
    FOR i = 1 TO PARSECOUNT( sText, $CRLF ) ' go thru the whole file
    sLine = PARSE$( sText, $CRLF, i ) ' get string that is too long
    XPRINT TEXT SIZE sLine TO TxtWidth, TxtHeight ' get length of line
    IF TxtWidth > PageWidth THEN ' the line is longer than the page width
    POS = INSTR( 1, sLine, " " ) ' find first word
    WHILE LEN(sLine)
    POS = INSTR( 1, sLine, " " ) ' find the end of the first word
    DO ' step thru the line word by word
    LastPos = POS ' save last step
    POS = INSTR( POS+1, sLine, " " ) ' next word
    sTemp = LEFT$( sLine, POS-1 ) ' load line so far
    XPRINT TEXT SIZE sTemp TO TxtWidth, TxtHeight ' get length of line so far
    IF POS = 0 THEN ' at the end of the line
    IF TxtWidth > PageWidth THEN ' we have a very long word!
    IF LastPos THEN EXIT LOOP ' end of line and PageWidth coincide
    DO ' loop thru the word one char at a time
    INCR POS
    sTemp = LEFT$( sLine, POS ) ' compile word
    XPRINT TEXT SIZE sTemp TO TxtWidth, TxtHeight ' Test length
    LastPos = POS ' Last Char is under PageWidth
    LOOP UNTIL TxtWidth >= PageWidth ' Exit when Pagewidth exceeded
    EXIT LOOP ' Done
    ELSE
    LastPos = LEN(sLine)+1 ' Line is shorter than PageWidth
    EXIT LOOP ' Done
    END IF
    END IF
    LOOP UNTIL TxtWidth > PageWidth ' now line is one step too long
    sTemp = LEFT$( sLine, LastPos-1 ) ' Line at last step befor exceded PageWidth
    sPrint = sPrint + TRIM$(sTemp) + $CRLF ' Add correct length line to lines so far
    sLine = RIGHT$( sLine, -(LastPos-1) ) ' Remove from line and continue on (PB8)
    POS = 1 ' start at beggining of what is left of line
    WEND
    ELSE
    sPrint = sPrint + TRIM$(sLine) + $CRLF ' Line length is less than Page Width
    END IF
    NEXT i ' repeat for all lines in sText
    sPrint = RTRIM$( sPrint, $CRLF ) ' Remove trailing $CRLF's
    '================================
    
    
    ' OPEN "FormattedLetter.txt" FOR BINARY AS #hFile ' for testing
    ' IF ERR THEN
    ' MSGBOX "Problem creating file",64,"File Error"+STR$(ERRCLEAR)
    ' CLOSE #hFile
    ' EXIT FUNCTION
    ' END IF
    ' PUT$ #hFile, sPrint
    ' CLOSE #hFile
    ' EXIT FUNCTION
    ' '================================
    
    
    'print header Logo ganz oben ajuf der ausgedruckten Seite: Bilder und Schrift
    Page = 1 : a = 230 ' um ... Punkte tiefer! a = 230
    sHeader="Holiday-Inn" '
    XPRINT TEXT SIZE sHeader TO TxtWidth, TxtHeight ' Header width
    ' MSGBOX STR$(TxtWidth) + " " + STR$(TxtHeight)
    XPRINT COLOR RGB(3,135,63), -2
    XPRINT FONT "Comic Sans MS",26,3
    XPRINT SET POS (60, 25)
    XPRINT sHeader
    
    sHeader="Mary"
    XPRINT FONT "Comic Sans MS",12,3
    XPRINT SET POS (63, 36)
    XPRINT sHeader
    
    sHeader="and"
    XPRINT FONT "Comic Sans MS",10,3
    XPRINT SET POS (67, 41)
    XPRINT sHeader
    
    sHeader="Rudolf"
    XPRINT FONT "Comic Sans MS",12,3
    XPRINT SET POS (75,41)
    XPRINT sHeader
    
    sHeader="name"
    XPRINT FONT "Comic Sans MS",24,3
    XPRINT SET POS (92, 36)
    XPRINT sHeader
    
    b = 0 'senkrechte Verschiebung: nach oben o. unten: -/+ für Testzwecke benutzt!
    sHeader="street nr, city"
    XPRINT FONT "Comic Sans MS",13,3
    XPRINT SET POS (136,50 )
    XPRINT sHeader
    sHeader="Tel./Fax: +49xxxx"
    XPRINT FONT "Comic Sans MS",13,3
    XPRINT SET POS (136, 56)
    XPRINT sHeader
    sHeader="www.xxx-yyy.de"
    XPRINT FONT "Comic Sans MS",11,3
    XPRINT SET POS (136, 62)
    XPRINT sHeader
    sHeader="email: [email protected]"
    XPRINT FONT "Comic Sans MS",11,3
    XPRINT SET POS (136, 67)
    XPRINT sHeader
    sHeader=Datum$
    XPRINT FONT "Comic Sans MS",12,3 ' Datum:
    XPRINT COLOR RGB(0,0,0),-1
    XPRINT SET POS (150, 80)
    XPRINT sHeader
    ' Falzkante markieren: kurze Linie am linken Rand
    XPRINT WIDTH 4
    ' XPRINT FONT "Comic Sans MS",11,3
    XPRINT LINE (0, 108) - (9, 108)
    '================================
    ' drucke BMP:
    nfile&=FREEFILE
    OPEN "pic1.bmp" FOR BINARY AS nfile&
    GET #nFile&, 19, nwidth&
    GET #nFile&, 23, nHeight&
    CLOSE nFile&
    XPRINT RENDER "pic1.bmp", (5,5)-(50,47)
    IF ERR THEN MSGBOX "Status von XPRINT RENDER" + STR$(ERRCLEAR)
    '================================ Mitte: Logo familyv.bmp
    nfile&=FREEFILE
    OPEN "pic2.bmp" FOR BINARY AS nfile&
    GET #nFile&, 19, nwidth&
    GET #nFile&, 23, nHeight&
    CLOSE nFile&
    XPRINT RENDER "pic2.bmp", (54,5)-(160,27)
    IF ERR THEN MSGBOX "Status von XPRINT RENDER" + STR$(ERRCLEAR)
    '================================ Rechts: brommi_rh_col.bmp
    
    nfile&=FREEFILE
    OPEN "pic3.bmp" FOR BINARY AS nfile&
    GET #nFile&, 19, nwidth&
    GET #nFile&, 23, nHeight&
    CLOSE nFile&
    XPRINT RENDER "pic3.bmp", (165,5)-(206,44)
    IF ERR THEN MSGBOX "Status von XPRINT RENDER" + STR$(ERRCLEAR)
    '================================
    ' Umrahmen mit: ¤ :
    ' XPRINT COLOR RGB(63,135,63), -2
    ' XPRINT FONT "Comic Sans MS",10,3
    ' XPRINT SET POS (50, 24)
    ' XPRINT string$(150, "~")
    ' .......... oberer Rand ........................... unterer Rand: blaue Wellenlinie
    XPRINT COLOR RGB(7,146,248), -2
    ' XPRINT FONT "Comic Sans MS",10,3
    XPRINT SET POS (5, 45)
    XPRINT STRING$(48, "~")
    ' allgemeine Druckfarbe festlegen für restlichen Ausdruck:
    XPRINT COLOR RGB(0,0,0),-1
    XPRINT FONT "Comic Sans MS",8,5
    XPRINT SET POS (17, 50)
    XPRINT "Addr.: Ferienhof name, street nr, city"
    ' XPRINT FONT "Comic Sans MS",11,3
    XPRINT FONT "Comic Sans MS",11,3 ' Schriftgröße für restlichen Brieftext
    '.........................................................................................
    'Print the pages line by line
    ' Count = 4 ' 4 lines for header
    XPRINT GET POS TO x, y :y=600
    FOR i = 1 TO PARSECOUNT( sPrint, $CRLF )
    INCR Count
    XPRINT GET POS TO x, y
    y=y/10+5*i
    ' msgbox str$(x)+ ", "+str$(y)
    ' XPRINT SET POS (PrntMargin+120, y ) ' move print start position to calculated margin
    XPRINT SET POS (PrntMargin+5, y )
    sLine = PARSE$( sPrint, $CRLF, i )
    XPRINT sLine
    IF Count = PageLines THEN
    INCR Page
    XPRINT FORMFEED ' New page
    XPRINT TEXT SIZE sHeader TO TxtWidth, TxtHeight ' Header width
    ' XPRINT SET POS (PrntMargin+120, nTop+TxtHeight )
    XPRINT SET POS (PrntMargin+5, nTop+TxtHeight )
    XPRINT "Seite " + FORMAT$(Page, "0")
    XPRINT SET POS (((PageWidth-TxtWidth)/2), nTop+TxtHeight )
    XPRINT sHeader
    XPRINT
    ' Count = 4
    END IF
    NEXT i
    '================================
    
    ' ab zum Druck!!
    'Detach the printer
    XPRINT CLOSE
    '================================
    
    FUNCTION = Page ' return # of pages printed
    
    END FUNCTION
    
    '¤¤¤¤¤¤¤¤¤¤¤¤¤ Hauptroutine
    FUNCTION PBMAIN
    
    LOCAL i, hFile AS LONG
    LOCAL sFile, sLine, sTemp AS STRING
    
    ' feststellen, welches Betriebssystem: bei WINXP einen "Vergrößerungsfaktor anwenden: winxp=1.66
    ' winver$= osversion winxp ist hier eigentlich unnötig, diente für frühere Versuche,
    ' da bei unterschiedlichen Systemen die Bildgröße verschieden groß ausgedruckt wurde
    
    
    ' aktuelles Datum in Bestätigung einfügen
    CALL heutedatum
    ' nun schreibe den aktuellen Bestätigungstext mit der zugehörigen Anschrift des Gastes:
    hFile = FREEFILE '
    OPEN "fewobesx.txt" FOR BINARY AS hFile ' < bessere Technik als unten
    ' OPEN "fewobesx.txt" AS hFile ' veraltet
    IF ERR THEN
    MSGBOX "Problem mit dem Öffnen des Files",64,"File Error"+STR$(ERRCLEAR)
    CLOSE hFile
    EXIT FUNCTION
    END IF
    GET$ hFile, LOF(hFile), sFile ' read the whole file into a string
    CLOSE hFile
    '================================
    
    i = XPrintText( sFile, "", "Comic Sans MS", 12, 0 ) ' Print the text
    IF i THEN
    ' MSGBOX STR$(i)+" Seiten gedruckt",64,"Ausdruck komplett"
    ELSE
    MSGBOX "Nichts wurde gedruckt",64,"Druck fehlgeschlagen!"
    END IF
    '================================
    END FUNCTION
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤'

  • #2
    After translation and fix for POS:
    Code:
    'LetterheadPrint.bas Stand: 14.11.2006 ufb!!! f. RHO
    ' Inserted folder edge: ok!!
    #COMPILE EXE
    $DIM ALL
    $INCLUDE "win32api.inc" 'pb=Paperbreite in pkt.
    GLOBAL nfile&, DateToday$, Dates$, xp AS LONG, winxp AS LONG, winver$, cm AS LONG, pb AS LONG
    
    'default function: convert cm to ppi
    FUNCTION CM2PPI(cXY AS STRING ,nCM AS SINGLE) AS SINGLE
        LOCAL x&, y&
        XPRINT GET PPI TO x&, y&
        SELECT CASE cXY
            CASE "x","X"
                CM2PPI = nCM * x& / 2.54
            CASE "y","Y"
                CM2PPI = nCM * y& / 2.54
            CASE ELSE
                CM2PPI = 0
        END SELECT
    END FUNCTION
    
    'default function: convert ppi to cm
    FUNCTION PPI2CM(cXY AS STRING ,nPoints AS SINGLE) AS SINGLE
        LOCAL x&, y&
        XPRINT GET PPI TO x&, y&
        SELECT CASE cXY
            CASE "x","X"
                PPi2CM = nPoints / x& * 2.54
            CASE "y","Y"
                PPi2CM = nPoints / y& * 2.54
            CASE ELSE
                PPi2CM = 0
        END SELECT
    END FUNCTION
    
    'default function: convert ppi to mm
    FUNCTION PPI2MM(cXY AS STRING ,nPoints AS SINGLE) AS SINGLE
        PPi2MM = PPI2CM(cXY,nPoints) * 10
    END FUNCTION
    
    
    'predetermined function: Determine operating system:
    
    
    ' from here begins the own development work: Put today's date in the right format:
    SUB TodayDate
      LOCAL tag AS STRING
      LOCAL month AS STRING
    
      tag=MID$(DATE$,4,2)
      month=LEFT$(DATE$,2)
      IF LEFT$(month,1)="0" THEN
          month=RIGHT$(month,1)
      END IF
      DateToday$=tag+". "+month+". "+RIGHT$(DATE$,4)
      Dates$=DateToday$
    END SUB
    
    ' Here the page is setup and printed:
    FUNCTION XPrintText( sText AS STRING, sHeader AS STRING, sFont AS STRING, fSize AS LONG, fStyle AS LONG ) AS LONG
    
        LOCAL sPrint, sLine, sTemp AS STRING
        LOCAL i, j, COUNT, PageLines, PAGE, POSx, hFile, LastPos AS LONG
        LOCAL nLeft, nTop, nRight, nBottom, PageWidth, PageHeight, TxtWidth, TxtHeight AS SINGLE
        LOCAL x, y, PrintMargin AS SINGLE
        LOCAL nwidth&, nheight& , a AS LONG , b AS LONG , c AS LONG, ncWidth!, ncHeight!
    
        'assign a printer
        XPRINT ATTACH CHOOSE
        IF LEN(XPRINT$) = 0 THEN
            FUNCTION = 0
            EXIT FUNCTION ' Printer error !?
        ELSE
            i = MSGBOX( XPRINT$+$CRLF+$CRLF+$CRLF+"Use this Printer?",%MB_YESNO ,"Set Printer")
            IF i = %IDNO THEN
                XPRINT CLOSE
                XPRINT ATTACH CHOOSE
                IF LEN(XPRINT$) = 0 THEN
                    MSGBOX "No printer was selected!",64,"Printer Selection Error"
                    EXIT FUNCTION
                END IF
            END IF
        END IF
        '================================ Paper and page settings for printing:
        XPRINT GET CLIENT TO ncWidth!, ncHeight!
        XPRINT SCALE (0,0)-(210,297) ' specify all values in mm, where to print! Portrait!
        'get page specs
        XPRINT FONT sFont, fSize, fStyle ' set the font first
        XPRINT GET LINES TO PageLines ' 57 MSGBOX STR$(PageLines),64,"PageLines"
        XPRINT GET MARGIN TO nLeft, nTop, nRight, nBottom 'get margins
        XPRINT GET CLIENT TO PageWidth, PageHeight 'get print area
        PrintMargin = PageWidth * 0.06 ' MSGBOX STR$(PrintMargin),64,"PrintMargin"
        PageWidth = PageWidth - ( PrintMargin*2 ) ' MSGBOX STR$(PageWidth),64,"PageWidth"
        '================================
        ' pb=pagewidth/137.71 ' pagewidth=6464 "Points" ----- pb= 21 cm
        ' cm=pb*137.71/21 ' Height = 137,71 Points / cm
        ' msgbox str$(cm)+" = Points per cm"
        '============================================================================
        'break up long lines *** here: specified routine for text positioning:
        sPrint = ""
        FOR i = 1 TO PARSECOUNT( sText, $CRLF ) ' go thru the whole file
            sLine = PARSE$( sText, $CRLF, i ) ' get string that is too long
            XPRINT TEXT SIZE sLine TO TxtWidth, TxtHeight ' get length of line
            IF TxtWidth > PageWidth THEN ' the line is longer than the page width
                POSx = INSTR( 1, sLine, " " ) ' find first word
                WHILE LEN(sLine)
                    POSx = INSTR( 1, sLine, " " ) ' find the end of the first word
                    DO ' step thru the line word by word
                        LastPos = POSx ' save last step
                        POSx = INSTR( POSx+1, sLine, " " ) ' next word
                        sTemp = LEFT$( sLine, POSx-1 ) ' load line so far
                        XPRINT TEXT SIZE sTemp TO TxtWidth, TxtHeight ' get length of line so far
                        IF POSx = 0 THEN ' at the end of the line
                            IF TxtWidth > PageWidth THEN ' we have a very long word!
                                IF LastPos THEN EXIT LOOP ' end of line and PageWidth coincide
                                DO ' loop thru the word one char at a time
                                    INCR POSx
                                    sTemp = LEFT$( sLine, POSx ) ' compile word
                                    XPRINT TEXT SIZE sTemp TO TxtWidth, TxtHeight ' Test length
                                    LastPos = POSx ' Last Char is under PageWidth
                                LOOP UNTIL TxtWidth >= PageWidth ' Exit when Pagewidth exceeded
                                EXIT LOOP ' Done
                            ELSE
                                LastPos = LEN(sLine)+1 ' Line is shorter than PageWidth
                                EXIT LOOP ' Done
                            END IF
                        END IF
                    LOOP UNTIL TxtWidth > PageWidth ' now line is one step too long
                    sTemp = LEFT$( sLine, LastPos-1 ) ' Line at last step befor exceded PageWidth
                    sPrint = sPrint + TRIM$(sTemp) + $CRLF ' Add correct length line to lines so far
                    sLine = RIGHT$( sLine, -(LastPos-1) ) ' Remove from line and continue on (PB8)
                    POSx = 1 ' start at beggining of what is left of line
                WEND
            ELSE
                sPrint = sPrint + TRIM$(sLine) + $CRLF ' Line length is less than Page Width
            END IF
        NEXT i ' repeat for all lines in sText
        sPrint = RTRIM$( sPrint, $CRLF ) ' Remove trailing $CRLF's
        '================================
    
    
        ' OPEN "FormattedLetter.txt" FOR BINARY AS #hFile ' for testing
        ' IF ERR THEN
        ' MSGBOX "Problem creating file",64,"File Error"+STR$(ERRCLEAR)
        ' CLOSE #hFile
        ' EXIT FUNCTION
        ' END IF
        ' PUT$ #hFile, sPrint
        ' CLOSE #hFile
        ' EXIT FUNCTION
        ' '================================
    
    
        'print header Logo at the top of the printed page: Pictures and writing
        PAGE = 1 : a = 230 ' around ... points lower! a = 230
        sHeader="Holiday-Inn" '
        XPRINT TEXT SIZE sHeader TO TxtWidth, TxtHeight ' Header width
        ' MSGBOX STR$(TxtWidth) + " " + STR$(TxtHeight)
        XPRINT COLOR RGB(3,135,63), -2
        XPRINT FONT "Comic Sans MS",26,3
        XPRINT SET POS (60, 25)
        XPRINT sHeader
    
        sHeader="Mary"
        XPRINT FONT "Comic Sans MS",12,3
        XPRINT SET POS (63, 36)
        XPRINT sHeader
    
        sHeader="and"
        XPRINT FONT "Comic Sans MS",10,3
        XPRINT SET POS (67, 41)
        XPRINT sHeader
    
        sHeader="Rudolf"
        XPRINT FONT "Comic Sans MS",12,3
        XPRINT SET POS (75,41)
        XPRINT sHeader
    
        sHeader="name"
        XPRINT FONT "Comic Sans MS",24,3
        XPRINT SET POS (92, 36)
        XPRINT sHeader
    
        b = 0 'vertical shift: up or down: -/+ used for test purposes!
        sHeader="street nr, city"
        XPRINT FONT "Comic Sans MS",13,3
        XPRINT SET POS (136,50 )
        XPRINT sHeader
        sHeader="Tel./Fax: +49xxxx"
        XPRINT FONT "Comic Sans MS",13,3
        XPRINT SET POS (136, 56)
        XPRINT sHeader
        sHeader="www.xxx-yyy.de"
        XPRINT FONT "Comic Sans MS",11,3
        XPRINT SET POS (136, 62)
        XPRINT sHeader
        sHeader="email: [email protected]"
        XPRINT FONT "Comic Sans MS",11,3
        XPRINT SET POS (136, 67)
        XPRINT sHeader
        sHeader=Dates$
        XPRINT FONT "Comic Sans MS",12,3 ' Datum:
        XPRINT COLOR RGB(0,0,0),-1
        XPRINT SET POS (150, 80)
        XPRINT sHeader
        ' Mark fold edge: short line on the left edge
        XPRINT WIDTH 4
        ' XPRINT FONT "Comic Sans MS",11,3
        XPRINT LINE (0, 108) - (9, 108)
        '================================
        ' prints BMP:
        nfile&=FREEFILE
        OPEN "pic1.bmp" FOR BINARY AS nfile&
            GET #nFile&, 19, nwidth&
            GET #nFile&, 23, nHeight&
        CLOSE nFile&
        XPRINT RENDER "pic1.bmp", (5,5)-(50,47)
        IF ERR THEN MSGBOX "Status from XPRINT RENDER" + STR$(ERRCLEAR)
        '================================ Not: Logo familyv.bmp
        nfile&=FREEFILE
        OPEN "pic2.bmp" FOR BINARY AS nfile&
            GET #nFile&, 19, nwidth&
            GET #nFile&, 23, nHeight&
        CLOSE nFile&
        XPRINT RENDER "pic2.bmp", (54,5)-(160,27)
        IF ERR THEN MSGBOX "Status from XPRINT RENDER" + STR$(ERRCLEAR)
        '================================ Right: brommi_rh_col.bmp
    
        nfile&=FREEFILE
        OPEN "pic3.bmp" FOR BINARY AS nfile&
            GET #nFile&, 19, nwidth&
            GET #nFile&, 23, nHeight&
        CLOSE nFile&
        XPRINT RENDER "pic3.bmp", (165,5)-(206,44)
        IF ERR THEN MSGBOX "Status from XPRINT RENDER" + STR$(ERRCLEAR)
        '================================
        ' Frame with: ¤ :
        ' XPRINT COLOR RGB(63,135,63), -2
        ' XPRINT FONT "Comic Sans MS",10,3
        ' XPRINT SET POS (50, 24)
        ' XPRINT string$(150, "~")
        ' .......... upper edge ........................... lower edge: blue wavy line
        XPRINT COLOR RGB(7,146,248), -2
        ' XPRINT FONT "Comic Sans MS",10,3
        XPRINT SET POS (5, 45)
        XPRINT STRING$(48, "~")
        ' Set general printing color for remaining printout:
        XPRINT COLOR RGB(0,0,0),-1
        XPRINT FONT "Comic Sans MS",8,5
        XPRINT SET POS (17, 50)
        XPRINT "Addr.: Unknown name, street nr, city"
        ' XPRINT FONT "Comic Sans MS",11,3
        XPRINT FONT "Comic Sans MS",11,3 ' Font size for remaining letter text
        '.........................................................................................
        'Print the pages line by line
        ' Count = 4 ' 4 lines for header
        XPRINT GET POS TO x, y :y=600
        FOR i = 1 TO PARSECOUNT( sPrint, $CRLF )
            INCR COUNT
            XPRINT GET POS TO x, y
            y=y/10+5*i
            ' msgbox str$(x)+ ", "+str$(y)
            ' XPRINT SET POS (PrintMargin+120, y ) ' move print start position to calculated margin
            XPRINT SET POS (PrintMargin+5, y )
            sLine = PARSE$( sPrint, $CRLF, i )
            XPRINT sLine
            IF COUNT = PageLines THEN
                INCR PAGE
                XPRINT FORMFEED ' New page
                XPRINT TEXT SIZE sHeader TO TxtWidth, TxtHeight ' Header width
                ' XPRINT SET POS (PrintMargin+120, nTop+TxtHeight )
                XPRINT SET POS (PrintMargin+5, nTop+TxtHeight )
                XPRINT "Page " + FORMAT$(PAGE, "0")
                XPRINT SET POS (((PageWidth-TxtWidth)/2), nTop+TxtHeight )
                XPRINT sHeader
                XPRINT
                ' Count = 4
            END IF
        NEXT i
        '================================
    
        ' off to pressure!!
        'Detach the printer
        XPRINT CLOSE
        '================================
    
        FUNCTION = PAGE ' return # of pages printed
    
    END FUNCTION
    
    '¤¤¤¤¤¤¤¤¤¤¤¤¤ main routine
    FUNCTION PBMAIN
    
        LOCAL i, hFile AS LONG
        LOCAL sFile, sLine, sTemp AS STRING
    
        ' determine which operating system: to apply a "magnification factor" in winxp: winxp = 1.66
         'winver$ = osversion winxp is actually unnecessary here, served for earlier attempts,
         'Since the size of the image was printed at different sizes for different systems
    
    
        ' Insert current date in confirmation
        CALL TodayDate
        ' Now write the current confirmation text with the corresponding address of the guest:
        hFile = FREEFILE '
        OPEN "fewobesx.txt" FOR BINARY AS hFile ' < better technique than below
        ' OPEN "fewobesx.txt" AS hFile ' outdated
        IF ERR THEN
            MSGBOX "Problem with opening the File",64,"File Error"+STR$(ERRCLEAR)
            CLOSE hFile
            EXIT FUNCTION
        END IF
        GET$ hFile, LOF(hFile), sFile ' read the whole file into a string
        CLOSE hFile
        '================================
    
        i = XPrintText( sFile, "", "Comic Sans MS", 12, 0 ) ' Print the text
        IF i THEN
            ' MSGBOX STR$(i)+" Pages printed",64,"Expression complete"
        ELSE
            MSGBOX "Nothing was printed",64,"Print failed!"
        END IF
        '================================
    END FUNCTION
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤'

    Comment

    Working...
    X