Page 6 of 32

Posted: Sat May 03, 2008 10:39 am
by ABBKlaus
No, its purpose is only to use it in threadsafe mode.

Posted: Sat May 03, 2008 10:45 am
by srod
Aye, fair enough. :)

I will need a truly threadsafe version at some point and so will have to modify the sources to that end. Using critical sections will suffice, so I'll look to add a bunch of commands from the mutex library.

Posted: Sat May 03, 2008 12:10 pm
by ABBKlaus
The easiest approach i could think of is this :

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!"

Posted: Sat May 03, 2008 12:18 pm
by srod
Yes, that will serve my purposes very well. :)

Posted: Wed May 28, 2008 8:02 pm
by Marco2007
Hi,

I get an IMA with pdf_Circle. I know, there`s no lib for 4.20 final.
...it`s just an info.

best regards
Marco

Posted: Wed May 28, 2008 11:22 pm
by ABBKlaus
its fixed, you can test it here : http://www.purebasicpower.de/downloads/ ... 2_PB42.zip

Note : you have to delete the old libraries yourself (PurePDFDraw/PurePDFMisc)

Posted: Thu May 29, 2008 2:30 am
by DoubleDutch
Is this a single lib that covers them all (purepdf/pdfmisc/pdfdraw)?

Posted: Thu May 29, 2008 5:52 am
by Marco2007
That was fast!
Thank you, ABBKlaus!

version PUREPDF 12

Posted: Thu May 29, 2008 6:33 am
by KIKI
All seems to works well
Thanks

Posted: Thu May 29, 2008 8:09 am
by ABBKlaus
DoubleDutch wrote:Is this a single lib that covers them all (purepdf/pdfmisc/pdfdraw)?
Yes, they had used too many exported string functions. Its only one lib now.

Posted: Sat May 31, 2008 6:26 am
by KIKI
it seems that PURE PDF has a strange behaviour and erase the content of var
I test a program with purepdf and without pure pdf in one var are goods in the other one with PurePDF the content of var are erased or has a bad value.

Posted: Wed Jun 04, 2008 5:37 pm
by ABBKlaus
i made a bug report in the droopy lib announcement, the lib was not compiled with the newest version of PB4.20 / TailBite.

Posted: Wed Jun 04, 2008 6:36 pm
by Thorsten1867
I found a bug in pdf_TruncateCell(), if w = 0. I've changed the code.

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

Posted: Wed Jun 04, 2008 10:47 pm
by ABBKlaus
Thanks Thorsten1867, the fix is integrated.

Download : http://www.purebasicpower.de/downloads/ ... 2_PB42.zip

Posted: Tue Jun 24, 2008 4:41 pm
by DoubleDutch
I used to use some of the internal functions, such as : ipf_GetLMargin, ipf_GetRMargin, ipf_GetWidth, etc

Can these be made available as commands as the internal versions are not working (they are really useful).