Export to PDF with ReportBuilder ppRichView

General TRichView support forum. Please post your questions here
Post Reply
cesartakahashi
Posts: 3
Joined: Thu May 27, 2021 3:36 pm

Export to PDF with ReportBuilder ppRichView

Post 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
Attachments
Capturar.JPG
Capturar.JPG (100.27 KiB) Viewed 10100 times
Capturar2.JPG
Capturar2.JPG (117.69 KiB) Viewed 10100 times
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Export to PDF with ReportBuilder ppRichView

Post 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.
cesartakahashi
Posts: 3
Joined: Thu May 27, 2021 3:36 pm

Re: Export to PDF with ReportBuilder ppRichView

Post by cesartakahashi »

An example is attached. Thank you very much for the support
Attachments
Teste.zip
(43.58 KiB) Downloaded 828 times
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Export to PDF with ReportBuilder ppRichView

Post by Sergey Tkachenko »

Sorry, can you create a project without TrxMemoryData?
I do not know how to install it in new versions of Delphi.
cesartakahashi
Posts: 3
Joined: Thu May 27, 2021 3:36 pm

Re: Export to PDF with ReportBuilder ppRichView

Post by cesartakahashi »

A new project is attached. Thank you very much for the support.
Attachments
NewTest.zip
(43.57 KiB) Downloaded 776 times
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Export to PDF with ReportBuilder ppRichView

Post 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).
Post Reply