Posted: Sat May 03, 2008 10:39 am
No, its purpose is only to use it in threadsafe mode.
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
Global Mutex.l
Procedure Header()
pdf_Image("logo_purepdf.png",10,8,33)
pdf_SetFont("Arial","B",15)
pdf_Cell(80)
pdf_Cell(30,10,"Title",1,0,#PDF_ALIGN_CENTER)
pdf_Ln(20)
EndProcedure
Procedure Footer()
pdf_SetY(-15)
pdf_SetFont("Arial","I",8)
pdf_Cell(0,10,"Page "+Str(pdf_GetPageNo())+"/{nb}",0,0,#PDF_ALIGN_CENTER)
EndProcedure
Procedure Thread_A(Dummy.l)
Debug "Thread_A started"
LockMutex(Mutex)
Debug "Thread_A running"
pdf_Create()
pdf_SetProcFooter(@Footer())
pdf_SetProcHeader(@Header())
pdf_AliasNbPages();
pdf_AddPage();
pdf_SetFont("Times","",12);
For i = 1 To 40
pdf_Cell(0,10,"Printing line number "+Str(i),0,1);
Next
pdf_Save("PDF_Thread_A.pdf")
Debug "Thread_A finished"
UnlockMutex(Mutex)
EndProcedure
Procedure Thread_B(Dummy.l)
Debug "Thread_B started"
LockMutex(Mutex)
Debug "Thread_B running"
pdf_Create()
pdf_SetProcFooter(@Footer())
pdf_SetProcHeader(@Header())
pdf_AliasNbPages();
pdf_AddPage();
pdf_SetFont("Times","",12);
For i = 1 To 40
pdf_Cell(0,10,"Printing line number "+Str(i),0,1);
Next
pdf_Save("PDF_Thread_B.pdf")
Debug "Thread_B finished"
UnlockMutex(Mutex)
EndProcedure
Debug "Starting threads!"
Mutex=CreateMutex()
Thread_A=CreateThread(@Thread_A(),0)
Thread_B=CreateThread(@Thread_B(),0)
While IsThread(Thread_A) Or IsThread(Thread_B)
Delay(16)
Wend
Debug "Threads finished!"
Yes, they had used too many exported string functions. Its only one lib now.DoubleDutch wrote:Is this a single lib that covers them all (purepdf/pdfmisc/pdfdraw)?
Code: Select all
; works only as PurePDF library (Don't use it direct)
Procedure.s pdf_TruncateCell(w.f, h.f=0, Text$="", border.w=0, Ln.f=0, Align$="", Fill.f=0, Link.w=-1)
Protected wMax.f, TLen.l, trunc$
If w = 0
w = pdfW - pdfRMargin - pdfX
EndIf
wMax = w - (2 * pdfCMargin)
If pdf_GetStringWidth(Text$) <= wMax
pdf_Cell(w, h, Text$, border, Ln, Align$, Fill, Link)
Else
TLen = Len(Text$)
Repeat
TLen - 1
trunc$ = Left(Text$, TLen)+"..."
Until pdf_GetStringWidth(trunc$) <= wMax
pdf_Cell(w, h, trunc$, border, Ln, Align$, Fill, Link)
ProcedureReturn Right(Text$, Len(Text$)-TLen)
EndIf
EndProcedure