Page 15 of 32

Re: PurePDF Version 2.0

Posted: Sat Oct 08, 2011 2:18 am
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.

Re: PurePDF Version 2.0

Posted: Sun Oct 09, 2011 10:36 am
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 !

Re: PurePDF Version 2.0

Posted: Sun Oct 09, 2011 11:13 am
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?

Re: PurePDF Version 2.0

Posted: Sun Oct 09, 2011 11:30 am
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

Re: PurePDF Version 2.0

Posted: Sun Oct 09, 2011 12:46 pm
by MachineCode
Now I see. I did a search for "#PurePDF_Include", not "PurePDF_Include" (note the hash). :)

Re: PurePDF Version 2.0

Posted: Tue Nov 01, 2011 4:21 pm
by IdeasVacuum
Can anyone show me how to use pdf_ImageMem() with a CatchImage()?

Re: PurePDF Version 2.0

Posted: Wed Nov 02, 2011 1:34 am
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)

Re: PurePDF Version 2.0

Posted: Wed Nov 02, 2011 7:56 pm
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.

Re: PurePDF Version 2.0

Posted: Mon Dec 05, 2011 3:14 am
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

Re: PurePDF Version 2.0

Posted: Thu Feb 23, 2012 7:32 pm
by ABBKlaus

Re: PurePDF Version 2.0

Posted: Fri Feb 24, 2012 5:31 pm
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

Re: PurePDF Version 2.0

Posted: Fri Feb 24, 2012 6:46 pm
by IdeasVacuum
...it is possibly a Compiler setting. Compiler/Compiler Options, try un-ticking the unicode and thread safe options.

Re: PurePDF Version 2.0

Posted: Fri Feb 24, 2012 10:39 pm
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

Re: PurePDF Version 2.0

Posted: Sat Feb 25, 2012 9:19 am
by graves
It works fine now.
Thanks for this very very usefull library.

Re: PurePDF Version 2.0

Posted: Tue Mar 13, 2012 9:36 am
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