Welcome, Guest
Guest Settings
Help

Thread: How to set margins in created PDF report


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Nov 29, 2016 8:48 AM Last Post By: George Winkler Threads: [ Previous | Next ]
Mikael Lenfors

Posts: 80
Registered: 3/6/01
How to set margins in created PDF report  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 29, 2016 2:59 AM
Hello!

I just bought Rave Reports to upgrade an old project we have.
The problem I have in the code below is that the created PDF file has to big margins! The printout is cut of some centimeters on the right end.
The code is run in a service and is supposed to create a PDF document in A4 size with small margins.
The current selected default printer should NOT have an impact on the created PDF!

Please advise.

Function TEntryForm.CreateLabelPDF(FileName: String): Boolean;

Var RvNDRWriter: TRvNDRWriter;
RvRenderPDF: TRvRenderPDF;
ReportData: TMemoryStream;

Begin

Result := False;

ReportData := TMemoryStream.Create;
RvNDRWriter := TRvNDRWriter.Create(Nil);
RvRenderPDF := TRvRenderPDF.Create(Nil);;

Try

RvNDRWriter.StatusFormat := 'Printing page %p';
RvNDRWriter.UnitsFactor := 1;
RvNDRWriter.Title := 'WebLabels';
RvNDRWriter.Orientation := poLandscape;
RvNDRWriter.ScaleX := 100;
RvNDRWriter.ScaleY := 100;
RvNDRWriter.StreamMode := smUser;
RvNDRWriter.OnPrint := CreateLabelPDFPrint;
RvNDRWriter.Tag := ArrayIndex;

RvRenderPDF.DisplayName := 'Adobe Acrobat (PDF)';
RvRenderPDF.FileExtension := '*.pdf';
RvRenderPDF.ImageQuality := 100;
RvRenderPDF.DocInfo.Title := 'Lenfors Data AB';

// Then we assign this data to report writer
RvNDRWriter.Stream := ReportData;

// Execute the report
RvNDRWriter.Execute;

// Create PDF file
RvRenderPDF.PrintRender(ReportData, ExtractFilePath(ParamStr(0)) + 'wwwroot\' + FileName);

Result := True;

Except
// Errorhandler
End;

FreeAndNil(ReportData);
RvNDRWriter.Free;
RvRenderPDF.Free;

End;

Mikael Lenfors

Posts: 80
Registered: 3/6/01
Re: How to set margins in created PDF report  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 29, 2016 4:37 AM   in response to: Mikael Lenfors in response to: Mikael Lenfors
By the way.....

Changing margins in the RvNDRWriter has no impact at all!

RvNDRWriter.MarginTop := 0.5;
RvNDRWriter.MarginBottom := 0.5;
RvNDRWriter.MarginRight := 0.5;
RvNDRWriter.MarginLeft := 0.5;

Best regards, Mikael
George Winkler

Posts: 40
Registered: 5/10/05
Re: How to set margins in created PDF report  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 29, 2016 8:48 AM   in response to: Mikael Lenfors in response to: Mikael Lenfors
Mikael Lenfors wrote:
By the way.....

Changing margins in the RvNDRWriter has no impact at all!

RvNDRWriter.MarginTop := 0.5;
RvNDRWriter.MarginBottom := 0.5;
RvNDRWriter.MarginRight := 0.5;
RvNDRWriter.MarginLeft := 0.5;

Best regards, Mikael

I am not sure how you create the report. When I use Rave I do all my reports in code. Then I use the RvRenderPDF component and when printing I chose PDF and create the PDF file. When I do that I can get whatever margin I want. Works fine. Here is some code...

procedure TForm1.RvSystem3Print(Sender: TObject);
begin
with Sender as TBaseReport do
begin
FN := 'Christmas';
with LabelQuery do
begin
Close;
SQL.Clear;
SQL.ADD('select * from '''+FN+''' T');
// SQL.ADD('where GroupNumber ='''+GN + '''');
SQL.ADD('Order by T.LastName,T.FirstName');
DisableControls;
Open;
EnableControls;
gYPos := 0.4;
while not eof do
begin
gYPos := gYPos + 0.2;
if gYPos > 10.0 then
begin
NewPage;
gYPos := 0.6;
end;
GoToXY(1.0,gYPos);
PrintLeft(FieldByName('LastName').asString + ' ' +
FieldByName('FirstName').asString,2.0);
Next;
end;
end;
end;
end;

I can change the 2.0 to whatever I need.

George
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02