PurePDF Version 2.0

Developed or developing a new product in PureBasic? Tell the world about it.
Hurga
Enthusiast
Enthusiast
Posts: 148
Joined: Thu Jul 17, 2003 2:53 pm
Contact:

Post by Hurga »

With the PB-IDE i got the "constant not found -error"
:shock:
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Post by ABBKlaus »

i think you haven´t installed the lib correctly.
Please read this how to (its located at the bottom) : http://www.purearea.net/pb/english/userlibs.php

These files are needed (at least the first two) to run the demo´s :

Code: Select all

%PBDIR%\PureLibraries\UserLibraries\PurePDF
%PBDIR%\Residents\PurePDF_res.res
%PBDIR%\SubSystems\UserLibThreadSafe\PureLibraries\UserLibraries\PurePDF
%PBDIR%\SubSystems\UserLibUnicode\PureLibraries\UserLibraries\PurePDF
%PBDIR%\SubSystems\UserLibUnicodeThreadSafe\PureLibraries\UserLibraries\PurePDF
Hurga
Enthusiast
Enthusiast
Posts: 148
Joined: Thu Jul 17, 2003 2:53 pm
Contact:

Post by Hurga »

Hm, all files are where they should be.... (that was one of the first things i checked)
That the strange thing for me. I cant guess what It could be ...
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Post by ABBKlaus »

ok my last thought : are you using Windows Vista :?:
Hurga
Enthusiast
Enthusiast
Posts: 148
Joined: Thu Jul 17, 2003 2:53 pm
Contact:

Post by Hurga »

Nop, Win X2 SP 2... sorry..
User avatar
Thorsten1867
Addict
Addict
Posts: 1372
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Post by Thorsten1867 »

I found a bug. If the text is shorter than "..." it causes a endless loop (infinite loop).

Code: Select all

Procedure.s pdf_TruncateCell(w.f, h.f=0, Text$="", border.w=0, Ln.f=0, Align$=#PDF_ALIGN_LEFT, Fill.f=0, Link.w=0, trunc$="...")
  Protected wMax.f, TLen.l, short$
  If w <= 0 ; Seitenbreite
    w = pdfW - pdfRMargin - pdfX
  EndIf
  wMax = w - (2 * pdfCMargin)
  If pdf_GetStringWidth(Text$) <= wMax
    pdf_Cell(w, h, Text$, border, Ln, Align$, Fill, Link)
  Else
    TLen = Len(Text$)
    While TLen
      TLen - 1
      short$ = Left(Text$, TLen)+trunc$
      If pdf_GetStringWidth(short$) <= wMax
        Break
      EndIf
    Wend
    If TLen < 1 : short$ = "" : EndIf
    pdf_Cell(w, h, short$, border, Ln, Align$, Fill, Link)
    ProcedureReturn Right(Text$, Len(Text$)-TLen)
  EndIf
EndProcedure
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
User avatar
Thorsten1867
Addict
Addict
Posts: 1372
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Post by Thorsten1867 »

Is it possible to attach a file to the pdf? I need to add the source file to the pdf.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Post by ABBKlaus »

Thorsten1867 wrote:Is it possible to attach a file to the pdf? I need to add the source file to the pdf.
Yes, it should be possible. I will try to implement this.

BTW: the updated pdf_TruncateCell will be included in the next release
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Post by ABBKlaus »

@Thorsten1867,

i made a beta version that is capable of embedding files.
You can download it here : http://www.purebasicpower.de/downloads/ ... 4_PB43.zip

A test file is i.e. Tutorial27 Include File.pb

Regards Klaus
User avatar
Thorsten1867
Addict
Addict
Posts: 1372
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Post by Thorsten1867 »

Great! Thanks!
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
User avatar
Thorsten1867
Addict
Addict
Posts: 1372
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Post by Thorsten1867 »

How can I (my program) extract the files again? (without Acrobat Reader)
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Post by ABBKlaus »

Thorsten1867 wrote:How can I (my program) extract the files again? (without Acrobat Reader)
You will have to parse the pdf and search for file objects.

Code: Select all

6 0 obj
<</F(20k_c1.txt)/EF<</F 7 0 R>>/Desc ()/Type/Filespec>>
endobj
This points to the Embedded file object :

Code: Select all

7 0 obj
<</Type/EmbeddedFile/Params<<
/Size 5512
/CreationDate (D:20081003014113Z)
/ModDate (D:20051017181816Z)
>>
/Length 6892
/Filter/ASCII85Decode
>>
stream
...
endstream
endobj
In this example the stream is ASCII85 encoded but can also be FlateDecode (thats zip-algo) !
User avatar
Thorsten1867
Addict
Addict
Posts: 1372
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Post by Thorsten1867 »

Thanks a lot! I will try it.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
User avatar
Thorsten1867
Addict
Addict
Posts: 1372
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Post by Thorsten1867 »

It seems I need something like "ipf_ASCII85_Decode()". I can create the files, but they are not readable.

Code: Select all

If ReadFile(0, "D:\Temp\Tutorial27 Include File.pdf")
  While Eof(0) = 0
    row$ = ReadString(0)
    If Left(row$,5) = "<</F("
      FileName.s = Mid(row$, 6, FindString(row$, ")", 6) - 6)
      Repeat : Until ReadString(0) = "<</Type/EmbeddedFile/Params<<"
      Size = Val(StringField(ReadString(0),2," "))
      Repeat : Until ReadString(0) = "stream"
      *Buffer = AllocateMemory(Size+1)
      If *Buffer
        Bytes = ReadData(0, *Buffer, Size)
        If CreateFile(1, "D:\Temp\"+FileName)
          WriteData(1, *Buffer, Bytes)
          CloseFile(1)
        EndIf
      EndIf
    EndIf
  Wend
  CloseFile(0)
EndIf
Last edited by Thorsten1867 on Wed Oct 22, 2008 6:33 pm, edited 2 times in total.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Post by ABBKlaus »

Thorsten1867 wrote:It seems I need something like "ipf_ASCII85_Decode()". I can create the files, but they are not readable.
I think i never needed to decode it myself. I will code one for you this weekend :wink:
Post Reply