There is some free component to export to PDF?

General TRichView support forum. Please post your questions here
Post Reply
leandersantosm
Posts: 20
Joined: Fri Jun 03, 2011 8:33 pm

There is some free component to export to PDF?

Post by leandersantosm »

Hello!

Anyone knows if there is some free component to export the richview documents to PDF?

I found one in richview resources webpage (TRichViewPDF by Roledata Information Technology), but the website is offline, so I can't download it.

Thanks.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

All other PDF engines that are tested with TRichView are not free.
There is one untested option, though - Synopse PDF Engine: http://blog.synopse.info/
It looks like it has VCLCanvas property where you can draw TRVReportHelper. Or you can draw a page into a metafile, then draw this metafile on the page using their engine.
GerryD
Posts: 10
Joined: Wed Oct 06, 2010 1:07 am
Location: Dallas

Follow-up

Post by GerryD »

I too would like to get the synopse code to work. See the snippet of synopse code below.

I can make this work for a tRichEdit component (what the code was desined to do) but not a tRichView. Can I assume it is because the tRichView is not responding to the SEND_MESSAGE? All this code receives back are zeros.

I passed in the handle of the tRichview component to this function. Am I way off base here?


procedure TGDIPages.AppendRichEdit(RichEditHandle: HWnd);
var Range: TFormatRange;
LogX, LogY, LastChar, MaxLen, OldMap: integer;
TextLenEx: TGetTextLengthEx; // RichEdit 2.0 Window Class
begin
if (Self<>nil) and (fCanvas<>nil) then
with Range do begin
LogX := GetDeviceCaps(fCanvas.Handle, LOGPIXELSX);
LogY := GetDeviceCaps(fCanvas.Handle, LOGPIXELSY);
rcPage.Left := (fPageMarginsPx.Left*1440) div LogX;
rcPage.Right := ((fPhysicalSizePx.x-fPageMarginsPx.Right)*1440) div LogX;
rcPage.Top := ((fPageMarginsPx.Top+fHeaderHeight)*1440) div LogY;
rcPage.Bottom := ((fPhysicalSizePx.y-fPageMarginsPx.Bottom-fFooterHeight)*1440) div LogY;
rc := rcPage;
rc.Top := (fCurrentYPos*1440) div LogY;
LastChar := 0;
with TextLenEx do begin
flags := GTL_DEFAULT;
codepage := CP_ACP;
end;
MaxLen := SendMessage(RichEditHandle, EM_GETTEXTLENGTHEX, Integer(@TextLenEx), 0);
chrg.cpMax := -1;
OldMap := SetMapMode(hdc, MM_TEXT);
try
SendMessage(RichEditHandle, EM_FORMATRANGE, 0, 0);
repeat
chrg.cpMin := LastChar;
hdc := fCanvas.Handle;
hdcTarget := hdc;
LastChar := SendMessage(RichEditHandle, EM_FORMATRANGE, 1, Integer(@Range));
if cardinal(LastChar)>=cardinal(MaxLen) then
break;
NewPageInternal;
DoHeader;
rc := rcPage;
until false;
fCurrentYPos := (rc.Bottom*LogY) div 1440;
finally
SendMessage(RichEditHandle, EM_FORMATRANGE, 0, 0);
SetMapMode(hdc, OldMap);
end;
end;
end;
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

This code does not work for TRichViewEdit, it is only for TRichEdit.
Try drawing a metafile (using TRVReportHelper) and export it using Synopse.
Post Reply