PurePDF Version 2.0

Developed or developing a new product in PureBasic? Tell the world about it.
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: PurePDF Version 2.0

Post by MachineCode »

c4s wrote:
ABBKlaus wrote:Hint3 : Its now possible to use the PurePDF sources as includefile, just set #PurePDF_Include=1 to something and it will be included
Does it mean I don't have to use it as a Userlib any longer? If so, thanks! :D
I don't get this. How do I include PurePDF as part of my source instead of lib? I don't see how setting a constant will include it.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Re: PurePDF Version 2.0

Post by ABBKlaus »

@Machinecode, sorry it wasn´t well explained :oops:

Please look into the "Tutorial32 Unicode.pb" code to get you started.
Tutorial32 Unicode.pb wrote:#PurePDF_Include=1
XIncludeFile "Source\PurePDF.pb" ; You might want to change the path to the Sources of PurePDF !
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: PurePDF Version 2.0

Post by MachineCode »

Sorry, I still don't get it. #PurePDF_Include is only defined ONCE, in the "Tutorial32 Unicode.pb" file, and is NOT referenced anywhere else, such as the source or residents file. So, what's the point of defining it, if there's no other code using it?
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Re: PurePDF Version 2.0

Post by ABBKlaus »

Its used inside the sources of PurePDF :

Code: Select all

CompilerIf Defined(PurePDF_Include,#PB_Constant)
  IncludePath #PB_Compiler_FilePath
  XIncludeFile "PurePDF_res.pb"
  IncludePath ""
CompilerEndIf
...
CompilerIf Defined(PurePDF_Include,#PB_Constant)
  pdf_Init()
  ; - PurePDF commands used as Includefile
  Procedure.l pdf_AcceptPageBreak() ;Accept automatic page break or not
    ProcedureReturn ipf_AcceptPageBreak()
  EndProcedure
...
...
CompilerElse
  ; - PurePDF commands used as TailBiten Library
  ProcedureDLL.l pdf_AcceptPageBreak() ;Accept automatic page break or not
    ProcedureReturn ipf_AcceptPageBreak()
  EndProcedure
...
...
CompilerEndIf
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: PurePDF Version 2.0

Post by MachineCode »

Now I see. I did a search for "#PurePDF_Include", not "PurePDF_Include" (note the hash). :)
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: PurePDF Version 2.0

Post by IdeasVacuum »

Can anyone show me how to use pdf_ImageMem() with a CatchImage()?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
swan
Enthusiast
Enthusiast
Posts: 225
Joined: Sat Jul 03, 2004 9:04 am
Location: Sydney Australia
Contact:

Re: PurePDF Version 2.0

Post by swan »

A cut-&-paste from one of my apps, hope it helps:

Code: Select all

;- Image Globals
Global Image1
Global Image2

;- Catch Images
Image1 = CatchImage(1, ?Image1)
Image2 = CatchImage(2, ?Image2)

;- Images
DataSection
Image1:
  IncludeBinary "D:\projects\BpMining\Lubenet.jpg"
Image2:
  IncludeBinary "D:\projects\BpMining\Lubenet.png"
EndDataSection
Then:

Code: Select all

    pdf_Create("P","mm",#PDF_PAGE_FORMAT_A4)
    pdf_AddPage()
    pdf_SetFillColor(200) 
    pdf_Rect(35,22,165,5,#PDF_STYLE_FILL)
    pdf_Rect(10,110,190,5,#PDF_STYLE_FILL)
    pdf_ImageMem("Lubenet.jpg",?Image1,?Image2-?Image1,10,10) 
    pdf_SetFont("Arial","B",20)
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: PurePDF Version 2.0

Post by IdeasVacuum »

Ah, that's it thank you - forgot that little trick on how to get the image size.

Just noticed something incredible - the latest Adobe Reader is ~115MB - seems a bit ott.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: PurePDF Version 2.0

Post by IdeasVacuum »

Tried this to password-protect (weak, but something) a PDF:

Code: Select all

sPdfName.s = "C:\MyPdf.pdf"

pdf_Create("P","mm",#PDF_PAGE_FORMAT_A4)
pdf_AddPage()
pdf_IncludeJS("pass=prompt('enter password',' ');if(pass=='secret')alert('OK');")
pdf_Save(sPdfName)
......the script fails to execute though. I assume there is too much missing from the script and/or the syntax is incorrect.

Has anyone used pdf_IncludeJS or pdf_IncludeFileJS?

same question from shire: http://www.purebasic.fr/english/viewtop ... 13&t=48538

Edit: OK, got hold of Adobe's PDF Javascript API guide and solved the script issue (not so pretty but it works).
See:http://www.purebasic.fr/english/viewtop ... 89#p369589
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Re: PurePDF Version 2.0

Post by ABBKlaus »

User avatar
graves
Enthusiast
Enthusiast
Posts: 160
Joined: Wed Oct 03, 2007 2:38 pm
Location: To the deal with a pepper

Re: PurePDF Version 2.0

Post by graves »

Hi ABBKlaus,
It's my first time on PurePDF. I've downloaded your PDF222-PB46X86 version and I've copied it on my Purebasic Folders.
When I try to compile "Tutorial27 Include File.pb" souce (from examples folder), PBcompiler say:
******************************************
PureBasic 4.60 (Windows - x86)
******************************************
Compiling w:\Program Files\PureBasic\Examples\PurePDF\Tutorial27 Include File.pb

Loading external libraries...
Starting compilation...
17 lines processed.
Creating executable "w:\Program Files\PureBasic\Examples\PurePDF\Tutorial27 Include File.exe".
Error: Linker
POLINK: error: Unresolved external symbol '_PB_FindString'.
POLINK: fatal error: 1 unresolved external(s).
What is wrong?
Do I need to "install" anything more?

BR
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: PurePDF Version 2.0

Post by IdeasVacuum »

...it is possibly a Compiler setting. Compiler/Compiler Options, try un-ticking the unicode and thread safe options.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Re: PurePDF Version 2.0

Post by ABBKlaus »

nope. it was my fault, the lib was from 4.51 :oops:

The archive has now the correct version, compiled with PureBasic 4.61 Beta 1.

[Edit]Should also work with PureBasic 4.60[/Edit]

BR Klaus
User avatar
graves
Enthusiast
Enthusiast
Posts: 160
Joined: Wed Oct 03, 2007 2:38 pm
Location: To the deal with a pepper

Re: PurePDF Version 2.0

Post by graves »

It works fine now.
Thanks for this very very usefull library.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: PurePDF Version 2.0

Post by DoubleDutch »

PurePdf didn't take style into account when embedding fonts. If you had a font with 2 different styles, only one would be embedded... this would result in the 2nd text item being corrupted.

Here is the fixed bits:

Code: Select all

Structure PDF_ObjectStructure
  Buffer.i ; Buffer
  Buflen.i ; Bufferlength
  pdfN.i   ; when ipf_Put...() is called this is the pointer to the object
  vStyle.i	; style
  Name$ ; Name of an object
  Desc$ ; Description (optional)
  CreationDate$ ; The date and time when the embedded file was created.
  ModDate$ ; The date and time when the embedded file was last modified.
EndStructure
.
.
.

Code: Select all

            vFound=#False
            ForEach FontList()
            	If FontList()\Name$ = FontName$
            		If FontList()\vStyle = vStyle
	                vFound=#True
	                Break
	              EndIf
              EndIf
            Next
            
            ; if Font is not already defined load it into memory
            If vFound=#False
              Mem=0:Len=0
              If ipf_Get_Font(hDC,@Mem,@Len)
                AddElement(FontList())
                FontList()\Name$  = Fonts()\Name$
                FontList()\Buffer = Mem
                FontList()\Buflen = Len
                FontList()\pdfN   = 0
                FontList()\vStyle = vStyle
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Post Reply