вторник, 26 марта 2013 г.

FastReport 4 font reading and huge file size workaround solution

Information for Russian-speakingсDevelopers is in Russian version of this article

Environment:
Delphi 7 application, Fast Report 4 VCL


Problem 1:
Export files from FastReport to PDF is unreadable on Android-devices, iOS-devices and web mailers.


Solution 1 - PDF is unreadable on Android-devices, iOS-devices and web mailers
embed fonts in the report file.
In export component set this property to "true":
TfrxPDFExport.EmbeddedFonts

With embedded font report became readable on any client OS and Web Mailers.


Problem 2 (a consequence of the solution of the problem 1)
The report file is huge: approximately 1MB


Reason: embedded font (which we embed in pdf file to solve problem 1)

Particular Solution 2 -
The huge file-size of FastReport export to PDF with embedded fonts:

I must say that the general solution I have not found. Tried to use third-party filters, but they have bugs. Virtual pdf printer - is not suited for me as a solution, because it's hard to maintain. But I found a partial solution that work in my environment, hope it may be useful to someone:

The Main Idea of the solution: use a font with small file-size. Naturally this font you need to install on your development computer and on the client computer (only to computer of pdf-exporter customer).

Disadvantages solutions: font need to be installed on client computer.

Small in size (57KB) Arial-like font with Cyrillic Charset I've found here:
http://weblast.ru/fonts-493.html
direct link: http://weblast.ru/fonts/ukrainian/ARICYR.ttf

I've set Font property of all  labels and bands in a report to new font, and (BINGO!) export file reduced from 1MB to 120KB.

Please note that labels did not pickup new font when their CharSet property was setted to RUSSIAN_CHARSET, I had to change down all charsets to DEFAULT_CHARSET

Case history

The problem must be solved in 5 FastReport VCL (it includes only used font-characters in exported file), but there is stil not FastReport 5 VCL on developer's site, and who knows when it will be. Wrote to support - no answer.

Related Links

http://www.fast-report.com/en/forum/index.php?showtopic=7265

http://stackoverflow.com/questions/6844831/any-good-pdf-export-filter-that-works-with-fast-report



Комментариев нет:

Отправить комментарий