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
Rounding issues (only wit...
by
Hartmut
[
Today
at 07:41:02 pm]
Is an uninitialized dynam...
by
bstewart
[
Today
at 07:31:01 pm]
Changing the same record ...
by
Tomu
[
Today
at 07:13:22 pm]
Amigo programming languag...
by
paxscript
[
Today
at 07:09:06 pm]
Ellipses Function?
by
munair
[
Today
at 06:38:14 pm]
How to get file type from...
by
Nimbus
[
Today
at 06:02:52 pm]
Isn’t this funny?
by
munair
[
Today
at 06:01:40 pm]
Gtk3 widgetset - call for...
by
PeterBB
[
Today
at 05:46:04 pm]
Fast multi threaded file ...
by
Tomu
[
Today
at 04:16:16 pm]
FPC Unleashed (async/awai...
by
srvaldez
[
Today
at 03:35:52 pm]
Using callback
by
LemonParty
[
Today
at 02:15:03 pm]
TCHATGPT — An Artificial ...
by
schuler
[
Today
at 01:44:11 pm]
Lazarus for Windows on aa...
by
szlbz
[
Today
at 10:27:29 am]
Playing with GTK-server
by
Roland57
[
Today
at 10:11:06 am]
[New Component] ExtTabCtr...
by
wp
[
Today
at 10:04:27 am]
Some Lazarus documentatio...
by
dsiders
[
Today
at 09:40:28 am]
Slow app start on M5 MacB...
by
Thaddy
[
Today
at 06:34:10 am]
Review from FreePascal
by
n7800
[
Today
at 05:27:49 am]
Network drop and firewall
by
kupferstecher
[July 21, 2026, 07:11:07 pm]
How to check my own certi...
by
LeP
[July 21, 2026, 05:04:49 pm]
How can I get names of CO...
by
Thaddy
[July 21, 2026, 04:55:08 pm]
Accessing VRAM memory wit...
by
Thaddy
[July 21, 2026, 01:31:19 pm]
Fixed an RV32ec compiler ...
by
ccrause
[July 21, 2026, 12:04:05 pm]
[SOLVED} Copying existing...
by
Davo
[July 21, 2026, 11:59:45 am]
TDWEdit
by
Ed78z
[July 21, 2026, 09:53:10 am]
« previous
next »
Print
Pages: [
1
]
2
3
4
Author
Topic: Pdf Viewer in Pascal (Read 3055 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: 133
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: 5559
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: 1746
Не съм сигурен, че те разбирам.
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