Author Topic: Trying to Convert PdftkBuilder from Delphi to Lazarus  (Read 6001 times)


  • Newbie
  • Posts: 1
Trying to Convert PdftkBuilder from Delphi to Lazarus
« on: December 15, 2009, 10:48:56 pm »
I used to program with Delphi 6 many years ago. But after switching to Linux I've been idle for a while. Now I'd like to get back in, and am using Lazarus.

For my first project, I'd like to convert PdftkBuilder from Delphi 7 for Windows to Lazarus. First I started tidying up the pdftk-gui program, but after I saw the PdftkBuilder, it was already organized quite nicely, so I thought I'd go with that instead. Both of these programs are just GUI's over a command-line program, so nothing that difficult.

The first real snag I've run into is that PdftkBuilder has quite a few lines of code unrelated to the command-line app, which check the number of pages in a PDF, so that it can offer the user a more intelligent choice as to page-range, should they decide to extract a certain number of pages from their PDF.

This code uses the zlib library, and I'm stuck on these lines:

//decompress the stream ...

    buffer := nil;

    zlib.DecompressBuf(p, k, k*3, pointer(buffer), bufSize);

It said it can't find DecompressBuf. So I checked the zlib unit, and sure enough, it was different, with a different number of parameters:

FUNCTION GZ_DecompressMem(srcbuf : POINTER; srclen : longword; destbuf : POINTER; destlen : longword) : LONGINT;

Anyone know why the zlib unit is different between Delphi and Lazarus? Are there any examples about how to adapt this?

Also ran into an error on the function "GetTempPath". Is this a cross-platform function or Windows only? (I'm on Ubuntu). What would be the equivalent?

If these are absolutely time-wasting questions, pointing me in the direction of a doc that will help is acceptable.


  • Hero Member
  • *****
  • Posts: 2750
Re: Trying to Convert PdftkBuilder from Delphi to Lazarus
« Reply #1 on: December 15, 2009, 10:54:46 pm »
I don't know anything about zlib, but GetTempPath is probably the Win API call.

I think you can use SysUtils' GetTempDir/GetTempFileName - see FPC's rtl.pdf for more info.




TinyPortal © 2005-2018