Page 1 of 1

Export to PDF with ReportBuilder ppRichView

Posted: Fri May 28, 2021 6:17 pm
by cesartakahashi
Hi

I work with Delphi 2007, ReportBuilder 16.02, TRichView 17.3 and I add text like this:

ppRichView1P.RichView.Clear;
ppRichView1P.RichView.Style.TextStyles.Items[0].FontName:='Monotype Corsiva';
ppRichView1P.RichView.Style.TextStyles.Items[0].Size:=15;
ppRichView1P.RichView.Style.TextStyles.Items[0].Color:=clBlack;
ppRichView1P.RichView.Style.TextStyles.Items[0].Style:=[];

ppRichView1P.RichView.Style.ParaStyles.Items[0].Alignment:=rvaJustify;
ppRichView1P.RichView.Style.ParaStyles.Items[0].LineSpacing:=100;

ppRichView1P.RichView.AddNL('TESTE DE IMPRESSÃO TESTE DE IMPRESSÃO TESTE DE IMPRESSÃO TESTE DE IMPRESSÃO TESTE DE IMPRESSÃO ',0,0);

When I send report to screen, that is ok.

ppReport.DeviceType:='Screen';
ppReport.AllowPrintToFile := False;
ppReport.ShowPrintDialog := True;
ppReport.ShowCancelDialog:=True;
ppReport.Print;

But when I try to export to PDF, text loses all formatting.

ppReport.AllowPrintToFile := True;
ppReport.ShowPrintDialog := False;
ppReport.ShowCancelDialog := False;
ppReport.TextFileName := 'Report.pdf';
ppReport.DeviceType := 'PDF';
ppReport.PDFSettings.OpenPDFFile:=True;
ppReport.Print;

Any suggestions or recommendations?

Thanks,
Cesar

Re: Export to PDF with ReportBuilder ppRichView

Posted: Mon May 31, 2021 11:47 am
by Sergey Tkachenko
This is quite an old version, I am afraid I cannot provide support for it.
But if you can send me a sample project, I can check if this problem still exists in the new version, and, if yes, I'll suggest a fix.

Re: Export to PDF with ReportBuilder ppRichView

Posted: Mon May 31, 2021 12:24 pm
by cesartakahashi
An example is attached. Thank you very much for the support

Re: Export to PDF with ReportBuilder ppRichView

Posted: Fri Jun 04, 2021 10:33 am
by Sergey Tkachenko
Sorry, can you create a project without TrxMemoryData?
I do not know how to install it in new versions of Delphi.

Re: Export to PDF with ReportBuilder ppRichView

Posted: Fri Jun 04, 2021 11:38 am
by cesartakahashi
A new project is attached. Thank you very much for the support.

Re: Export to PDF with ReportBuilder ppRichView

Posted: Sat Jun 05, 2021 12:32 pm
by Sergey Tkachenko
I checked with the new version of TRichView and ReportBuilder 20.03, Delphi 10.4.
The font size is correct, at least when the screen's pixel density = 96 dpi (i.e. in Windows screen settings, Scale and layout = 100%)
(If the screen pixel density is greater, and DPI awareness is turned off (the window looks blurry), there is a known problem with text size in PDF (both in ppRichView and standard ReportBuilder objects), but text is smaller, not larger)
So this problem is fixed in the new version.

When exporting to PDF, ppRichView generates a TMetafile and gives it to RB's PDF renderer.
This metafile has a large size, however, it must be scaled by RB to the object size.
For any case, you can check a metafile that is created by ppRichView.
Open ppPDFRendererRV.pas, uncomment lMetaFile.SaveToFile line (change to some path), and then see which metafile is generated (you can attach to this topic).