|
-
Jul 4th, 2001, 04:28 PM
#1
Thread Starter
Hyperactive Member
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
-
Jul 4th, 2001, 04:29 PM
#2
-= B u g S l a y e r =-
what are u printing and how are you doin it ?
peet
-
Jul 4th, 2001, 04:31 PM
#3
Thread Starter
Hyperactive Member
printer.print "Page" & printer.page
printer.print text1.text
printer.enddoc
-
Jul 4th, 2001, 04:38 PM
#4
Thread Starter
Hyperactive Member
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
-
Jul 4th, 2001, 04:56 PM
#5
Thread Starter
Hyperactive Member
anyone?
-
Jul 4th, 2001, 05:03 PM
#6
-
Jul 4th, 2001, 05:06 PM
#7
-= B u g S l a y e r =-
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
-
Jul 4th, 2001, 05:07 PM
#8
Thread Starter
Hyperactive Member
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!
-
Jul 4th, 2001, 05:15 PM
#9
-= B u g S l a y e r =-
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
-
Jul 4th, 2001, 05:20 PM
#10
Thread Starter
Hyperactive Member
thnx. i will see what i can do...but i am a bit new at this...haha should be fun!
-
Jul 4th, 2001, 05:23 PM
#11
-= B u g S l a y e r =-
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
-
Jul 4th, 2001, 06:09 PM
#12
Thread Starter
Hyperactive Member
ne1
ne1? pls help...i am really stuck here!
-
Jul 4th, 2001, 08:03 PM
#13
Frenzied Member
VB Code:
ss = text1.text
LN = Len(ss)
Do Until Printer.TextHeight(SS) < Printer.ScaleHeight
LN = LN - 1
SS = Mid(SS, 1, LN)
Loop
FLN = LN
Printer.Print SS
Printer.EndDoc
Printer.NewPage
Printer.Print "Whatever I want"
LN = Len(ss)
Do Until Printer.TextHeight(SS) < Printer.ScaleHeight
LN = LN - 1
SS = Mid(SS, FLN, LN)
Loop
Foll around with this code. You could make it shorter. I dont have VB Here
-
Jul 4th, 2001, 09:27 PM
#14
Thread Starter
Hyperactive Member
Thanks, I think were on the right track now. I am trying to work out the bugs though...i think it will work
-
Jul 4th, 2001, 09:40 PM
#15
Thread Starter
Hyperactive Member
it keeps printing 2 copies and one has the header. the other dosent...
-
Jul 5th, 2001, 07:51 AM
#16
Frenzied Member
What is your final code?
VB Code:
Printer.NewPage
Printer.Print "Whatever I want"
ss = text1.text
LN = Len(ss)
Do Until Printer.TextHeight(SS) < Printer.ScaleHeight
LN = LN - 1
SS = Mid(Text1.Text, 1, LN)
Loop
FLN = LN
Printer.Print SS
Printer.EndDoc
NewPge:
Printer.NewPage
Printer.Print "Whatever I want"
LN = Len(ss)
Do Until Printer.TextHeight(SS) < Printer.ScaleHeight
LN = LN - 1
SS = Mid(Text1.Text, FLN, LN)
Loop
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|