Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PDF Generation update
#1
Hello all,

Here is a small update to my pdfGenerator(https://qb64phoenix.com/forum/showthread.php?tid=3504). 

I've added a few minor commands since my last update, and started work on some proper documentation. 

In the files, I have included a demo that generates a small book of holiday mazes for kids to solve along with solutions.
Note: The generation is slow, about 5 to 10 minutes. 
 
[Image: Screenshot-from-2025-11-28-18-23-58.png]

If you examine the library files (pdfGen.bm) you may notice there is some peculiar notations in the comments. That is part of my documentation project. I figure users would look at the library first, and then at the docs. So, I figured I would write the docs once in the library and use pdfGen to extract the docs from the library.

At some point I will post it to my github, but I have lost quite a bit of work on there, because I'm such an amateur at it. 

For those of you that are nervous about .zip files from strangers on the internet, I've included all the necessary files, but you will have to make sure the filenames are correct. These are the files located in the zip file.

File names of the silhouettes in no particular order.

Bell.png
CandyCane.png
ChristmasTree.png
GingerBreadman.png
Present.png
SantaHat.png
sleigh.png
Stocking.png
Turkey.png

The following are the silhouettes for the mazes. 

[Image: Candy-Cane.png] [Image: Christmas-Tree.png] [Image: Ginger-Breadman.png] [Image: Present.png] [Image: SantaHat.png] [Image: sleigh.png] [Image: Stocking.png] [Image: Bell.png]

 
[Image: Turkey.png]


Attached Files
.zip   pdfGen_Holiday.zip (Size: 851.65 KB / Downloads: 26)
.bi   pdfGen.bi (Size: 12.03 KB / Downloads: 21)
.bm   pdfGen.bm (Size: 74.19 KB / Downloads: 21)
.bas   pdfMaze.bas (Size: 26.45 KB / Downloads: 16)
Reply
#2
Hi
Glad to see you are still working on the project. I'm away from my PC until Tuesday. I'll take a look when I get back. What are the minor commands that you've added?
Oh look. A sig line :-)
Reply
#3
Quote:What are the minor commands that you've added?
I've only added three. They were helpful in my maze book project.

Code: (Select All)
SUB pdfSetLineCapStyle (c AS LONG)
SUB pdfSetLineJoinStyle (c AS LONG)
SUB pdfSetLineDashPattern (ondash AS LONG, offdash AS LONG, phase AS LONG)

pdfSetLineCapStyle sets what the end caps of a line segment should look like.


[Image: Screenshot-from-2025-11-29-15-08-51.png]

pdfSetLineJoinStyle sets how the connected line appear.


[Image: Screenshot-from-2025-11-29-15-11-20.png]


pdfSetLineDashPattern changes the lines to dashed or dotted lines.


[Image: Screenshot-from-2025-11-29-15-13-52.png]
Reply
#4
Finally got around to looking at the update. One thing you may want to alter is line 67 of pdfGen.bm  At the moment it's
Print "Doh! I'm the library not the main program!" 
I don't think that's needed  Big Grin

I have altered the file just a little. I've remed out the logFile section. It's not something I need. Apart from that it's great.
I ran the maze demo and printed them out for my wife. She seemed happy and hopefully it'll keep her quiet for a while.
Oh look. A sig line :-)
Reply
#5
Have you broken something?  I've just run a little test with the old and new .bm and .bi files. I've got the following lines in my demo

'
Code: (Select All)
 ' Define page size
' Landscape

pdfMediaBox 0, 0, 792, 612

' Portrait
pdfMediaBox 0, 0, 612, 792
 

With the old .bm and .bi files the PDF creates either landscape or portrait depending on which I've got unremmed. With the new .bm and .bi files the the PDF size is wrong

The demo prog I'm using is below in case you want to see what I'm doing. The two test text files are also attached (I hope!)

Code: (Select All)
'$Include:'pdfGen.bi'

' Read file and output to PDF
' 09-03-25
' Added page numbers
' 10-03-25
' Added title,author, creator and producer info

pdfDefault.info.title = "PAT Download Data"
pdfDefault.info.author = "Colin Birch"
pdfDefault.info.creator = "SNDownload"
pdfDefault.info.producer = "SNDownload"

' Define page size
' Landscape

pdfMediaBox 0, 0, 792, 612

' Portrait
'pdfMediaBox 0, 0, 612, 792

' Available fonts

'Courier            Symbol
'Courier-Bold        Times-Roman
'Courier-Oblique    Times-Bold
'Courier-BoldOblique Times-Italic
'Helvetica          Times-BoldItalic
'Helvetica-Bold      ZapfDingbats
'Helvetica-Oblique  Helvetica-BoldOblique
'
' Set up new page, font and line spacing

pdfAddPage
pdfLoadFont "F1", PDF_FONT_COURIER
pdfSetLeading 11

' First page setup

pdfBeginText
pdfSetFontSize "F1", 11
pdfSetPosition 16, 592

' fe% = 1 - Input file exist
' pa% - page number
' pa$ - Text to print before page number

fe% = 0
pa% = 1
pa$ = "Page "

' ***************************************
ofn$ = "sndownload5.pdf"

'fn$ = "sndownload.cfg"
fn$ = "header-wideorig.txt"
'fn$ = "header.txt"

' Lets check file exists

If _FileExists(fn$) Then

    ' it exists. Set fe% and open file
    fe% = 1
    Open fn$ For Input As #3

    Do While Not EOF(3)

        ' Input text from file, add it to PDF and move to next line then increment line count

        Line Input #3, g$
        pdfAddText g$
        pdfNextLine
        ln = ln + 1

        ' If we are on line 52 then print page number and start a new page

        If (ln = 52) Then

            pdfNextLine
            pn$ = Str$(pa%)
            pp$ = pa$ + pn$
            pdfAddText pp$
            pa% = pa% + 1

            pdfEndText
            pdfAddPage
            pdfLoadFont "F1", PDF_FONT_COURIER
            pdfSetLeading 11

            pdfBeginText
            pdfSetFontSize "F1", 11
            pdfSetPosition 16, 592
            ln = 0
        End If
    Loop
    Close #3

    ' All read in. Lets close the input file and print the final page number

    pn$ = Str$(pa%)
    pp$ = pa$ + pn$
    pdfNextLine
    pdfAddText pp$

    pdfEndText

    ' Create the PDF

    pdfGen ofn$

End If
If fe% = 0 Then Print "ERROR - File not found"

'Print "FINISHED!!"

'$Include:'pdfGen.bm'




Attached Files
.txt   header-wideorig.txt (Size: 718 bytes / Downloads: 9)
.txt   header.txt (Size: 545 bytes / Downloads: 9)
Oh look. A sig line :-)
Reply
#6
I have been plugging away at proper documentation and making small updates and bug fixes.

I'm not exactly sure what you are seeing, but I discovered that if you do not make the crop box the same as the media box, it won't work correctly. I made it to where media box will change the crop box to match in this last version. 

I included the latest libraries and the UNFINISHED docs that I have currently have. 

If you are adding huge blocks of texts to your document you might look at pdfAddTextBlock or pdfAddTextBlockEx.


Attached Files
.bi   pdfGen.bi (Size: 12.33 KB / Downloads: 13)
.bm   pdfGen.bm (Size: 108.42 KB / Downloads: 11)
.pdf   pdfGenDocs.pdf (Size: 61.5 KB / Downloads: 18)
Reply
#7
I know, I didn't explain my problem very well. Basically, if I was rem out line 17 and unrem line 20 (set to portrait) then rem line 56 and unrem line 57 (header.txt) then everything printed okay in portrait mode. If I then swap things around, rem out line 20 and unrem line 17 (landscape mode) and unrem line 56 and rem line 57 (header-wideorig.txt) then the PDF would be created in landscape mode but the text would carry on off page. 
I've just tried it with the latest .bi and .bm files and it now seems to work fine so I'm a happy bunny.

 It still prints ' Doh! I'm the library not the main program' though :-)

The docs seem pretty good so far. Looks like I need to do some reading.
Oh look. A sig line :-)
Reply
#8
That makes sense. You will have to reduce the font size or reduce the amount of text, to get it to fit in the page. It does not scale the text based on width, it will simply cut it off.

It can't determine the width of a font with any reliability, because that is dependent on what you are using to view the pdf. I can make some guesses, but I decided to leave that up to the end user.

I always put and END or SYSTEM before the '$INCLUDE:'pdfGen.bm' to keep 'Doh! I'm the library not the main program' message from popping up. I use that message to warn me not to compile the library (which happens a lot), but to compile the program using the library. Your more than welcome to delete it, if it is a inconvenience.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  The Van Halenizer 2.5 update madscijr 11 1,265 11-08-2025, 07:16 AM
Last Post: madscijr
  PDF Generation and Mystery Mania justsomeguy 41 6,460 03-11-2025, 11:29 PM
Last Post: justsomeguy
  Pointlessly Walk or Run forever! (update 0002) Cobalt 14 2,648 01-24-2025, 07:04 PM
Last Post: bplus
  Need for Speed High Stakes menu simulator (update 1) paulel 0 538 03-30-2024, 08:50 PM
Last Post: paulel

Forum Jump:


Users browsing this thread: 1 Guest(s)