cPDF Class

Started by Richard Kelly, May 19, 2026, 07:48:11 PM

Previous topic - Next topic

Richard Kelly

cPDF is my evolving effort to create a Freebasic PDF generator using as much of AFXNova as I can. Attached is a very preliminary first test effort. There is much more to do like finding our why test underlining is inconsistent, and, adding images, zlib compression, outlines, etc support. I have coded what I've called Place Holder objects that can be created that get drawn on every page and I included a page numbering object so pages can be automatically numbered both current and total pages. The attached is my first result. Adobe Acrobat is very tight with it's standards and doesn't like my generated PDF although it renders fine with either Edge or Chrome. More work to do there so Adobe doesn't complain. I'm not planning on creating linearized PDF's as the main focus is use PDF's in my other apps for reports (that are not generally very large) and not bother with all the errata with window printers.

Richard Kelly

#1
Shapes and Images support added with thumbnails option added.

Richard Kelly

#2
Zlib support added (attached PDF was compressed by Zlib)
Outline/Bookmarks added (you can turn them on in your viewer)
Courier Font added.
Adobe has stopped complaining about my streams. Picky...Picky...

I still have to figure out why underlining is inconsistent.

If there is some part of the PDF 1.7 specification you might find useful, let me know.

Zlib support looks like this: (The FB zlib.bi has a lib reference that isn't defined anywhere I could find)

   ZLibCompress               AS FUNCTION (BYVAL sDestination AS ANY PTR, BYREF nDestinationLen AS ULONG, BYVAL sSource AS ANY PTR, BYVAL nSourceLen AS ULONG) AS LONG
   ZLIBCompressBound          AS FUNCTION (BYVAL sourceLen AS ULONG) AS ULONG


' Load zLib if it provided

    hZlib = LoadLibrary("zlib1.dll")
    If hZlib <> 0 Then
        ZLibCompress = DyLibSymbol(hZlib, "compress")
        ZLibCompressBound = DyLibSymbol(hZlib, "compressBound")
        If ZLibCompress = 0 ORELSE ZLibCompressBound = 0 Then
           FreeLibrary hZlib
           hZlib = 0
        End If

    End If