Hi Norm.!
Thanks Norm.! Your snipped works.
But now I stumbled over the next hurdle.
It has to do with bookmarks.
When I create a PDf document twice, the first copy
will have bookmarks, the second has none. Everything
else looks ok.
It makes no difference wether
- I create the first document save this and creating
the second and save that
or
- interrupting the creation of the first document and
create this document again and save it.
Always the bookmarks are missing on second run.
When debugging, I can see that pdf_BookMark(msg)
is always called and msg has always the correct text.
What can be the reason for this?
Here is the example showing this result. I took the last
test code and put the pdf-creation in an procedure
and call this procedure twice:
Code: Select all
;Unicode example
;===============
#PurePDF_Include=1
XIncludeFile "\purepdf\Examples\PurePDF.pb" ; <-------- REPLACE THIS FILES LOCATION
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
#ZLIB_IMPORT_PATH = #PB_Compiler_Home + "purelibraries/linux/libraries/zlib.a"
CompilerCase #PB_OS_Windows
#ZLIB_IMPORT_PATH = "zlib.lib"
CompilerCase #PB_OS_MacOS
#ZLIB_IMPORT_PATH = "/usr/lib/libz.dylib"
CompilerEndSelect
ImportC #ZLIB_IMPORT_PATH
compress.l(*dest, *destlen, *source, sourcelen)
EndImport
Procedure.l PDFCompress(*aData.MEM_DataStructure)
Protected zerr,CompMem,SourceLen,SourceMem,CompLen,lbError
lbError = #False
SourceLen = *aData\lCurSize
SourceMem = *aData\pData
CompLen = (Int(SourceLen/8000)+1)*8000 + 16
CompMem=AllocateMemory(CompLen)
If CompMem
zerr=compress(CompMem,@CompLen,SourceMem,SourceLen)
If zerr = 0
*aData\pData = CompMem
*aData\lMaxSize = CompLen
*aData\lCurSize = CompLen
;FreeMemory(Sourcemem) ; <- Crash with enabled purifier if run as TailBiten library
lbError = #True
EndIf
EndIf
ProcedureReturn lbError
EndProcedure
Procedure Footer()
pdf_SetY(-15);
pdf_SetFont("MS SansSerif","I",8);
pdf_Cell(0,10,"Page "+Str(pdf_GetPageNo())+"/"+Chr(14),0,0,#PDF_ALIGN_CENTER);
EndProcedure
Procedure makePDF(run)
Protected File$
Protected String$,StringWidth.d,i
Protected CreateBookmarks=#True
File$=GetFilePart(#PB_Compiler_File)
File$=Mid(File$,1,Len(File$)-Len(GetExtensionPart(File$))-1)
pdf_Create()
pdf_SetProcFooter(@Footer())
pdf_AliasNbPages(Chr(14)); you need this to match your Footer procedure currently chr(16)
pdf_SetAuthor("PurePDF")
pdf_SetTitle(File$)
pdf_SetSubject("Unicode Text")
pdf_SetCreator("PurePDF")
pdf_SetKeywords(StringField(File$,1," "))
; pdf_SetProcCompression(@PDFCompress())
pdf_AddPage()
pdf_SetFont("Lucida Sans Unicode","",28)
pdf_Text(20,30,"PU??PЃ is ????")
pdf_BookMark("Page 1a")
pdf_Text(20,50,"??¤????????")
pdf_Text(20,70,Chr($107)+Chr($108)+Chr($109)+Chr($10A)+Chr($10B)+Chr($10C)+Chr($10D))
pdf_SetFont("Lucida Sans Unicode","",28)
For i=1 To 15
pdf_AddPage()
If CreateBookmarks
pdf_BookMark("Page "+Str(i+1))
EndIf
pdf_Text(20,30,"PU??PЃ is ????")
pdf_Text(20,50,"??¤????????")
pdf_Text(20,70,Chr($107)+Chr($108)+Chr($109)+Chr($10A)+Chr($10B)+Chr($10C)+Chr($10D))
pdf_text(20, 90, "Counter i="+Str(i))
Next
file$=Str(run)
pdf_Save(File$+".pdf")
RunProgram(File$+".pdf")
EndProcedure
makepdf(1)
makepdf(2)