I'm currently creating a PDF from RTF using this:
var
RichText : TWPCustomRtfEdit;
Enviroment : TWPToolsEnviroment;
PDF : TWPPDFExport;
begin
Result := 0;
if not ForceDirectories(ExtractFilePath(AFQFilename_PDF)) then begin
Result := 3;
Exit;
end;
Enviroment := nil;
RichText := nil;
PDF := nil;
try
try
{$IFNDEF NOENVIROMENT}
Enviroment := TWPToolsEnviroment.Create(nil);
Enviroment.Assign(GlobalWPToolsCustomEnviroment);
{$ENDIF}
RichText := TWPCustomRtfEdit.CreateDynamic;
if Assigned(Enviroment) then
RichText.Memo.RTFData.RTFProps.Enviroment := Enviroment;
RichText.AsString := AString_RTF;
RichText.ReformatAll; // First time to calculate pages
RichText.ReformatAll; // Second time to do the job
RichText.ReformatAll; // Third time to REALLY do the job
PDF := TWPPDFExport.Create(nil);
PDF.Source := RichText;
PDF.FileName := AFQFilename_PDF;
PDF.FontMode := wpEmbedSubsetTrueType_UsedChar;
PDF.Print;
except
Result := 4;
end;
finally
if Assigned(Enviroment) then FreeAndNil(Enviroment);
if Assigned(RichText) then FreeAndNil(RichText);
if Assigned(PDF) then FreeAndNil(PDF);
end;
Unfortunately, I cannot figure out how to tell the TWPPDFExport I'd like it to generate PDFs for legal size paper.
I imaging it must be a property set somewhere, but I can't find it.
Does anyone know how to do this?
Thanks!