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

Re: PurePDF Version 2.0

Post by ABBKlaus »

I can only add a check in ipdf_putbookmarks() and it will break iteration if it finds an invalid level.
You can check with pdf_geterrorcode() after pdf_save() for the errorcode 19 alias #PDF_ERROR_BOOKMARK.
I have uploaded a new version, same link as above.

BR Klaus
normeus
Enthusiast
Enthusiast
Posts: 415
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

Re: PurePDF Version 2.0

Post by normeus »

I added the following if test at the end of "ipdf_PutBookMarks()" procedure

Code: Select all

 
   ;OutLine root
    ipdf_NewObj()
    pdfOutlineRoot = ipdf_GetN()
    ipdf_Out("<</Type /Outlines /First " + Str(ln) + " 0 R")
    If (SelectElement(lru(),0)) ; just in case there was a problem
      ipdf_Out("/Last " + Str(ln + lru()) + " 0 R>>")
    Else
      ipdf_Out("/Last " + Str(ln) + " 0 R>>")
      pdfError=#PDF_ERROR_BOOKMARK
    EndIf
    ipdf_Out("endobj")
  EndIf
EndProcedure 
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Re: PurePDF Version 2.0

Post by ABBKlaus »

Thanks normeus,

fix is added. Tailbiten libs can be (re)downloaded from my page.

BR Klaus
Tranquil
Addict
Addict
Posts: 950
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Re: PurePDF Version 2.0

Post by Tranquil »

At first I want to thank all who improved this great lib!

Using this lib leads me to two questions:

1st: Is there a way to avoid including complete Fonts in the PDF File? If I export an PDF File from out of MS-Word, these fonts will not be included.
2nd: If i create a printer object (for eg with PB internal printer lib or the external Printer_Lib include), is it possible to print it to PDF?

Thank you very much!!
Tranquil
User avatar
VisualJump3D
User
User
Posts: 75
Joined: Thu Jun 23, 2011 8:32 pm
Location: italy
Contact:

I get this error ..

Post by VisualJump3D »

Hi ,



I tried this example: <<Tutorial 01 Hello Word.pb>>

I get this error in purePDF.pb :

<<Line 5584:Invalide name:same as a command ( from library PurePDF ) >>

Can you help me, please ?

Thank
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 »

Take a look at Line 5584 in PurePDF.pb and you should see the cause of the problem - a rename of the command with a prefix or postfix ought to fix it.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
VisualJump3D
User
User
Posts: 75
Joined: Thu Jun 23, 2011 8:32 pm
Location: italy
Contact:

Re: PurePDF Version 2.0

Post by VisualJump3D »

?????
User avatar
VisualJump3D
User
User
Posts: 75
Joined: Thu Jun 23, 2011 8:32 pm
Location: italy
Contact:

Re: PurePDF Version 2.0

Post by VisualJump3D »

<<Take a look at Line 5584 in PurePDF.pb and you should see the cause of the problem - a rename of the command with a prefix or postfix ought to fix it.>>

I did it but it does not work ...


can someone help me?

( please )
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: PurePDF Version 2.0

Post by c4s »

@VisualJump3D
Seems like you have the library installed (in compiler folder "\PureLibraries\UserLibraries\" and "\Residents\"). The problem is that the example tries to include the include file too. So all PurePDF commands would be declared twice which doesn't work.
I think IdeasVacuum's comment doesn't help here. Instead you should completely remove the library and just use the include file wherever you need it. That way you can also fix and enhance PurePDF yourself e.g. if something doesn't work as you want it to.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User avatar
VisualJump3D
User
User
Posts: 75
Joined: Thu Jun 23, 2011 8:32 pm
Location: italy
Contact:

Re: PurePDF Version 2.0

Post by VisualJump3D »

Thank !
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 »

I think IdeasVacuum's comment doesn't help here.
I think that's true, sorry VisualJump3D. However, using the files as an include instead of installing the lib can still be a challenge, so unless you need to modify the files, it might be easier to just use the lib. That said, the lib might not be available for the PB version you are using, I think it ran into a TailBite issue.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
VisualJump3D
User
User
Posts: 75
Joined: Thu Jun 23, 2011 8:32 pm
Location: italy
Contact:

Re: PurePDF Version 2.0

Post by VisualJump3D »

Thanks! Problem solved!
Franky
Enthusiast
Enthusiast
Posts: 213
Joined: Sat Apr 26, 2003 2:58 pm

Re: PurePDF Version 2.0

Post by Franky »

Thanks for the great work, this is really helpfull to me.

Was this bug already mentioned?

Code: Select all

#PurePDF_Include=1
XIncludeFile "PurePDF.pb"

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

Define file$="Tutorial02 Header-Footer.pdf"
Define i

pdf_Create()
pdf_SetProcFooter(@Footer())
pdf_AliasNbPages();
pdf_AddPage();
pdf_SetFont("Times","",12);
For i = 1 To 40
  pdf_AddPage();
  pdf_Cell(0,10,"Printing line number "+Str(i),0,1);
Next
pdf_Save(file$)
RunProgram(file$)
Enable Unicode, than take a look at the Page numbering!


Sorry, I didn't run through the 28 pages, and read all posts :lol:


Best regards

Franky
Give Up everything but trying!
Franky
Enthusiast
Enthusiast
Posts: 213
Joined: Sat Apr 26, 2003 2:58 pm

Re: PurePDF Version 2.0

Post by Franky »

Hi there,
another small issue:

http://www.purebasicpower.de/downloads/ ... tSize.html

The help says, pdf_GetFontSize() returns the size in points. Actually it returns the size in mm (or the current format?)
Give Up everything but trying!
normeus
Enthusiast
Enthusiast
Posts: 415
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

Re: PurePDF Version 2.0 - unicode

Post by normeus »

This Procedure replaces "{nb}" (aSource.s) with "41" ( aDest.s) or the number of final pages; in memory storage aData.MEM_DataStructure
it is the only time it is used by PurePDF.
it is a count backwards one byte at a time routine, however; in unicode it would be 2 bytes at a time.
I don't know if the rest of purepdf is unicode ready but for the problem of total page numbers loosing a byte fixing this routine would fix it.
I don't have the time to fix it now but since the routine is pretty generic I figure anyone even if not familiar with purepdf would come up with a clever way of replacing FOR loops with WHILE loops and using StringByteLength(aSource.s) as a STEP for the loops
Thanks in advance
Norm.

Code: Select all

Procedure MEM_DataReplace(*aData.MEM_DataStructure, aSource.s, aDest.s)
  Protected vSourceLen,vDestLen,vCurSize,vMaxSize,vCount,vFind,*tmp,vReturn,i,j
  
  vSourceLen   = Len(aSource)
  vDestLen     = Len(aDest)
  vCurSize     = *aData\lCursize  
  vMaxSize     = *aData\lMaxsize  
  vFind        = 0
  vReturn      = #True
  
  If (vDestLen > vSourceLen)
    For i = vCurSize To 0 Step -1
      vCount= 0
      For j = 1 To vSourceLen
        If PeekB(*aData\pData + i - vSourceLen + j - 1) = Asc(Mid(aSource,j,1))
          vCount = vCount + 1
        EndIf
      Next 
      If vCount = vSourceLen   
         vFind = vFind + 1   
      EndIf
    Next
    If (vFind > 0)
      vReturn = MEM_DataInit(*aData, vMaxSize + (vFind*(vDestLen - vSourceLen))) ; = #False
    EndIf  
  EndIf
  
  If vReturn = #True
    *tmp = AllocateMemory((vDestLen + vCurSize) - vSourceLen)
    If *tmp
      For i = vCurSize To 0 Step -1
        vCount= 0
        For j = 1 To vSourceLen
          If PeekB(*aData\pData + i - vSourceLen + j - 1) = Asc(Mid(aSource,j,1))
            vCount = vCount + 1
          EndIf
        Next
        If vCount = vSourceLen
          CopyMemory(*aData\pData + i, *tmp, *aData\lCurSize - i)
          CopyMemory(@aDest, *aData\pData + i - vSourceLen , vDestLen)
          CopyMemory(*tmp, *aData\pData + i - vSourceLen + vDestLen, *aData\lCurSize - i)
          *aData\lCurSize = *aData\lCurSize + (vDestLen-vSourceLen)
        EndIf
      Next
      FreeMemory(*tmp)
    Else
      vReturn = #False
    EndIf
  EndIf
  ProcedureReturn vReturn
EndProcedure
Post Reply