PurePDF Version 2.0

Developed or developing a new product in PureBasic? Tell the world about it.
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Post by ABBKlaus »

No, its purpose is only to use it in threadsafe mode.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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.
I may look like a mule, but I'm not a complete ass.
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Post 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!"
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Yes, that will serve my purposes very well. :)
I may look like a mule, but I'm not a complete ass.
Marco2007
Enthusiast
Enthusiast
Posts: 638
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

Post 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
PureBasic for Windows
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Post 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)
User avatar
DoubleDutch
Addict
Addict
Posts: 3219
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Is this a single lib that covers them all (purepdf/pdfmisc/pdfdraw)?
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Marco2007
Enthusiast
Enthusiast
Posts: 638
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

Post by Marco2007 »

That was fast!
Thank you, ABBKlaus!
PureBasic for Windows
KIKI
Enthusiast
Enthusiast
Posts: 145
Joined: Thu Dec 28, 2006 11:49 am
Location: FRANCE

version PUREPDF 12

Post by KIKI »

All seems to works well
Thanks
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Post 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.
KIKI
Enthusiast
Enthusiast
Posts: 145
Joined: Thu Dec 28, 2006 11:49 am
Location: FRANCE

Post 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.
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Post 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.
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Post 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
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Post by ABBKlaus »

Thanks Thorsten1867, the fix is integrated.

Download : http://www.purebasicpower.de/downloads/ ... 2_PB42.zip
User avatar
DoubleDutch
Addict
Addict
Posts: 3219
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post 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).
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Post Reply