I am French. Excuse me for my English.
PrintPreview does not take account of the orientation of paper to create file pdf.
In portrait, there is no problem.
In landscape, the PDF file is created in portrait.
I modified the SaveAsPdf function but that functions only on the first page.
Here modification:
- Code: Select all
procedure TPrintPreview.SaveAsPDF(const FileName: String);
var
I: Integer;
Mem: TMemoryStream;
begin
if dsPDF.Handle > 0 then
begin
dsPDF.BeginDoc(PChar(FileName));
try
if FOrientation = poPortrait then
dsPDF.SetPage(2, 0, 0, 0)
else
dsPDF.SetPage(2, 1, 0, 0);
Mem := TMemoryStream.Create;
try
for I := 1 to TotalPages do
begin
if I > 1 then
dsPDF.NewPage;
Mem.Clear;
Pages[I].SaveToStream(Mem);
dsPDF.PrintPageMemory(Mem.Memory, Mem.Size);
end;
finally
Mem.Free;
end;
finally
dsPDF.EndDoc;
end;
end
else
raise EMissingPDFLibrary.Create('Cannot locate ' + dsPDF_lib);
end;
I am not an expert in Delphi. I make especially C or of C++.
I use the version demonstration of dspdf.dll.
Thank you for this component.
Akeix