GithubHelp home page GithubHelp logo

alanphys / form2pdf Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 1.0 59 MB

Renders a pascal form to a PDF document. Written in Lazarus and Free Pascal

License: Apache License 2.0

Pascal 100.00%
pdf-generation forms lazarus free-pascal

form2pdf's Introduction

Form2PDF (c) AC Chamberlain Copyright 2020-2022

1) Introduction
This unit renders (very crudely) the text and image components of a form to a PDF using the fcl-pdf package. The object is not to provide a pixel by pixel representation of the form, but to record the text and image information. Multiline controls such as TStringGrid and TMemo are printed out in their entirety. The unit is modularised so new components can be added easily. Written for Free Pascal and Lazarus.

2) Licence
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

3)Supported components are:
TForm
TLabel
TStaticText
TEdit
TSpinEdit
TFloatSpinEdit
TSpinEditEx
TFloatSpinEditEx
TDirectoryEdit
TFileNameEdit
TComboBox
TListBox
TStringGrid
TValueListEditor
TMemo (does not support word wrapping under linux)
TCheckBox
TRadioButton
TImage
TChart
TShape (rectangle, rounded rect, ellipse)
TPageControl
TTabSheet
TGroupBox
TPanel
TRadioGroup
TCheckGroup
TScrollbox
TDateTime

4) Usage
To use copy form2pdf.pas into your source directory and include Form2PDF in your uses clause. You will need to add the path to the fcl-pdf source so the standard font metrics file can be included. Any visual control can be passed as a parent eg. TTabSheet or TForm.

FormToPDF 
Initialise FDoc and check if fonts are available. Returns 0 if everything OK, error code otherwise.

FormToPDF(AControl: TControl)
Parse controls and append pages to Fdoc. Returns number of objects in FDoc, error code otherwise.

FormToPDF(FileName:string)
Save FDoc to PDF and reset FDoc. Returns number of objects in FDoc, error code otherwise.

FormToPDF(AControl:TControl; FileName:string) 
Parse controls and save and close Fdoc. Returns number of objects in FDoc, error code otherwise.

5) History
26/6/2020  Initial commit.
3/7/2020   Fix bottom margin pagination.
5/7/2020   (TvS):moved initialization of FormToPDF to initalization part of unit
6/7/2020   changed FormToPDF to function to return error code
           added control and filename checks
8/7/2020   add functionality to append pages to document, FDoc now global}
13/7/2020  load and use system fonts
15/7/2020  add text alignment for labels
17/7/2020  add text alignment for spin edits
           add Panel caption
5/8/2020   add hide string grid columns
6/8/2020   fix string grid fixed cols bug
           add consistent margin schema
           17/12/2020 use rounded rect for smoother appearance
           fix TStringGrid no columns bug
18/12/2020 fix TStringGrid extend beyond end of control
14/6/2021  add TScrollbox
           fix groupbox (inc radiogroup and checkgroup) item spacing start
           fix add metadata
17/6/2021  fix off by one on panel and groupbox border
           add 2 pixel offset to left margin for panel and groupbox borders
22/6/2021  add TDateTime
           add drawing routines and refactor
           tweak arrows for spin and combo boxes
           add conditional defines for controls
28/11/2022 derive TForm2PDFDoc class and add definable margins in FDOC
           print TabSheet caption in footer

6) To Do
Implement word wrapping on TMemo (seems to be OK for Windows)

form2pdf's People

Contributors

alanphys avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

khongten001

form2pdf's Issues

PoMetaDataEntry

Just downloaded this a couple of days ago. Obviously a lot of hours of hard work into this project, thank you sir.

Win 10 home, Lazarus 2.08R62944 : Produces a compile error PoMetaDataEntry not found. And sure enough, it is not in the set (or Type, I forget how it's defined at the moment, I'm old and my memory is causing me problems :-) definition.

Managed to work around all that. However, some of the form objects are transposed in the PDF, ie: some labels etc. from the top end up on the bottom. Not only that, the lines are off for the data (text in this instance) inside the controls. It draws the TEdit boxes correctly and in the right spots, but the corresponding data is printed half below the boxes.

You've put so much time and effort into this I hope you have a solution for me. Hopefully just a case of defining PoMetaDataEntry and adding it to the type or set.

Thanks,
Steve, [email protected]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.