Coder Social home page Coder Social logo

synpdf's Introduction

SynPDF

Synopse PDF engine is a fully featured Open Source PDF document creation library for Delphi, embedded in one unit.

It's used e.g. in our mORMot framework, for creating PDF files from generated reports. But you can use it stand-alone, without our main ORM/SOA framework.

If you download the whole mORMot source code, you do not need this separate package: ensure you get rid of any existing separated SynPDF installation, and use the PDF units as available in the main mORMot trunk. This SynPDF distribution/GitHub account targets only people needing PDF writing, without other mORMot features, under Delphi.

If you plan using any part of the framework (e.g. SynLog, SynDB or the ORM/SOA), don't use this repository, but use the main mORMot framework. Having the two repositories on the same environement may be a source of unexpected version conflict. Just use and trust the main mORMot repository, which will be updated much more often.

For long-term support, and FPC compatibility, check the mORMot 2 mormot.ui.pdf.pas unit

Features

  • Pure Delphi code, with no external .dll, and adding very small code size to your executable;
  • Targets Delphi 6 and up, including Unicode versions of Delphi, for Win32 and Win64 platforms, with full source code provided;
  • Includes most vectorial drawing commands, including text, lines or curves;
  • Renders bitmaps, and metafiles (even most .emf files with clipping and regioning);
  • Introduce metadata, bookmarks and outline information;
  • Produce very small .pdf files;
  • Optionally encrypt and secure the .pdf content using 40 bit or 128 bit keys;
  • Fast file generation with low memory overhead (tested with several thousands of pages);
  • Access a true VCL TCanvas instance to create the PDF content;
  • Optionally embed True Type fonts subsets;
  • Unicode ready, even with pre-Unicode versions of Delphi, including advanced Uniscribe Glyph shading and Font fallback;
  • Can publish PDF/A-1 archive files;
  • Used in a lot of applications, with regular enhancements, mainly from active end-users;
  • Licensed under a MPL/GPL/LGPL tri-license.

Sample Code

In fact, you have at least three ways of generating pdfs using the library:

  • Directly call of a TPdfCanvas as published by a TPdfDocument instance - this is the most direct but also more difficult way of rendering;
  • Use regular VCL TCanvas methods thanks to TMetaFile support - see TPdfDocumentGDI.VCLCanvas property and the TPdfCanvas.RenderMetaFile method - this is very easy if you want to use "regular" TCanvas methods to draw the page content, especially if you have some existing printing code;
  • Use TGDIPages of the supplied mORMotReport.pas unit (extracted from our mORMot ORM/SOA framework) to easily create the content from code, with some report-oriented methods (including complex rtf with TGDIPages.AppendRichEdit) - for basic reporting features, it is pretty much the solution.

The 2nd and 3rd ways are preferred, for most applications.

Relevant Forks

Some users did fork the project, and add some nice features, useful for some particular needs, but which were not merged yet to ease maintenance and ensure backward compatibility.

Documentation

For detailed documentation of the unit, see the corresponding pages in the "Software Architecture Document" of mORMot official documentation, or directly in the interface part of the unit, as methods comments.

Including the report generation pages within the "SynFile Main Demo" description.

Dedicated Blog and Forum

A blog is available at http://blog.synopse.info, and will notify any evolution of this component.

A forum is dedicated to this component, and is available on https://synopse.info

This is the main entry point for support: first search for an existing answer, then ask your question in a new thread.

synpdf's People

Contributors

jonjbar avatar joshkel avatar maykon-t avatar shenmin avatar synopse avatar viktorakselrod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

synpdf's Issues

Access Violation on Delphi 10.4.1 with byte record field alignment

Generating a PDF via VLCCanvas and TPdfDocumentGDI causes access violation when compiled with Delphi 10.4.1 with record field alignment compiler option set to "byte" or "off". When this option is set to either of "word", "double word" or "quad word", the PDF gets created without errors. The same exact code works fine when compiled with Delphi 10.4 (patch 3), regardless of the field alignment flag.
It smells like an off-by-one error somewhere (that's why introducing gaps between record fields circumvents it), but I wasn't able to pinpoint it. The exception appears in TPdfWrite.Save method, where the L variable seems to be assigned a meaningless value (zero or negative). But since there's a lot of pointer math and memory copying, the actual cause might as well be completely elsewhere.
Minimal example I managed to put together, which reproduces the error:

procedure TForm1.testButtonClick(Sender: TObject);
var
  outfile: TFileStream;
  pdfdoc: TPdfDocumentGDI;
begin

  if FileExists('test.pdf') then
    DeleteFile('test.pdf');
  outfile := TFileStream.Create('test.pdf', fmCreate);
  try
    pdfdoc := TPdfDocumentGDI.Create();
    try
      pdfdoc.GeneratePDF15File := true;
      pdfdoc.SaveToStreamDirectBegin(outfile);
      pdfdoc.AddPage();
      pdfdoc.VCLCanvas.TextOut(20, 20, 'ABC');
      pdfdoc.SaveToStreamDirectPageFlush();
      pdfdoc.SaveToStreamDirectEnd();
    finally
      pdfdoc.Free();
    end;
  finally
    outfile.Free();
  end;
end;

When compiled on 10.4.1 with byte aligned records it crashes, with word (or wider) alignment it works fine. Compiled on D10.4 works well in all cases. All other compiler options except the field alignment was set to IDE default.
Currently I have access to active installations of both D10.4 and D10.4.1, so if I could assist in some testing, I'd be happy to do so (those are corporate machines, so I can't provide any kind of remote access, but I can compile and run test projects and let you know what happens).
The zipped project in the comments below.

Is PDF/A-3 on your roadmap

This is becoming important in Europe for commercial systems exchanging PDF files of invoices and other "unalterable archive" formats.

Text with spaces before

When printing text containing spaces before it, the alignment is screwed.
We use a fixed width font to maintain column alignment, but when there is space before the text the spaces are not the same width than the font.

What it should have looked like
image

What it looks in the PDF
image

Sample.emf.zip

default page size

Hello!

Recently I've updated application with latest SynPDF code. Inside I am generating PDF report using TGDIPage. After update default size of page has changed from A4 to US Letter.
I tried to find some method to change it but without success.
Could you advise me something?

SynPDF.pas is not cross-platform

I was under the impression that SynPDF is cross-platform, seeing as it supports FPC. Trying to compile it on Linux or FreeBSD and I get an error in the SynPDF.pas unit.

I commented out the two units in the uses clause, which are Windows specific....

Windows, WinSpool,

...but due to the other bug I report (missing unit), I can't see if there are any other issues before it is cross-platform.

SynPDF does not compile

Under Delphi XE7 (and as I see it in every version), the code I downloaded on 27 May 2021 does not compile:

SynPDF.pas lines 5810-5812:

  with fMissingBookmarks do
  for i := Count-1 downto 0 do
    if Get(i)=aBookmarkName then begin

throws an error because the symbol Get is not defined. Looking at SynCommons.pas, TRawUTF8List has a function Get(Index: PtrInt): RawUTF8; {$ifdef HASINLINE}inline;{$endif} which is defined as protected .

I hope you can reproduce this. Possible solution: Make it public. I'll leave this decision to those who have more insight into structure and other applications of the library.

Missing unit SynFPCTypInfo.pas

I've just checked out this repository, and tried to compile it with FPC (though this issue would apply to Delphi too), using the very simple DirectCall example. The compiler complained about a missing unit. I double checked and it doesn't exist in the repository.

Delphi 7 compile error SetFont

I just downloaded the source code and when I compile I get that error
[Error] QRPDFSynFilt.pas(1082): There is no overloaded version of 'SetFont' that can be called with these arguments.

Delphi 10.4 Sedny Support

Hello Bro
Targets Delphi 5 up to Delphi 10.3 Rio (and latest version of FPC), for Win32 and Win64 platforms, with full source code provided;

Please Add 10.4.2 support
Tnx

Build error: Undeclared function 'AtomicIncrement'

error

[DCC Error] SynCommons.pas(17276): E2003 Undeclared identifier: 'AtomicIncrement'
[DCC Error] SynCommons.pas(17281): E2003 Undeclared identifier: 'AtomicDecrement'
[DCC Fatal Error] SynPDFDXE2.dpk(36): F2063 Could not compile used unit 'SynCommons.pas'

How to reproduce:
Try build with Delphi XE2 Update 4 HostFix 1, Build Configuration: Release or Debug, Target Plataforms: Win64 on Windows 7 64 bits Professional.

How to solve:
Replace: Line 17276
result := AtomicIncrement(I);
By
Result := Windows.InterlockedIncrement(I);

Replace: Line 17281
result := AtomicDecrement(I);
By
Result := Windows.InterlockedDecrement(I);

Double/Wrong xref section

Hi,

I'm trying to debug a problem that occurs intermittently. I'm using the TPdfDocumentGDI class.
Often PDFs are not opened by some PDF readers, in particular Acrobat and the Firefox built-in reader. For Acrobat, the error returned is 109 (damaged file).
Other PDF readers seems to display the file without problems, like FoxIt and Google Chrome built-in reader.

After a comparative study between the generated files, I realized these problematic files have two sections startxref/xref/trailer at the end of the file, while in normal files there is only one section of each. I also noticed that the first xref section lists objects at wrong offsets and the second xref section seems to have consistent references.

Unfortunately, just my users got this problem until now and I wasn't successful trying to recreate it.

An example file containing the problem is attached.
Example.pdf
Note the first xref section:

xref
0 12
0000000000 65535 f
0000000009 00000 n
0000000093 00000 n
0000000322 00000 n
0000000373 00000 n
0000000544 00000 n
0000005284 00000 n
0000005931 00000 n
0000006109 00000 n
0000006784 00000 n
0000006956 00000 n
0000007612 00000 n

From the seventh object, the offsets indicated are inconsistent with real objects in file. It is also important to note that the last xref section looks consistent.

Any idea what might be going on? Where can I start to debug this?

Privileged instruction Error

Hi,
Some computers raises "Privileged instruction" exception.
It occurs in versions with updates.
gdi32.dll file is updated.
gdi32.dll Version :10.0.14393.0
gdi32.dll file size is 201K.

madExcept log:

date/time : 2016-09-02, 18:49:15, 600ms
computer name : ZAKIB
user name : ZakiT
registered owner : Hp
operating system : Windows 8 x64 build 9200
system language : Turkish
system up time : 2 days 9 hours
program up time : 1 minute 3 seconds
processors : 4x Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz
physical memory : 9541/16265 MB (free/total)
free disk space : (C:) 270,16 GB
display mode : 1920x1080, 32 bit
process id : $2858
allocated memory : 202,01 MB
command line : "C:\Program Files (x86)\xxxxx\REPENGINE.EXE"
executable : REPENGINE.EXE
exec. date/time : 2016-09-01 23:06
version : 1.0.0.2
compiled with : Delphi XE3
madExcept version : 4.0.7
callstack crc : $75df162a, $e8b949c2, $7bcf8464
exception number : 1
exception class : EPrivilege
exception message : Privileged instruction.

main thread ($3514):
75df162a +0000 GDI32.dll
0112ecf4 +009c REPENGINE.EXE SynPdf TPdfWrite.AddUnicodeHexTextUniScribe
0112f560 +0060 REPENGINE.EXE SynPdf TPdfWrite.AddUnicodeHexText
0113718b +002b REPENGINE.EXE SynPdf TPdfCanvas.ShowText
01135a04 +0058 REPENGINE.EXE SynPdf TPdfCanvas.TextOutW
0188b2a1 +0115 REPENGINE.EXE ReportDlg 1557 +16 TReportForm.TStartBtnClick
006261cb +006f REPENGINE.EXE Vcl.Controls TControl.Click
005d10e2 +001e REPENGINE.EXE Vcl.StdCtrls TCustomButton.Click
007987c1 +00a5 REPENGINE.EXE Vcl.Buttons TBitBtn.Click
005d1c04 +0010 REPENGINE.EXE Vcl.StdCtrls TCustomButton.CNCommand
00625c75 +02bd REPENGINE.EXE Vcl.Controls TControl.WndProc
0062a709 +05c5 REPENGINE.EXE Vcl.Controls TWinControl.WndProc
005d0d8c +006c REPENGINE.EXE Vcl.StdCtrls TButtonControl.WndProc
006258b0 +0024 REPENGINE.EXE Vcl.Controls TControl.Perform
0062a86f +0023 REPENGINE.EXE Vcl.Controls DoControlMsg
0062b2f7 +000b REPENGINE.EXE Vcl.Controls TWinControl.WMCommand
00625c75 +02bd REPENGINE.EXE Vcl.Controls TControl.WndProc
0062a709 +05c5 REPENGINE.EXE Vcl.Controls TWinControl.WndProc
00656c0e +007a REPENGINE.EXE Vcl.Themes TStyleHook.WndProc
00629d4c +002c REPENGINE.EXE Vcl.Controls TWinControl.MainWndProc
004dc3cc +0014 REPENGINE.EXE System.Classes StdWndProc
77b0fef4 +0034 ntdll.dll KiUserCallbackDispatcher
77340bcb +013b USER32.dll SendMessageW
005db7d3 +0043 REPENGINE.EXE Vcl.StdCtrls TButtonStyleHook.DoClick
005dbb4b +002b REPENGINE.EXE Vcl.StdCtrls TButtonStyleHook.WMLButtonUp
00656c0e +007a REPENGINE.EXE Vcl.Themes TStyleHook.WndProc
00656dfc +0000 REPENGINE.EXE Vcl.Themes TMouseTrackControlStyleHook.WndProc
005db874 +005c REPENGINE.EXE Vcl.StdCtrls TButtonStyleHook.WndProc
00656594 +0064 REPENGINE.EXE Vcl.Themes TStyleHook.HandleMessage
006ba966 +0116 REPENGINE.EXE Vcl.Styles TStyleEngine.HandleMessage
006539ac +0054 REPENGINE.EXE Vcl.Themes TStyleManager.HandleMessage
00628a93 +000f REPENGINE.EXE Vcl.Controls TWinControl.DoHandleStyleMessage
0062a19f +005b REPENGINE.EXE Vcl.Controls TWinControl.WndProc
005d0d8c +006c REPENGINE.EXE Vcl.StdCtrls TButtonControl.WndProc
00629d4c +002c REPENGINE.EXE Vcl.Controls TWinControl.MainWndProc
004dc3cc +0014 REPENGINE.EXE System.Classes StdWndProc
005f585b +00f3 REPENGINE.EXE Vcl.Forms TApplication.ProcessMessage
005f589e +000a REPENGINE.EXE Vcl.Forms TApplication.HandleMessage
005f5bd9 +00c9 REPENGINE.EXE Vcl.Forms TApplication.Run
04598060 +0468 REPENGINE.EXE REPENGINE initialization
76b962c2 +0022 KERNEL32.DLL BaseThreadInitThunk

thread $302c:
76452af4 +84 KERNELBASE.dll SleepEx
76452a5a +0a KERNELBASE.dll Sleep
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $3cd4:
76452af4 +84 KERNELBASE.dll SleepEx
76452a5a +0a KERNELBASE.dll Sleep
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $2634:
76452af4 +84 KERNELBASE.dll SleepEx
76452a5a +0a KERNELBASE.dll Sleep
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $31c0:
76452af4 +84 KERNELBASE.dll SleepEx
76452a5a +0a KERNELBASE.dll Sleep
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $254c:
76452af4 +84 KERNELBASE.dll SleepEx
76452a5a +0a KERNELBASE.dll Sleep
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $3b68:
76452af4 +84 KERNELBASE.dll SleepEx
76452a5a +0a KERNELBASE.dll Sleep
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $1c88:
76452af4 +84 KERNELBASE.dll SleepEx
76452a5a +0a KERNELBASE.dll Sleep
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $23c0:
76452af4 +84 KERNELBASE.dll SleepEx
76452a5a +0a KERNELBASE.dll Sleep
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $2b20:
7644ac83 +93 KERNELBASE.dll WaitForSingleObjectEx
7644abdd +0d KERNELBASE.dll WaitForSingleObject
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $3b8c:
7644ac83 +93 KERNELBASE.dll WaitForSingleObjectEx
7644abdd +0d KERNELBASE.dll WaitForSingleObject
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $1ecc:
7644ac83 +93 KERNELBASE.dll WaitForSingleObjectEx
7644abdd +0d KERNELBASE.dll WaitForSingleObject
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $3194:
7644ac83 +93 KERNELBASE.dll WaitForSingleObjectEx
7644abdd +0d KERNELBASE.dll WaitForSingleObject
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $3ee0:
7644ac83 +93 KERNELBASE.dll WaitForSingleObjectEx
7644abdd +0d KERNELBASE.dll WaitForSingleObject
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $3590:
7644ac83 +93 KERNELBASE.dll WaitForSingleObjectEx
7644abdd +0d KERNELBASE.dll WaitForSingleObject
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $3c94:
7644ac83 +93 KERNELBASE.dll WaitForSingleObjectEx
7644abdd +0d KERNELBASE.dll WaitForSingleObject
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $320c:
7644ac83 +93 KERNELBASE.dll WaitForSingleObjectEx
7644abdd +0d KERNELBASE.dll WaitForSingleObject
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $1d9c:
7644ac83 +93 KERNELBASE.dll WaitForSingleObjectEx
7644abdd +0d KERNELBASE.dll WaitForSingleObject
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $2c5c:
7644ac83 +93 KERNELBASE.dll WaitForSingleObjectEx
7644abdd +0d KERNELBASE.dll WaitForSingleObject
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $35d0:
7644ac83 +93 KERNELBASE.dll WaitForSingleObjectEx
7644abdd +0d KERNELBASE.dll WaitForSingleObject
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $3c98:
7644ac83 +93 KERNELBASE.dll WaitForSingleObjectEx
7644abdd +0d KERNELBASE.dll WaitForSingleObject
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $3c08:
7644ac83 +93 KERNELBASE.dll WaitForSingleObjectEx
7644abdd +0d KERNELBASE.dll WaitForSingleObject
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $16a8:
7644ac83 +93 KERNELBASE.dll WaitForSingleObjectEx
7644abdd +0d KERNELBASE.dll WaitForSingleObject
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $1c38:
7644ac83 +93 KERNELBASE.dll WaitForSingleObjectEx
7644abdd +0d KERNELBASE.dll WaitForSingleObject
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $1ea4:
7644ac83 +93 KERNELBASE.dll WaitForSingleObjectEx
7644abdd +0d KERNELBASE.dll WaitForSingleObject
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $2388:
76452af4 +84 KERNELBASE.dll SleepEx
76452a5a +0a KERNELBASE.dll Sleep
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $3888:
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $371c:
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $3998: priority:2
7735249d +4d USER32.dll GetMessageA
009b5385 +0d REPENGINE.EXE madExcept 16670 +6 CallThreadProcSafe
009b53ea +32 REPENGINE.EXE madExcept 16720 +9 ThreadExceptFrame
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

created by main thread ($3514) at:
70b830ab +00 winmm.dll

thread $3024:
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $3dd8:
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $3cf4:
76451a2a +ea KERNELBASE.dll WaitForMultipleObjectsEx
009b5385 +0d REPENGINE.EXE madExcept 16670 +6 CallThreadProcSafe
009b53ea +32 REPENGINE.EXE madExcept 16720 +9 ThreadExceptFrame
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

created by main thread ($3514) at:
7687d227 +00 combase.dll

thread $2364:
76451a2a +ea KERNELBASE.dll WaitForMultipleObjectsEx
77348ea3 +63 USER32.dll MsgWaitForMultipleObjects
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $b38:
76451a2a +ea KERNELBASE.dll WaitForMultipleObjectsEx
77348ea3 +63 USER32.dll MsgWaitForMultipleObjects
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $3d68:
76451a2a +ea KERNELBASE.dll WaitForMultipleObjectsEx
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $28ac:
76451a2a +ea KERNELBASE.dll WaitForMultipleObjectsEx
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $3f14: priority:2
76451a2a +ea KERNELBASE.dll WaitForMultipleObjectsEx
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $2b90:
7644ac83 +93 KERNELBASE.dll WaitForSingleObjectEx
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $29c4:
7644ac83 +93 KERNELBASE.dll WaitForSingleObjectEx
7644abdd +0d KERNELBASE.dll WaitForSingleObject
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $2500:
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $1e8c:
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $25d8:
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $2964:
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $2574:
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $2598:
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $25d4:
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $1e4:
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $3d3c:
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $2ac8:
76451a69 +129 KERNELBASE.dll WaitForMultipleObjectsEx
77348941 +171 USER32.dll MsgWaitForMultipleObjectsEx
7690eac9 +089 combase.dll CoWaitForMultipleHandles
009b5385 +00d REPENGINE.EXE madExcept 16670 +6 CallThreadProcSafe
009b53ea +032 REPENGINE.EXE madExcept 16720 +9 ThreadExceptFrame
76b962c2 +022 KERNEL32.DLL BaseThreadInitThunk

created by thread $371c at:
7616a62c +000 shcore.dll

thread $2494:
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $29a4:
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

thread $3728:
76b962c2 +22 KERNEL32.DLL BaseThreadInitThunk

cpu registers:
eax = 0019e346
ebx = 01102d28
ecx = 00000000
edx = 01102dc4
esi = 5574f164
edi = 0019e428
eip = 75df162a
esp = 0019e320
ebp = 0019e39c

stack dump:
0019e320 f9 ec 12 01 00 00 00 00 - 46 e3 19 00 44 e3 19 00 ........F...D...
0019e330 fc e3 19 00 40 b5 40 00 - 9c e3 19 00 00 00 00 00 ....@.@.........
0019e340 2c 0f 45 76 00 00 00 00 - 00 00 6f 27 00 00 00 00 ,.Ev......o'....
0019e350 00 00 00 00 14 e4 19 00 - e6 04 00 00 00 00 00 00 ................
0019e360 00 00 00 00 00 00 00 00 - 02 00 00 00 40 a0 8f 00 ............@...
0019e370 01 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................
0019e380 04 00 00 00 24 54 86 20 - 00 00 00 00 10 9f d7 24 ....$T. .......$
0019e390 10 ad 86 1e f4 fe 6f 27 - 01 00 00 00 c4 e3 19 00 ......o'........
0019e3a0 65 f5 12 01 20 8d 89 1e - 00 9c 21 16 00 ee df 16 e... .....!.....
0019e3b0 10 9f d7 24 03 00 00 00 - 04 00 00 00 24 54 86 20 ...$........$T.
0019e3c0 10 ad 86 1e dc e3 19 00 - 90 71 13 01 20 8d 89 1e .........q.. ...
0019e3d0 10 ad 86 00 24 54 86 20 - 20 8d 89 1e ec e3 19 00 ....$T. .......
0019e3e0 09 5a 13 01 24 54 86 20 - 20 8d 89 1e 48 e4 19 00 .Z..$T. ...H...
0019e3f0 ed e6 8f 01 cd 2c 4a 44 - 00 00 03 44 54 e4 19 00 .....,JD...DT...
0019e400 40 b5 40 00 48 e4 19 00 - 80 e4 19 00 18 e5 19 00 @[email protected]...........
0019e410 00 00 00 00 00 00 00 00 - 0c 02 00 00 1b 00 00 00 ................
0019e420 13 02 00 00 27 00 00 00 - 30 a7 b2 00 44 e4 19 00 ....'...0...D...
0019e430 00 00 00 00 6c e4 19 00 - 0c 02 00 00 02 00 00 00 ....l...........
0019e440 14 55 86 20 f0 22 8e 1e - 88 e4 19 00 32 05 90 01 .U. ."......2...
0019e450 00 00 00 00 9c e4 19 00 - 40 b5 40 00 88 e4 19 00 ........@.@.....

TGDIPages.AppendRichEdit get stack

TGDIPages.AppendRichEdit( get stack on
LastChar := SendMessage(RichEditHandle, EM_FORMATRANGE, 1, Integer(@range));
dose not move to next char. stay on 13704
loading testrtf.rtf
Using D10.2.3

Bullet not being correctly represented in PDF

Hi, Synopse!

I've just downloaded the version 1.18 of SynPDF. Thank you very much for keeping your project updated. However, it's not working when I try to export a document with a bullet point in it. Instead of printing the bullet point, it's printing a block/square. Something like this: "[] test".

Is there something i have to set up in the create of TPdfFontTrueType? Does it have to be Unicode or doesn't matter?

Please, see attachment.
testBullet.pdf
I'm using Delphi XE2 with Fortes Report.

protected PDFs shows garbage in document information (e.G. Adobe Reader)

When the PDF document uses encryption to ensure no modifications, the resulting PDF files contains some kind of garbage in the document properties; see Screenshot.

Example:

LPdf := TPdfDocumentGDI.Create(
  false, 0 , false, 
  TPDFEncryption.New(elRC4_40, '', 'secret', [epPrinting])
);
LPdf.Info.Author := 'User name';
LPdf.Info.Creator := 'Software name';
LPdf.Info.Subject = 'Auto generated document';

SynPDF document properties

Infinite loop in SynZip (Un)CompressStream

Those functions currently contain an infinite loop when the buffer is corrupted, they both have a repeat...until loop which looks like

    repeat
      code := Check(inflate(strm, Z_FINISH),[Z_OK,Z_STREAM_END,Z_BUF_ERROR],'UnCompressStream');
      FlushBuf;
    until code=Z_STREAM_END;

And Check() is thus set to accept Z_BUF_ERROR while the until test does not cover for it. The Check should probably have just [Z_OK,Z_STREAM_END]

Canvas graphics from TPrintPreview distorted

Hi,

a simple canvas graphics created with RoundRect and LineTo and written to PDF with SynPDF is distorted when created from a TPrintPreview.

Please find attached in SynPDFTester.zip a minimal program to reproduce the issue plus two sample PDF files to illustrate the issue: test_metafile.pdf is directly created from a canvas graphics in a metafile (correct), test_preview.pdf is created indirectly from a canvas graphics from a print preview.

I use the TPrintPreview component from here: DelphiArea which in turn uses SynPDF for creating PDF files from previews. TPrintPreview internally also uses metafiles to render and store the pages for preview. The preview on screen is right but the PDF created from the metafile is not.

Best regards,
Boris

Conform with the PDF/A-1a standard

Good afternoon!

We have long and successfully used your product - SynPDF to create PDF files from RTF.
PDF are created in PDF/A-1 format, with storing fonts inside the file
PdfDoc := TPdfDocumentGDI.Create(false, 0, true/APDFA1/);
PdfDoc.EmbeddedTTF := True;

Our users have noticed that the generated PDF files may not conform to the PDF/A-1a standard.
The https://www.pdf-online.com/osa/validate.aspx file uploaded to the site for verification displays the following message:
The key Type is required but missing.
The document does not conform to the requested standard.
The document doesn't provide appropriate logical structure information.
The document does not conform to the PDF/A-1a standard.

Is there any other parameter for SynPDF, changing which, I can achieve success when passing the PDF/A-1a compliance test?
What can I reply to my users?

With respect
Lisichkin Alexander.

I attach test pdf file:
TEST TEXT.pdf

Delphi 10.5 Olympus

Hi,
I'm trying the beta test version of Delphi 10.5 Olympus.
There is a problem with "SynCommons.pas".
The System.Classes TMempryStream has been modify :

{ TMemoryStream }
  TMemoryStream = class(TCustomMemoryStream)
  private
    FCapacity: NativeInt;
  protected
    procedure SetCapacity(NewCapacity: NativeInt); virtual;
    function Realloc(var NewCapacity: NativeInt): Pointer; virtual;
    property Capacity: NativeInt read FCapacity write SetCapacity;
  public
    destructor Destroy; override;
    procedure Clear;
    procedure LoadFromStream(Stream: TStream);
    procedure LoadFromFile(const FileName: string);
    procedure SetSize(const NewSize: Int64); override;
    procedure SetSize(NewSize: Longint); override;
    function Write(const Buffer; Count: Longint): Longint; override;
  end;

Realloc Function must be modify too (LongInt --> NativeInt) :

function THeapMemoryStream.Realloc(var NewCapacity: NativeInt): Pointer;

Best regards

SynPDF interface to the Delphi world

Hi, the interface to SynPDF is a bit weird. The canvas is not compatible with the Delphi/WinAPI canvas.

pdf := TPdfDocument.Create;
page := pdf.AddPage;
page.Canvas.Line(..) <--- <>TCanvas

Why not just work with a handle? It's a clean and simple solution.

var hdc: THandle;

pdf := TPdfDocument.Create;
hdc := pdf.AddPage;
canvas := TCanvas.Create;
canvas.handle := hdc;
canvas.Line(..)

In addition, you have the advantage that you are 100% assignment-compatible with the WinAPI.

Comparing signed and unsigned types - widened both operands in delphi Sidney

[dcc32 Error] SynCrypto.pas(6661): E2034 Too many actual parameters
[dcc32 Error] SynCrypto.pas(6668): E2034 Too many actual parameters
[dcc32 Error] SynCrypto.pas(14624): E2003 Undeclared identifier: 'Hash128Index'
[dcc32 Warning] SynCrypto.pas(14624): W1023 Comparing signed and unsigned types - widened both operands
[dcc32 Error] SynCrypto.pas(14630): E2003 Undeclared identifier: 'Hash128Index'
[dcc32 Warning] SynCrypto.pas(14630): W1023 Comparing signed and unsigned types - widened both operands
[dcc32 Fatal Error] SynPdf.pas(927): F2063 Could not compile used unit 'SynCrypto.pas'
Failed

SynLZ Compile Error

SynLZ.pas file line 374 give an error.

[DCC Error] SynLZ.pas(374): E1025 Unsupported language feature: 'ASM'
[DCC Error] SynLZ.pas(374): E2029 ';' expected but 'ASM' found

var off: TOffsets;
    cache: array[0..4095] of cardinal; // uses 32KB+16KB=48KB on stack
asm// rcx=src, edx=size, r8=dest

System Specification
Delphi 10.3.3
Target => Ubuntu Linux x64
Cpu Intel i7
OS: Windows 10 x64

When I try to compile for Linux x64 after including the units in SynPDF, I also encounter other errors. I think the mormot project is not suitable for developing with Delphi in Linux environment. Unless of course I'm making a mistake.

Actually, I included it in the project for printing and encryption only. I was going to use SynCrypto and mormorReport.

Access Violation

FMX

pdf.Canvas.TextOut(10,10,'Hello World'); <- Access Violation working only VCLCanvas

potential issue with xe7

I wrote on forum, but it's all quiet there for days, so i had to open an issue here
(this thread: https://synopse.info/forum/viewtopic.php?pid=24083#p24083)

Following code works on a delphi xe2
but it doesn't on my xe7
Win7 64bit both systems

moreover
in my case, a blank pdf appears only in project's folder, not in c:
but the rectangle appears live in TImage1
just that pdf is blank, and pdf in c:\ doesn't exist

I really don't know if it's a bug, or if i do something wrong (most probably the 2nd)

procedure TForm1.ButtonPrintClick(Sender: TObject);
var
  lPdf : TPdfDocumentGDI;
begin
  lPdf := TPdfDocumentGDI.Create();
  try
    lPdf.AddPage;
    lPdf.DefaultPaperSize := psA4;
    //Image1.Picture.LoadFromFile('c:\a.jpg');
    Image1.Canvas.Rectangle(10,10,30,30);

    lPdf.VCLCanvas.Draw(10,10,Image1.Picture.Graphic);
    lPdf.SaveToFile('1.pdf');
    lPdf.SaveToFile('c:\1.pdf');

  finally
    lPdf.Free;
  end;
end;

Warning for ESynException.CreateLastOSError

On Delphi XE 4 I get this warning

[dcc32 Warning] W1029 Duplicate constructor 'ESynException.CreateLastOSError' with identical parameters will be inacessible from C++

which I fixed by changing ESynException.CreateLastOSError from this

constructor CreateLastOSError(const Format: RawUTF8; const Args: array of const);

to this

// Note that the Unused parameter is just there to shut up warnings that this
// constructor is identical in paramaters to the above CreateUTF8 and can thus not be
// used in C++.
constructor CreateLastOSError(const Format: RawUTF8; const Args: array of const; Unused: Integer = 0);

Adding the Unused parameter with a default value keeps the code intact and shuts up the warning.

missing crc32c64.obj

Could you please add the missing crc32c64.obj for 64 bit support to the Project? In the moment 64 bit version did not compile out of the box.

Thank you very much,
Henner Kollmann

Multipage TIF to PDF

Hello,

Is it possible with SynPDF to convert a multpage TIF to PDF using the CCITTFaxDecode format ?

XnView can do that, the PDF has almost the same size than the TIF

9 0 obj
<<
/Type /XObject
/Subtype /Image
/Name /Im0
/Filter [ /CCITTFaxDecode ]
/DecodeParms [ << /K -1 /Columns 2448 /Rows 3498 >> ]
/Width 2448
/Height 3498
/ColorSpace 11 0 R
/BitsPerComponent 1
/Length 10 0 R
>>
stream

TAESCFB.SimpleEncrypt doesn't work for large files

I use this code for file encryption:

var
  inputfile : RawByteString;
  outputfile: RawByteString;
begin
  inputfile := StringFromFile('c:\test1.mp4');
  outputfile := TAESCFB.SimpleEncrypt(inputfile,'TEST',true,true);
  FileFromString(outputfile,'c:\test2.mp4');
end;

However it doesn't work for large files (>1GB). Is there any way to encrypt large files?

DefaultPaperSize does not work

My standard Windows printer is orientated in Landscape. But if I get the paper size from it, it's orientated as Portrait.

PDF := TPDFDocumentGDI.Create(False, CP_UTF8, False);
PDF.DefaultPaperSize := CurrentPrinterPaperSize();
PageWidth := Trunc(Integer(PDF.DefaultPageWidth) * GetDeviceCaps(Canvas.Handle, LOGPIXELSX) / 72);
PageHeight := Trunc(Integer(PDF.DefaultPageHeight) * GetDeviceCaps(Canvas.Handle, LOGPIXELSY) / 72); 

Is this my mistake or is it a bug in SynPDF?

HTML Table not well drawn

Hello,

I wrote this procedure to convert HTML to PDF.
But the Table is not well drawn.
HTMLViewer is used for rendering: https://github.com/BerndGabriel/HtmlViewer

procedure THTMLToXForm.HTMLViewerSynPDFClick(Sender: TObject);

var
Size : TSize;
Viewer : THtmlViewer;
pdfForm : TForm;
pdf : TPdfDocumentGDI;
begin
pdf := TPdfDocumentGDI.Create;
pdfForm := TForm.Create(nil);
Viewer := THtmlViewer.Create(pdfForm);
Viewer.Parent := pdfForm;
Viewer.DefBackground := clWhite;
Viewer.LoadFromFile(htmlFile);
Size.cx := Round(HTMLWidthFromViewPort(viewer.Text)*pdf.ScreenLogPixels/25.4);
Size := viewer.FullDisplaySize(Size.cx);
pdf.AddPage;
pdf.DefaultPageWidth := Size.cx;
pdf.DefaultPageHeight := Size.cy;
Viewer.Draw(pdf.VCLCanvas,0,Size.cx,Size.cx,Size.cy);
pdf.SaveToFile(ChangeFileExt(htmlFile,'-HTML-To-SYNPDF.pdf'));
pdf.Free;
pdfForm.Free;
end;

Reporter-HTML-To-SYNPDF.pdf

Reporter.txt

Best regards.

64bit AV in Delphi 10.2 for PEMRPolyLine16

This line in SynPdf.pas gives an access violation in Delphi 10.2 64 bit when cpts = 0

with PEMRPolyLine16(R)^.apts[PEMRPolyLine16(R)^.cpts-1] do

I don't really understand this code, or why it works in 32 bit when cpts=0, but have changed it to:

  if (PEMRPolyLine16(R)^.cpts > 0) then
  begin
    with PEMRPolyLine16(R)^.apts[PEMRPolyLine16(R)^.cpts-1] do
    begin
      Position.X := X;
      Position.Y := Y;
    end;
  end
  else
  begin
    Position.X := 0;
    Position.Y := 0;
  end;

Stack overflow on encrypted pdf

I have a stack overflow error when saving when I try to encrypt a pdf.
The error appears in TPdfRawText.InternalWriteTo

Here is my code :

        p := TMemoryStream.Create;
         Pdf := TPdfDocumentGDI.Create(false, 0, false, TPdfEncryption.New(elRC4_40, '1234', '1234',  [epPrinting]));
        Pdf.GeneratePDF15File := True;
        Pdf.PDFA1 := False;
        Pdf.Info.Title := 'Title';
        Pdf.Info.Author := 'Author';
        Pdf.Info.Creator := 'Creator';
        try
          for i := 1 to QuickReport.QRPrinter.PageCount do
          begin
            aMeta := QuickReport.QRPrinter.GetPage(i);
            try
              Pdf.DefaultPageWidth := MulDiv(aMeta.Width,72,Pdf.ScreenLogPixels);
              Pdf.DefaultPageHeight := MulDiv(aMeta.Height,72,Pdf.ScreenLogPixels);
              Pdf.AddPage;
              Pdf.Canvas.RenderMetaFile(aMeta,1,0,0,0, tpSetTextJustification,99,101,tcNeverClip);
            finally
              aMeta.Free;
            end;
          end;
          Pdf.SaveToStream(p);     <<--- Error appears here
        finally
          FreeAndNil(Pdf);
          FreeAndNil(p);
        end;

Revert the pull request 46

The change in pull request 46 seems to be invalid: #46

Here is the code I used to test this.

The output was:
MS Sans Serif 2
Microsoft Sans Serif 2
Courier New 1
Courier 1

This means that "(ALogFont.lfPitchAndFamily and 3) = FIXED_PITCH" would evaluate for the parameter AIsFixedWidth to

MS Sans Serif 2 => False
Microsoft Sans Serif 2 => False
Courier New 1 => True
Courier 1 => True

This is correct.

@maykon-t can you test on your computer?

// JCL_DEBUG_EXPERT_GENERATEJDBG OFF
program TestFonts;

{$APPTYPE CONSOLE}

{$R *.res}

uses
    System.SysUtils, Windows;

function EnumFontsProc(var LogFont: TLogFont; var TextMetric: TTextMetric;
    FontType: Integer; Data: Pointer): Integer; stdcall;
begin
    WriteLn(string(LogFont.lfFaceName), ' ', LogFont.lfPitchAndFamily and 3);

    Result := 1;
end;

var
    DC: HDC;
    F: LOGFONTW;
begin
    DC := GetDC(0);
    try
        FillChar(F, sizeof(F), 0);
        F.lfCharset := DEFAULT_CHARSET;
        EnumFontFamiliesEx(DC, F, @EnumFontsProc, 0, 0);
    finally
        ReleaseDC(0, DC);
    end;
    ReadLn;
end.

Render images in Windows sever

Hello, Im generating pdf files in windows server, but when the file contains an image, render it wrong.
I already try with
pdfDoc.VCLCanvas.StretchDraw
pdfDoc.Canvas.DrawXObject
pdfDoc.VCLCanvas.Draw
with the same results
Windows server sample
pdf.pdf
Windows 10 sample
pdf2.pdf
Server is 2012 R2 Standard

Update/Change the default FontFallBackName

The default value for the FontFallBackName is set to "Arial Unicode MS". This font type is no longer maintained by Microsoft and no longer included with Office at is has been. Microsoft sells the font at 209โ‚ฌ per license instead, which doesn't make it a good default value.

I would propose 'Noto Sans CJK JP Regular' as a new default value, as it is freely available and supports a similar range of characters. It's an OpenType font though and not yet supported.

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.