You are not logged in.
Pages: 1
Hi,
I want to convert RTF-text from RichEdit into PDF using synopse pdf engine. So I started with a small Delphi-programm using a demofile I found in the internet.
...
with TGDIPages.Create(self) do
try
Caption := 'SynPDF RichEdit Print Preview & PDF Creation';
BeginDoc;
SaveLayout;
Font.Size := 9;
AddTextToHeaderAt(Caption,LeftMargin);
TextAlign := taRight;
AddTextToHeader(DateTimeToStr(Now));
AddLineToHeader(true);
TextAlign := taLeft;
AddLineToFooter(true);
AddPagesToFooterAt('Page %d/%d',LeftMargin);
TextAlign := taRight;
AddTextToFooterAt('-=- Test Right click on the report then "Export as PDF" -=-',RightMarginPos);
RestoreSavedLayout;
DrawTitle('Rich Edit Content',true);
AppendRichEdit(RichEdit1.Handle);
DrawTitle('Last page content',true);
NewHalfLine;
DrawText('We are also able '+
'to know at where Y position the RichEdit content was finished printing....'#13+
'Therefore, any further writing to the report continue to the same page.');
DrawLine(true);
EndDoc;
ExportPDF(filenamepdf,true,false);
ShowPreviewForm;
finally
Free;
end;
...
everything is ok when I have only one paragraph in RichEdit1.
When I enter a new paragraph using the RETURN-key and start the konversion again by pressing button1 the program crashes and I have to terminate by windows program-manager.
The event occurs in the line: AppendRichEdit(RichEdit1.Handle);
What could be the reason? I am using Delphi XE8
Thanks for answering!
Offline
I found out by running debug, that there is an endless loop in: SQLite3Pages.pas vs 1.9 beginning at line 3739 until line 3752 in procedure TGDIPages.AppendRichEdit. If I replace until ... by my own everything works perfect.
Unfortunately I do not really understand the code. Could one of the programmers help me?
here the code:
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 begin
NewPageInternal;
DoHeader;
end else
fCurrentYPos := (rc.Bottom*LogY) div 1440;
rc := rcPage;
//until (LastChar>=1) or (LastChar=-1);
until (LastChar>=MaxLen) or (LastChar=-1);
finally
SendMessage(RichEditHandle, EM_FORMATRANGE, 0, 0);
SetMapMode(hdc, OldMap);
end;
Thanks for reply.
Offline
thank you so much!
now all is running nearly perfect!
please allow two questions:
1. can I append a graphic into my new PDF-document befor I save the PDF-document? I am using TGDIPages. code sample?
2. my Delphi-compiler can not compile the demo-program into 64-Bit-Windows. The only I can choose is 32-Bit-Windows. Is 64-bit impossible using Synopse-PDF-engine?
thanks for helping
Offline
Pages: 1