вторник, 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



FastReport 4 экспорт в PDF шрифты и большой размер файла: обходное решение

Окружение:
Программа на Delphi 7, FastReport 4 (VCL)

проблема 1: 
экспорт из FastReport в PDF не читается на андроид-устройствах, iOS-устройствах и веб-почтовиках.

решение проблемы 1 - PDF из FastReport не читается на Android, iOS, веб-почтовиках:
внедряем шрифт в файл.
в компоненте-экспорте свойство: TfrxPDFExport.EmbeddedFonts устанавливаем в true

и отчет нормально читается на всех клиентских машинах.

Проблема 2 (вытекает из решения проблемы 1)
Файл отчета становится большим: примерно 1Мб

Причина: внедренный шрифт (который мы внедрили для решения проблемы 1)

Частное Решение проблемы 2 - 
Большой размер файла экспорта из FastReport в PDF с внедренными шрифтами:

Сразу скажу, что общего решения я не нашел. Пытался использовать сторонние фильтры, но с ними у меня при экпорте вылазили глюки. Виртуальный пдф-принтер - тоже не подходил как решение, т.к. неуниверсально. Но я нашел частное решение, которое сработал в моем окружении, может кому-то окажется полезным:

Суть решения: использовать маленький по размеру шрифт. Естественно шрифт нужно установить и на компьютере разработчика и на компьютере клиента.

Недостатки решения: на компьютер клиента нужно установить используемый шрифт.

Маленький по размеру (57Кб) Arial-подобный шрифт с кириллицей нашел здесь:
http://weblast.ru/fonts-493.html
прямая ссылка: http://weblast.ru/fonts/ukrainian/ARICYR.ttf

перевел все надписи и банды в отчете на новый шрифт, и экспортный файл уменьшился с 1Мб до 120Кб.

Обратите внимание: шрифт не хотел подхватываться если у надписей в отчете стоял RUSSIAN_CHARSET, нужно было все надписи сбить в DEFAULT_CHARSET


История вопроса

Проблема должна была решиться в FastReport 5 VCL (типа там из всего шрифта в экспортный файл должны внедряться только реально используемые символы), но пятой версии нет, и неизвестно когда будет. Писал в поддержку - ответа не получил.

Ссылки по теме

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