Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
Packages and Libraries
»
Pdf Viewer in Pascal
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
I have made some progress...
by
zeljko
[
Today
at 08:23:17 pm]
Gtk3 widgetset - call for...
by
zeljko
[
Today
at 08:21:54 pm]
an error occurred while c...
by
Seenkao
[
Today
at 07:29:14 pm]
Indy10 hangs the app if u...
by
LeP
[
Today
at 07:28:12 pm]
FPC Unleashed (async/awai...
by
Thaddy
[
Today
at 05:43:19 pm]
RichMemo and GTK3
by
dsiders
[
Today
at 05:15:45 pm]
Desktop Shortcut
by
J-G
[
Today
at 04:49:33 pm]
ProDAW
by
jamie
[
Today
at 04:14:20 pm]
Which quantized model wor...
by
LeP
[
Today
at 04:12:28 pm]
Can not load postgres cli...
by
marcov
[
Today
at 02:34:12 pm]
[ANN] fpGUI Toolkit v2.1....
by
cdbc
[
Today
at 01:41:07 pm]
Ask AI to make fast HEX t...
by
paweld
[
Today
at 01:23:08 pm]
Isn’t this funny?
by
backprop
[
Today
at 12:25:46 pm]
Windows Installer with FP...
by
Martin_fr
[
Today
at 07:42:28 am]
GTK3 is now the default w...
by
dbannon
[
Today
at 03:25:30 am]
Parsing error?
by
jlinux
[
Today
at 02:15:42 am]
Putting a new file on a w...
by
J-G
[July 18, 2026, 11:10:43 pm]
[SOLVED]Problem with Mari...
by
Tomu
[July 18, 2026, 10:49:15 pm]
debugger error
by
Martin_fr
[July 18, 2026, 10:38:42 pm]
TCHATGPT — An Artificial ...
by
schuler
[July 18, 2026, 10:00:48 pm]
Slow app start on M5 MacB...
by
Thaddy
[July 18, 2026, 08:16:52 pm]
Peculiarities in the EXE ...
by
Thaddy
[July 18, 2026, 07:49:45 pm]
Windows 2026_7 update and...
by
Martin_fr
[July 18, 2026, 06:23:32 pm]
KOL4 Beta available.
by
Thaddy
[July 18, 2026, 06:23:08 pm]
This week in OPM!
by
wp
[July 18, 2026, 01:59:33 pm]
« previous
next »
Print
Pages: [
1
]
2
3
4
Author
Topic: Pdf Viewer in Pascal (Read 3039 times)
Tomxe
Full Member
Posts: 134
Pdf Viewer in Pascal
«
on:
June 09, 2026, 05:00:32 pm »
https://github.com/Xelitan/PDF-Viewer-exporter-in-pure-Free-Pascal-Lazarus-Delphi
Display PDFs:
Code: Pascal
[Select]
[+]
[-]
type
TForm1
=
class
(
TForm
)
...
public
PDF
:
TXelPDF
;
end
;
...
procedure
TForm1
.
FormCreate
(
Sender
:
TObject
)
;
begin
PDF
:
=
TXelPDF
.
Create
(
Form1
)
;
Pdf
.
Parent
:
=
Form1
;
Pdf
.
Align
:
=
alClient
;
Pdf
.
AutoFit
:
=
afWidth
;
//fit to width of the component
Pdf
.
LoadFromFile
(
'test.pdf'
)
;
end
;
procedure
TForm1
.
FormClose
(
Sender
:
TObject
;
var
CloseAction
:
TCloseAction
)
;
begin
Pdf
.
Free
;
end
;
Some editing is possible:
Code: Pascal
[Select]
[+]
[-]
Doc
.
DrawRect
(
0
,
50
,
600
,
200
,
80
,
clRed
)
;
//PageNum, Left, Top, Width, Height, Color
Doc
.
AddJpegImage
(
PageIndex
,
JpegBytes
,
Left
,
Top
,
Width
,
Height
)
;
FontRes
:
=
Doc
.
AddFont
(
FontName
,
FontSize
)
;
Doc
.
AddText
(
PageIndex
,
'Test Here'
,
Left
,
Top
,
FontRes
)
;
Also removing pages, adding new pages and exporting elements:
Code: Pascal
[Select]
[+]
[-]
Doc
.
ExportImage
(
PageNumber
,
ImageNumber
,
'out.png'
)
;
Doc
.
ExportJpeg
(
PageNumber
,
JpegNumber
,
'out.jpg'
)
;
PDF
.
Document
.
ExportFont
(
5
,
'out.otf'
)
;
//5 is the number of the font
Uses GDI+ so currently works only on Windows. Linux support will be added in the future.
Logged
kirchfritz
Jr. Member
Posts: 76
WIN11 LAZ 4.2 FPC 3.2.2
Re: Pdf Viewer in Pascal
«
Reply #1 on:
June 11, 2026, 11:40:26 am »
Hello tomxe,
trying to compile your PDF Viewer with Lazarus 4.2 FPC 3.2.2 gives the following error message:
(see attachement)
«
Last Edit: June 11, 2026, 11:42:27 am by kirchfritz
»
Logged
Tomxe
Full Member
Posts: 134
Re: Pdf Viewer in Pascal
«
Reply #2 on:
June 11, 2026, 12:05:23 pm »
Sorry, it would work but it's {$mode delphi} now. I fixed the code, please download the update.
Logged
zamtmn
Hero Member
Posts: 689
Re: Pdf Viewer in Pascal
«
Reply #3 on:
June 11, 2026, 12:10:28 pm »
Please provide a simple application so that we can view the selected pdf and evaluate the library's capabilities?
Logged
kirchfritz
Jr. Member
Posts: 76
WIN11 LAZ 4.2 FPC 3.2.2
Re: Pdf Viewer in Pascal
«
Reply #4 on:
June 11, 2026, 02:48:12 pm »
Hi tomxe:
using {mode objfpc} instead of {$mode delphi} lets me successfully compile all your modules.
I already found, how to scroll programatically from page to next/prev page, how to set the zoom level and how to show current pagenumber / total pagenumber.
But: I cant find a way how to rotate pdf-pages clockwise or anti-clockwise.
Does it make sense to wait for this feature?
«
Last Edit: June 11, 2026, 02:55:21 pm by kirchfritz
»
Logged
Tomxe
Full Member
Posts: 134
Re: Pdf Viewer in Pascal
«
Reply #5 on:
June 11, 2026, 03:52:37 pm »
I added a simple demo - DEMO_PDF.lpr that shows some of the options.
There are no rotations yet but will be added soon.
Logged
hedgehog
Full Member
Posts: 130
Re: Pdf Viewer in Pascal
«
Reply #6 on:
June 14, 2026, 07:57:23 am »
Hi Tomxe.
It looks cool!
I opened the test file
https://github.com/py-pdf/sample-files/blob/main/011-google-doc-document/google-doc-document.pdf
and here's what I noticed:
1. The logo (worm) is drawn with a black background, without transparency.
2. The flags of the countries are missing in the table.
«
Last Edit: June 14, 2026, 09:57:22 am by hedgehog
»
Logged
Dzandaa
Hero Member
Posts: 557
From C# to Lazarus
Re: Pdf Viewer in Pascal
«
Reply #7 on:
June 14, 2026, 11:44:26 am »
Hi,
@Tomxe:
Great Program/Library,
I'm currently looking for a program that would allow me to view a directory with many PDF files
and see their contents simply by clicking on them.
Here are two attached images of a document written in LibreOffice and exported as a PDF:
one from "Sumatra PDF" and the other from "Xelitan PDF"—they are quite similar.
Thank you again.
B->
Logged
Regards,
Dzandaa
eldonfsr
Hero Member
Posts: 598
Re: Pdf Viewer in Pascal
«
Reply #8 on:
June 16, 2026, 03:44:27 pm »
Looks great is print avalible to..
Logged
Handoko
Hero Member
Posts: 5558
My goal: build my own game engine using Lazarus
Re: Pdf Viewer in Pascal
«
Reply #9 on:
June 16, 2026, 03:55:42 pm »
Nice.
Unfortunately it is licensed under GPL, closed source can't use it.
Logged
Tomxe
Full Member
Posts: 134
Re: Pdf Viewer in Pascal
«
Reply #10 on:
June 17, 2026, 09:13:20 am »
Quote from: Handoko on June 16, 2026, 03:55:42 pm
Unfortunately it is licensed under GPL, closed source can't use it.
Commercial license is available and dirt cheap.
Logged
Tomxe
Full Member
Posts: 134
Re: Pdf Viewer in Pascal
«
Reply #11 on:
June 17, 2026, 09:59:03 am »
Fixed:
1) transparency around the Snake
2) flags now visible
3) resampling instead of resizing of images
4) rotations
Logged
CM630
Hero Member
Posts: 1743
Не съм сигурен, че те разбирам.
Re: Pdf Viewer in Pascal
«
Reply #12 on:
June 17, 2026, 11:32:05 am »
I tried a few documents, usually there are issues with some characters. But in the attached file I see only quadrangles.
Also, it it possible to search?
Logged
Лазар 4,8 32 bit (sometimes 64 bit); FPC3,2,2
Dzandaa
Hero Member
Posts: 557
From C# to Lazarus
Re: Pdf Viewer in Pascal
«
Reply #13 on:
June 17, 2026, 03:27:20 pm »
Hi,
@Tomxe:
Using Windows 10 64bits with Lazarus 4.8 fpc 3.2.2
The library works fine for some files, but sometimes, I have memory leaks
PdfObjects.pas at Line 105:
Create
PdfCFF.pas at line 434:
Result := Result + w;
Anyway, great job.
B->
Logged
Regards,
Dzandaa
Tomxe
Full Member
Posts: 134
Re: Pdf Viewer in Pascal
«
Reply #14 on:
June 17, 2026, 07:18:20 pm »
Thanks @Dzandaa - fixed.
@CM630 - a bit complicated but should be fixed today/tomorrow.
Searching:
TXelPDf.Search()
Logged
Print
Pages: [
1
]
2
3
4
« previous
next »
Lazarus
»
Forum
»
Programming
»
Packages and Libraries
»
Pdf Viewer in Pascal
TinyPortal
© 2005-2018