PurePDF Version 2.0

Developed or developing a new product in PureBasic? Tell the world about it.
normeus
Enthusiast
Enthusiast
Posts: 414
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

Re: PurePDF Version 2.0

Post by normeus »

This is what happens after you save so this will clear the PDF buffer and footer.
The title and other global variables
will still be there ( stuff that you set like pdf_SetAuthor(),pdf_SetTitle(),ETC... )

Code: Select all

ipdf_Close()
  If pdfBuffer\pData
    FreeMemory(pdfBuffer\pData)
  EndIf
  pdfBuffer\pData=0

Norm.
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
User avatar
Lord
Addict
Addict
Posts: 847
Joined: Tue May 26, 2009 2:11 pm

Re: PurePDF Version 2.0

Post by Lord »

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)
Image
normeus
Enthusiast
Enthusiast
Posts: 414
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

Re: PurePDF Version 2.0

Post by normeus »

That answer is on the help file:

Code: Select all

pdf_ResetBookMark()
by the way, I have made some useful changes to bookmarks all you have to do is copy the code if you go back a couple of page from this thread. Use google search which easily finds stuff in the forum:

https://www.google.com/advanced_search? ... rebasic.fr


Norm.
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
User avatar
Lord
Addict
Addict
Posts: 847
Joined: Tue May 26, 2009 2:11 pm

Re: PurePDF Version 2.0

Post by Lord »

Hi Norm.!
normeus wrote:That answer is on the help file:

Code: Select all

pdf_ResetBookMark()
...
Stupid me. I could have found it by myself. :oops:

I will soon test your other changes soon.

Have a nice sunday!

Lord
Image
normeus
Enthusiast
Enthusiast
Posts: 414
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

Re: PurePDF Version 2.0

Post by normeus »

There is an error with pdf_multicell() when it tries to do a line break and it is the first word it adds 1 character to the next line.
to fix this you have to go inside "Procedure.s ipdf_MultiCell()" and add a line.
around line 4759 add a line to see if this is the first word for the multicell line break:

Code: Select all

        saveX = pdfX
        If (first=#True And indent > 0)
          ipdf_SetX(pdfX + indent) 
          first = #False 
        EndIf             
        ipdf_Cell(w,h,Mid(s,j,i-j),b,2,align$,fill)      
        If j = 0: i + 1:EndIf ;>> If the first word is too long start on next character      
      Else 
        If(align$="J")
the only code you need to add is:

Code: Select all

 If j = 0: i + 1:EndIf ;
I included the other lines so you guys can see the context of the change.

@oakvalley ,@DoubleDutch
I just got a free trial of Adobe Acrobat DC and I see the error that shows when you look at properties of PDF
to fix this ( which is not an error Adobe should know it has to go to page 1 ) you do have to change "Procedure ipdf_PutCatalog()" just like @oakvalley said but what you have to change is the object that is being pointed to:
This is around line 2783 and the 1 should be changed to 3:

Code: Select all

  Select pdfZoomMode
    Case #PDF_ZOOM_FULLPAGE
      ipdf_Out("/OpenAction [3 0 R /Fit]")
    Case #PDF_ZOOM_FULLWIDTH
      ipdf_Out("/OpenAction [3 0 R /FitH null]")
    Case #PDF_ZOOM_REAL
      ipdf_Out("/OpenAction [3 0 R /XYZ null null 1]")
    Case #PDF_ZOOM_FULLSCREEN    ; <-- luis
      ipdf_Out("/PageMode/FullScreen")  ; <-- luis
    Default:
      ipdf_Out("/OpenAction [3 0 R /XYZ null null " + ipdf_StrF(pdfZoomMode/100,2) +  "]")
  EndSelect 
I tried with bookmarks and it worked fine so let me know if this does not work for you.

Norm.
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: PurePDF Version 2.0

Post by IdeasVacuum »

Valuable info, thanks normeus 8)
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Hadrianus
User
User
Posts: 34
Joined: Wed Mar 27, 2013 11:31 pm

Re: PurePDF Version 2.0

Post by Hadrianus »

I guess there is no more maintenance from the creator of this nice library. Pity.
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: PurePDF Version 2.0

Post by IdeasVacuum »

Since it is open source, that really doesn't matter, it can be modified as necessary.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
dige
Addict
Addict
Posts: 1247
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: PurePDF Version 2.0

Post by dige »

Here is a new fix (thx to ABBKlaus), if you use .otf fonts and have problems with pdf_text()
You have to add [..] "Or version = $4F54544F"

Code: Select all

[846]  If version = $10000 Or version = $4F54544F ; 0x00010000 for version 1.0 / can be 'true' or 'typ1' on Apple Systems

Code: Select all

Procedure.i ipdf_TTF_SearchTagName(*TTF_Memory.TTF_Header,TagName.s)
  Protected version,numTables,searchRange,entrySelector,rangeShift
  Protected *OffsetTable.TTF_Header_Table
  Protected tag.s,checkSum.l,offset.l,Tlength.l
  
  If *TTF_Memory
    version       = ipdf_EndianL(*TTF_Memory\sfnt_version)
    numTables     = ipdf_EndianW(*TTF_Memory\numTables)
    searchRange   = ipdf_EndianW(*TTF_Memory\searchRange)
    entrySelector = ipdf_EndianW(*TTF_Memory\entrySelector)
    rangeShift    = ipdf_EndianW(*TTF_Memory\rangeShift)
    If version = $10000 Or version = $4F54544F ; 0x00010000 for version 1.0 / can be 'true' or 'typ1' on Apple Systems

"Daddy, I'll run faster, then it is not so far..."
dige
Addict
Addict
Posts: 1247
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: PurePDF Version 2.0

Post by dige »

Hi there,

does someone knows, how to define the pdf background color?

Ciao dige
"Daddy, I'll run faster, then it is not so far..."
dige
Addict
Addict
Posts: 1247
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: PurePDF Version 2.0

Post by dige »

Use a background image now. That works for me.

But I have noticed that PurePDF can not handle 32 bit images...
"Daddy, I'll run faster, then it is not so far..."
leodh
Enthusiast
Enthusiast
Posts: 164
Joined: Sun Nov 06, 2005 6:07 am
Location: Perth Western Australia

Re: PurePDF Version 2.0

Post by leodh »

Hi all,

I am trying to get PurePDF (PurePDF225_PB52X86) working with PB5-43LTS (Windows - x86), has anyone been able to get it working.

I get the following error Invalid name: same as a command (from library "puePDF").

This is the procedure it first falls at

Code: Select all

Procedure.l pdf_AcceptPageBreak() ;Accept automatic page break or not
    ProcedureReturn ipdf_AcceptPageBreak()
  EndProcedure
Is there a quick fix for this error.

Cheers
Leo

__________________________________________________
BBCode enabled
24.08.2017
RSBasic
Regards
Leo
dige
Addict
Addict
Posts: 1247
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: PurePDF Version 2.0

Post by dige »

Looks like you've installed the libs and uses the include. I would recommend using only the include and delete the libs.
"Daddy, I'll run faster, then it is not so far..."
quasiperfect
Enthusiast
Enthusiast
Posts: 157
Joined: Tue Feb 13, 2007 6:16 pm
Location: Romania
Contact:

Re: PurePDF Version 2.0

Post by quasiperfect »

is the site down ?

can anyone share the latest version of the libs ?
Registered user of PureBasic
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: PurePDF Version 2.0

Post by RSBasic »

Look here and search for "PurePDF": http://www.rsbasic.de/backups/
Image
Image
Post Reply