Results 1 to 16 of 16

Thread: printer...need i say more?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Location
    who am I....and why do you want to know where I am?
    Posts
    326

    Unhappy printer...need i say more?

    dose anyone know how i can print something at the top of every page printed in a multi page job? thanks a lot in advance

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    what are u printing and how are you doin it ?

    peet

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Location
    who am I....and why do you want to know where I am?
    Posts
    326
    printer.print "Page" & printer.page
    printer.print text1.text
    printer.enddoc

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Location
    who am I....and why do you want to know where I am?
    Posts
    326
    srry..posted the code and not the description...i am printing a text box, but it is usually more then 1 page and i am printing it well....that was my code

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Location
    who am I....and why do you want to know where I am?
    Posts
    326
    anyone?

  6. #6
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    think you have to do a lot of coding in order to get this working

    you would have to calculate how much text from the textbox there is room for on one page, then do a end doc, then print the top text, then as much of the rest text that there is room for ..........

    I think the calculation will be a challange.... you will have to find out how to breake words, and you will have to figure out if a LF or a CRLF is beeing used ... lots of things to think about...

    then again ... I might be totally wrong

    peet

  7. #7
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    but hey! there are lot of smart people on this site, some of you have prob. already done it ??

    So common.. share your knowledge with us

    peet

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Location
    who am I....and why do you want to know where I am?
    Posts
    326
    oooo, guess i will be busy tonight...thnx anyway...

    hmmmm, i wonder how long it took em to do in in notepad...something 2 think about!

  9. #9
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    hmmm ... I'v done this once, but don't get to happy ... I'v used a tool called IT32 (a lot of tools for string man., tables ....) I always use it. But in order for you to see how much code is needed.... here goes :


    Code:
    Private Function StringSplitter(sFontName As String, dFontSize As Double, bFontBold As Boolean, sTextSomSkalSplittes As String, lColW As Long) As ITTable
        Dim t As New ITTable
        Dim tOk As New ITTable
        Dim i As Integer
        Dim j As Integer
        Dim currRow As Long
        Dim s As String
        Dim stmp As String
        Dim lLastPos As Long
        Dim lLastPosPrev As Long
        Dim lCharCount As Long
        Dim lStrPos As Long
        Dim sRest As String
        Dim lDivFakt As Long
        Dim iLineCount As Integer
        Dim tmpRowPos As Long
        Dim currCol As Long
    
        Dim iNumOfSplits As Integer
        Dim p As Printer
        Set p = Printer
        p.FontName = sFontName
        p.FontSize = dFontSize
        p.FontBold = bFontBold
    
        tOk.Init 1, 1
        t.Text = sTextSomSkalSplittes 'Replace(sTextSomSkalSplittes, vbCrLf, vbCr)
        Debug.Print t.Text
        tmpRowPos = 1
        For currRow = 1 To t.Rows
            
            lDivFakt = 1
            lLastPosPrev = 0
            iLineCount = 0
        
            stmp = Strip(t(currRow, 1), " ", itStripRight)
            s = stmp
            sRest = stmp
            lCharCount = Len(stmp)
            lStrPos = Len(stmp)
    
            iNumOfSplits = p.TextWidth(t(currRow, 1)) \ lColW
            If iNumOfSplits = 0 Then
                tOk(tOk.Rows, 1) = t(currRow, 1)
                tOk.InsertRow tOk.Rows + 1
                tmpRowPos = tmpRowPos + 1
            Else
                For j = 1 To iNumOfSplits
                    If j <> 1 Then
                        stmp = Mid(s, lLastPosPrev + 1, Len(s) - Len(stmp))
                        lCharCount = Len(stmp)
                        lStrPos = Len(stmp)
                        lLastPos = 0
                        sRest = stmp
                        lDivFakt = 1
                    End If
                    i = 1
                    
                    If p.TextWidth(stmp) > lColW Then
                        While Not (Val(lStrPos - lLastPos) = 1 Or Val(lStrPos - lLastPos) = 0 Or Val(lStrPos - lLastPos) = -1)
                            lLastPos = lStrPos
                            i = i + 1
                            If i <> 1 Then lDivFakt = lDivFakt * 2
                            If p.TextWidth(stmp) > lColW Then
                                'for bred
                                lStrPos = lStrPos - (lCharCount \ lDivFakt)
                            Else
                                If p.TextWidth(stmp) = lColW Then
                                    'ok
                                    'MsgBox "OK!"
                                End If
                                'for smal
                                lStrPos = lStrPos + (lCharCount \ lDivFakt)
                            End If
                            
                            stmp = Left(sRest, lStrPos)
                        Wend
                        If Left(sRest, lStrPos + 1) = " " Then
                            'dersom neste tegn er et mellomrom, så skal dette ikke & _
                            taes med i neste delstreng. trenger ikke finne forrige mellomrom, & _
                            fordi strengen skal deles på mellomrommet som kommer... ehh... det & _
                            er klart som blekk :)
                            lStrPos = lStrPos + 2
                        Else
                            'må finne første mellomrom til "venstre" i strengen, og starte neste & _
                            delstreng fra denne.
                            Dim x As Integer
                            Dim sChar As String
                            sChar = ""
                            x = 0
                            While sChar <> " "
                                sChar = Mid(sRest, lStrPos - x, 1)
                                x = x + 1
                                'dersom ingen mellomrom ...
                                If x = lStrPos Then sChar = " "
                            Wend
                            If x <> lStrPos Then lStrPos = lStrPos - (x - 1)
                        End If
                        stmp = Left(sRest, lStrPos)
                        lLastPosPrev = lLastPosPrev + lStrPos
                    End If
                    
                    'dersom splitting ved foranliggende space, kan antall linjer _
                    ha økt... dersom økt, må antall splits økes med 1
                    If (p.TextWidth(Mid(s, lLastPosPrev + 1, Len(s) - Len(stmp))) \ lColW) + j > iNumOfSplits Then
                        iNumOfSplits = iNumOfSplits + 1
                        iLineCount = iLineCount + 1
                    End If
                    tOk(tmpRowPos, 1) = stmp
                    tmpRowPos = tmpRowPos + 1
                    iLineCount = iLineCount + 1
                    'tOk.InsertRow tOk.Rows + 1
                    If tmpRowPos > tOk.Rows Then tOk.InsertRow tOk.Rows + 1
                Next j
                'siste rest av strengen
                iLineCount = iLineCount + 1
                stmp = Mid(s, lLastPosPrev + 1, Len(s) - Len(stmp))
                tOk(tmpRowPos, 1) = stmp
                'SplitIT = sResult
                tmpRowPos = tmpRowPos + 1
                If tmpRowPos > tOk.Rows Then tOk.InsertRow tOk.Rows + 1
        End If
        Next currRow
        Set StringSplitter = tOk
        Set tOk = Nothing
        
    End Function
    used the routine this way (part of another routine)

    Code:
                        Else
                            'må splitte opp innhold, slik at det passer på utskrift
                            Set tMultLine = StringSplitter(c.FontName, c.FontSize, c.FontBold, c.Text, c.Width)
                            For i = 1 To tMultLine.Rows
                                pobj.CurrentX = c.Left * ZoomFaktX
                                pobj.Print tMultLine(i, 1)
                            Next i
                        End If
    *phu...*

    a lot of work... but hey.. as I said there is prob. an easier way...

    peet

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Location
    who am I....and why do you want to know where I am?
    Posts
    326
    thnx. i will see what i can do...but i am a bit new at this...haha should be fun!

  11. #11
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    well search the web before jumpin into it "the answer is out there"

    well if it isn't its a good project...

    let me know how it goes.

    peet

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Location
    who am I....and why do you want to know where I am?
    Posts
    326

    ne1

    ne1? pls help...i am really stuck here!

  13. #13
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Brooklyn NY USA
    Posts
    1,258
    VB Code:
    1. ss = text1.text
    2. LN = Len(ss)
    3. Do Until Printer.TextHeight(SS) < Printer.ScaleHeight
    4. LN = LN - 1
    5. SS = Mid(SS, 1, LN)
    6. Loop
    7. FLN = LN
    8. Printer.Print SS
    9. Printer.EndDoc
    10. Printer.NewPage
    11. Printer.Print "Whatever I want"
    12.  
    13. LN = Len(ss)
    14. Do Until Printer.TextHeight(SS) < Printer.ScaleHeight
    15. LN = LN - 1
    16. SS = Mid(SS, FLN, LN)
    17. Loop


    Foll around with this code. You could make it shorter. I dont have VB Here

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Location
    who am I....and why do you want to know where I am?
    Posts
    326
    Thanks, I think were on the right track now. I am trying to work out the bugs though...i think it will work

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Location
    who am I....and why do you want to know where I am?
    Posts
    326
    it keeps printing 2 copies and one has the header. the other dosent...

  16. #16
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Brooklyn NY USA
    Posts
    1,258
    What is your final code?

    VB Code:
    1. Printer.NewPage
    2. Printer.Print "Whatever I want"
    3.  
    4. ss = text1.text
    5. LN = Len(ss)
    6. Do Until Printer.TextHeight(SS) < Printer.ScaleHeight
    7. LN = LN - 1
    8. SS = Mid(Text1.Text, 1, LN)
    9. Loop
    10. FLN = LN
    11. Printer.Print SS
    12. Printer.EndDoc
    13.  
    14. NewPge:
    15.  
    16. Printer.NewPage
    17. Printer.Print "Whatever I want"
    18.  
    19. LN = Len(ss)
    20. Do Until Printer.TextHeight(SS) < Printer.ScaleHeight
    21. LN = LN - 1
    22. SS = Mid(Text1.Text, FLN, LN)
    23. Loop
    24.  
    25.  
    26. If LN < Len(SS) Then GoTo NewPge

    Try This

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width