I did some more research and created executable code.
In the PDF, the image in the blue frame must contain the sequential number.
Starting on page 20, there are suddenly wrong images.
Code: Select all
Structure _USER
ID.s
RegID.i
Anrede.s
Titel.s
Name.s
Vorname.s
Firma.s
Funktion.s
Strasse.s
PLZ.s
Ort.s
EMail.s
Telefon.s
Kommentar.s
Teilnahme.s
ZusatzEvent.s
Begleitung.s
Speichern.s
HashID.s
CrC.s
EndStructure
Procedure FindTheBug()
Protected Dim s.s(10)
pdffile.s = "C:\Temp\FindeTheBug.pdf"
Protected NewList U._USER(), UC._USER
Protected NewMap RplTxt.s()
LoadFont(0, "Futura LT Pro Book", 100, #PB_Font_Bold)
LoadFont(1, "Futura LT Pro Book", 30)
#VERSION = "2.38"
#MAX_NAMEWIDTH = 830
#MAX_FKT_WIDTH = 950
For i = 1 to 500
AddElement(U())
;U()\Anrede = "Mr"
;U()\Firma = "Purebasic"
U()\Vorname = "Jane"
U()\Name = "Doe"
Next
If StartVectorDrawing(PdfVectorOutput(pdffile, 2480, 3508))
ForEach U()
pageNr + 1
If IsImage(0)
MovePathCursor(0, 0)
DrawVectorImage(ImageID(0));
EndIf
VectorFont(FontID(1), 30)
VectorSourceColor(RGBA(0, 0, 0, 255))
txt.s = "Erstellt: " + FormatDate("%dd.%mm.%yyyy %hh:%ii", Date()) + " Uhr | " + #VERSION + " | Seite: " + Str(pageNr)
MovePathCursor(VectorOutputWidth() - VectorTextWidth(txt) - 90, 5)
DrawVectorText(txt)
rowCount = 8 ; Textil
PosY = 160
For y = 1 To rowCount
PosX = 190
For x = 1 To 2
UC = U()
txt = ""
With UC
;{ Name Vorname zweizeilig
VectorFont(FontID(0), 70)
VectorSourceColor(RGBA(Red(rgb_text), Green(rgb_text), Blue(rgb_text), 255))
\Firma = Str(ListIndex(U()))
\Name + " " + Str(ListIndex(U()))
; Vornamen maskieren und Doppelleerzeichen entfernen
txt + ReplaceString(ReplaceString(\Vorname, " ", " "), " ", "_") + " " + \Name
txt = ReplaceString(txt, " ", " ")
txt2.s = ""
w = VectorTextWidth(txt)
If w > #MAX_NAMEWIDTH
c = CountString(txt, Chr(32))
If c > 0
For i = 1 To c + 1
s(i) = StringField(txt, i, Chr(32))
Next
If c = 1
txt = s(c)
txt2 = s(c+1)
Else
txt = ""
; Bei sehr langen Nachnamen, muss der Vornamen mit hoch in die erste Zeile
If VectorTextWidth(s(c+1)) > 600
txt2 = s(c+1)
For i = 1 To c
txt + s(i) + " "
Next
Else
txt2 = s(c) + " " + s(c+1)
For i = 1 To c - 1
txt + s(i) + " "
Next
EndIf
txt = Trim(txt)
EndIf
EndIf
txt = ReplaceString(txt, "_", " ")
txt2 = ReplaceString(txt2, "_", " ")
; Wegen haufenweise Vornamen kann der Text zu lang sein,
; daher einfach vorletzten Namen entfernen
; Malte Hans Dixi Mustermann -> Malte Hans Mustermann
w = VectorTextWidth(txt2)
If w > #MAX_NAMEWIDTH
c = CountString(txt2, Chr(32))
If c > 1
For i = 1 To c + 1
s(i) = StringField(txt2, i, Chr(32))
Next
; WriteLog("Too long: " + txt2 + " -> Remove: " + s(c))
s(c) = ""
txt2 = ""
For i = 1 To c + 1
If s(i) <> ""
txt2 + s(i) + " "
EndIf
Next
txt2 = Trim(txt2)
EndIf
EndIf
; Debug "Zeile 1 : " + txt
; Debug "Zeile 2 : " + txt2
EndIf
; AddPathBox(PosX, PosY, 1180, 400)
; VectorSourceColor(RGBA(200, 200, 200, 255))
; StrokePath(1)
; VectorSourceColor(RGBA(Red(rgb_text), Green(rgb_text), Blue(rgb_text), 255))
; Hier auch nochmal, sonst nur bei überlängen wieder entfernt
txt = ReplaceString(txt, "_", " ")
txt2 = ReplaceString(txt2, "_", " ")
If 1
; Titel Vorname Name Zeile 1
MovePathCursor(PosX, PosY)
DrawVectorText(txt)
Offset_Y + 100
If txt2 <> ""
; Titel Vorname Name Zeile 2
MovePathCursor(PosX, PosY + Offset_Y)
DrawVectorText(txt2)
Offset_Y + 100
EndIf
EndIf
;}
;{ Funktion
VectorFont(FontID(1), 40)
txt = Trim(ReplaceString(\Funktion, ";", ","))
;WriteLog( txt + " | " + Str(VectorTextWidth(txt)))
If VectorTextWidth(txt) > #MAX_FKT_WIDTH
ForEach RplTxt()
If FindString(txt, MapKey(RplTxt()), 0, #PB_String_NoCase)
txt = ReplaceString(txt, MapKey(RplTxt()), RplTxt(), #PB_String_NoCase)
EndIf
Next
EndIf
Repeat
w = VectorTextWidth(txt)
If w > #MAX_FKT_WIDTH
c = CountString(txt, Chr(32))
If c > 0
txt = ReverseString(txt)
c = FindString(txt, " ")
txt = Mid(txt, c + 1)
txt = ReverseString(txt)
Else
txt = Mid(txt, 1, Len(txt) - 1)
EndIf
w = VectorTextWidth(txt)
EndIf
Until w <= #MAX_FKT_WIDTH
;txt = Remove_Chars_from_Right(txt)
;}
;{ Firma
txt = Trim(ReplaceString(\Firma, ";", ","))
If VectorTextWidth(txt) > #MAX_FKT_WIDTH
ForEach RplTxt()
If FindString(txt, MapKey(RplTxt()), 0, #PB_String_NoCase)
txt = ReplaceString(txt, MapKey(RplTxt()), RplTxt(), #PB_String_NoCase)
EndIf
Next
EndIf
Repeat
w = VectorTextWidth(txt)
If w > #MAX_FKT_WIDTH
c = CountString(txt, Chr(32))
If c > 0
txt = ReverseString(txt)
c = FindString(txt, " ")
txt = Mid(txt, c + 1)
txt = ReverseString(txt)
Else
txt = Mid(txt, 1, Len(txt) - 1)
EndIf
w = VectorTextWidth(txt)
EndIf
Until w <= #MAX_FKT_WIDTH
If Right(txt, 6) = ", Büro"
txt = Mid(txt, 1, Len(txt) - 6)
EndIf
;txt = Remove_Chars_from_Right(txt)
If 1;styles & #TMPL_PREF_FIRMA
MovePathCursor(PosX, PosY + Offset_Y)
DrawVectorText(txt)
Offset_Y + 70
EndIf
;}
; b7a6f5517c684ba9348390ab100819ef -> #d7d3d0ed$
If 1;styles & #TMPL_PREF_QRCODE
;txt = CreateBarCodeText(\ID)
;img = qrcodegen::CreateTextImage(txt)
img = CreateImage(#PB_Any, 100, 100)
If IsImage(img)
If StartDrawing(ImageOutput(img))
Box(0, 0, OutputWidth(), OutputHeight(), #Blue)
Box(1, 1, OutputWidth()-2, OutputHeight()-2, #White)
DrawingMode(#PB_2DDrawing_Transparent)
DrawingFont(FontID(1))
DrawText(10, 10, Str(ListIndex(U())), #Black)
StopDrawing()
Endif
MovePathCursor(PosX + 848, PosY)
DrawVectorImage(ImageID(img))
MovePathCursor(PosX + 800, PosY + 140)
DrawVectorText(txt)
FreeImage(img)
Else
EndIf
EndIf
EndWith
PosX + 1180
Offset_Y = 0
If NextElement(U()) = 0
; Komplett abbrechen
Break 3
EndIf
Next x
PosY + 425
Next y
NewVectorPage()
PreviousElement(U())
Next
StopVectorDrawing()
EndIf
EndProcedure
FindTheBug()