Code: Select all
Global title.s
Global Col.f
Global y0.f
title="20000 Leagues Under the Seas"
#ZLIB_VERSION = "1.2.3"
#ZLIB_VERNUM = $1230
XIncludeFile "Source\PurePDF_res.pb"
XIncludeFile "Source\PurePDF.pb"
Structure z_stream
*next_in.l
avail_in.l
total_in.l
*next_out.l
avail_out.l
total_out.l
*msg.l
*state.l
zalloc.l
zfree.l
opaque.l
data_type.l
adler.l
reserved.l
EndStructure
ImportC "ZLIB.lib"
_compress.l(*dest,*destlen,*source,sourcelen) As "_compress"
EndImport
Procedure.b Compress(*aData.MEM_DataStructure)
Protected zerr.b
Protected CompMem.l
Protected sourcelen.l
Protected SourceMem.l
Protected CompLen.l
Protected lbError.b
lbError = #False
sourcelen = *aData\lCurSize
SourceMem = *aData\pData
CompLen.l = (Int(sourcelen/8000)+1)*8000 + 16
CompMem=AllocateMemory(CompLen)
If CompMem
zerr=_compress.l(CompMem,@CompLen,SourceMem,sourcelen)
If zerr = 0
*aData\pData = CompMem
*aData\lMaxSize = CompLen
*aData\lCurSize = CompLen
FreeMemory(SourceMem)
lbError = #True
EndIf
EndIf
ProcedureReturn lbError
EndProcedure
Procedure Header()
pdf_SetFont3("Arial","B",15)
w = pdf_GetStringWidth(title)+6
pdf_SetX((210 - w)/2)
pdf_SetDrawColor3(0,80,180)
pdf_SetFillColor3(230,230,0)
pdf_SetTextColor3(220,50,50)
pdf_SetLineWidth(1)
pdf_Cell7(w,9,title,1,1,#PDF_ALIGN_CENTER,1)
pdf_Ln2(10)
y0 = pdf_GetY()
EndProcedure
Procedure footer()
pdf_SetY(-15)
pdf_SetFont3("Arial","I",8)
pdf_SetTextColor(128)
txt.s = "Page " + Str(pdf_GetPageNo())
pdf_Cell6(0,10,txt,0,0,#PDF_ALIGN_CENTER)
EndProcedure
Procedure AcceptPageBreak()
ProcedureReturn #True;
EndProcedure
pdf_Init()
pdf_Create()
pdf_SetProcFooter(@footer())
pdf_SetProcHeader(@Header())
pdf_SetProcCompression(@Compress())
pdf_SetProcAcceptPageBreak(@AcceptPageBreak())
pdf_SetFont3("Arial","", 8)
pdf_AddPage()
myshorttext$ = "123456789 123456789 123456789 123456789 123456789 123456789 123456789 "
mylongtext$ = myshorttext$ + #PDF_NEWLINE + myshorttext$ + #PDF_NEWLINE + myshorttext$
Level = 0
For i = 1 To 14000
pdf_Cell7(10 , 5, Str(i), 0, 0, #PDF_ALIGN_LEFT, 0 )
pdf_SetX(20)
pdf_Cell7(150, 5, myshorttext$, 0, 1, #PDF_ALIGN_LEFT, 0)
pdf_SetX(25)
pdf_MultiCell6(150, 3, mylongtext$ , 0, #PDF_ALIGN_LEFT , 0, 0, 0)
Next
pdf_Save("CompressionTest.pdf")
MessageRequester("OK", "Done " + Str(i), #MB_OK|#MB_ICONINFORMATION)
And the very strange thing: if I use title="Textlist" (line 5) and not title="20000 Leagues Under the Seas", the comressed pdf-file is also opened without error.
Same with PB4.20
Hope ABBKlaus you can help and find a solution