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
bytebites
[
Today
at 07:31:06 pm]
Freepascal
by
Curt Carpenter
[
Today
at 07:28:15 pm]
WASM import error
by
lebao3105
[
Today
at 07:26:53 pm]
Lazarus 4.6 may erase you...
by
Martin_fr
[
Today
at 06:35:29 pm]
Best name for procedure
by
LemonParty
[
Today
at 05:23:02 pm]
Fixed an RV32ec compiler ...
by
MattBradford
[
Today
at 05:11:16 pm]
Many recent books on Laza...
by
Tomu
[
Today
at 05:02:44 pm]
Lazarus Bugfix Release 4....
by
geraldholdsworth
[
Today
at 04:35:14 pm]
International Pascal Cong...
by
zeljko
[
Today
at 04:08:53 pm]
equivalent to C/C++ "offs...
by
jamie
[
Today
at 02:43:16 pm]
val return code
by
ALLIGATOR
[
Today
at 01:40:21 pm]
Help needed on how to do ...
by
cdbc
[
Today
at 12:15:15 pm]
PascalRAL the fastest, mo...
by
Mobius1
[
Today
at 11:24:00 am]
TDateTimePicker - Make th...
by
AlexanderT
[
Today
at 09:57:05 am]
TCollection wiki entry
by
Thaddy
[
Today
at 05:44:53 am]
UI app to work with SQLit...
by
LeP
[
Today
at 12:50:04 am]
Elite Arcade
by
Guva
[July 11, 2026, 11:25:29 pm]
Printing on HP Smart Tank
by
JerryHudson
[July 11, 2026, 10:22:12 pm]
Why is my program freezin...
by
paweld
[July 11, 2026, 07:19:46 pm]
is there PDS reader/expor...
by
jamie
[July 11, 2026, 07:01:12 pm]
Fpcupdeluxe
by
cdbc
[July 11, 2026, 06:40:29 pm]
weird error message
by
jamie
[July 11, 2026, 06:37:01 pm]
Como compilar uma lib par...
by
marcelomaurinmartins@gmai
[July 11, 2026, 06:24:51 pm]
Desenvolvimento visual pa...
by
marcelomaurinmartins@gmai
[July 11, 2026, 06:19:16 pm]
OpenDocument('Filename') ...
by
J-G
[July 11, 2026, 06:13:03 pm]
« previous
next »
Print
Pages: [
1
]
2
3
4
Author
Topic: Pdf Viewer in Pascal (Read 2942 times)
Tomxe
Full Member
Posts: 132
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: 132
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: 132
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: 5557
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: 132
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: 132
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: 1732
Не съм сигурен, че те разбирам.
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: 132
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