I've written this for another project where I needed a print preview and some advances features for creating documents (and later print them or save them to pdf) like automatic page breaks, headers, footers etc.
Main features:
creating a document once and later output it to CanvasGadet, Window, Image, printer, pdf or svg
text and image cells with custom border, filling, text alignment, font etc.
horizontal, vertical and free lines
rectangles, curves, ellipses and ellipse segments
auto-invoked headers and footers, for the whole document or for a single page
auto page breaks
avoiding page breaks within connected element blocks
auto page numbers with free start value, excluding of pages from numbering, total number of pages etc.
possibility to display the document as single pages or as a list of pages (for print preview, see example code)
This has potential as a Report Generator.
Not sure why pdf would not work on Windows?
This version does not have a save to pdf option?
v.1.06 (2019-01-31)
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
skywalk wrote:Not sure why pdf would not work on Windows?
I use PB's PdfVectorOutput() which is not supported on Windows. On Linux and MacOS,
you can use VecVi::OutputPDF(). For PDF output on Windows, there is the fork with
PurePDF usage mentioned in my previous post.
Updated to v.1.10, mainly for improving the performance of the print preview with larger data.
Now only the elements that need to be displayed will be calculated before. In addition some
minor improvements, clarifications and bugfixes.
Thanks to PB 6.10, there is, beginning with v.1.13, direct pdf and svg output support for Windows, too. The PurePDF and pbPDF versions of VecVi won't get updated anymore.
; v.1.11 (2022-10-11)
; - fixed bug with pagebreak and x position reset
; v.1.12 (2023-10-10)
; - fixed bug causing crash when section is empty
; v.1.13 (2024-04-02)
; - added DuplicateSection(), DuplicateBlock()
; - added OutputPDF()/OutputSVG() support for all OS
; - changed OutputSVG() to require a page for output
; - changed BeginSection() and BeginBlock() to return a handle
; of the created section or block
; - fixed bugs with OutputPDF() and OutputSVG()
; - fixed another bug causing crash if section is empty
; - removed CanvasImage output
The pattern for your OpenFileRequesters are wrong. It should look like "PDF|*.pdf"
And If I cancel the PDF output requester it results in an IMA.
You should check the return values and also check if the output file was created before using RunProgram().
Yes, the example linked is also my quick&dirty test code so it could use a rework.
Regarding the return values I'm not sure in which cases StartVectorDrawing() returns zero and if it is reliable enough to assume that the file really exists. But I could at least pass trough its return value to have kind of an indication.
// EDIT: now done, also updated and extended the example
; v.1.14 (2024-04-04)
; - changed the output functions to have a return value
; indicating output success
; - fixed bugs with DuplicateBlock() and DuplicateSection()
- added ReplaceHeader(), ReplaceFooter(), AppendHeader(), AppendFooter()
- added variable support with GetVariable(), SetVariable(), RemoveVariable()
- added named position support with GetNamedPos(), SetNamedPos(), UseNamedPos()
- added LoadFile()/SaveFile()
- added pzName parameter to ImageCell()
- added GetImageReferencePath()/SetImageReferencePath()
- changed internal image handling to load the same image only once
I also finally had time to write a little documentation.
Thanks, this looks like a cool lib.
I love the canvasgadget.
Side note: the git PB files have config info at the bottom of the files AND separate config files. Did you set gitignore on the config files?
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
skywalk wrote: Fri Mar 28, 2025 9:53 pm
Side note: the git PB files have config info at the bottom of the files AND separate config files. Did you set gitignore on the config files?
I configured my IDE to not write any config to files or append it to the code. Is that what you mean?