Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

TAdvPDFLib landscape...

 Post Reply Post Reply
Author
Drake Mark View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 Jan 2011
Posts: 122
Post Options Post Options   Quote Drake Mark Quote  Post ReplyReply Direct Link To This Post Topic: TAdvPDFLib landscape...
    Posted: 08 Dec 2019 at 3:22am
Hello,

First time using TAdvPDFLib. The user manual needs some attention. Page 18&19 have a few...issues, my2c.
Attempting to save a bitmap to PDF. Saving the bitmap to a file, the image is correct for size and orientation.

No joy with TAdvPDFLib.
I did figure out the TBitMap (in the user manual) needs to be a TPicture and the version is 1.0.2.0 in the properties of the debugger.
Nothing I tried (many things) would get it to save to landscape.
And it prints the word "header" and "footer" no matter what I do.
Perhaps I totally miss what needs to be done.

procedure SaveScreenToPDF(bMap:TBitmap; const fName:string);
var
 p:TAdvPDFLib;
 aPicture:TPicture;
begin
 p:=TAdvPDFLib.Create;
 aPicture:=TPicture.Create;
 try
  aPicture.Assign(bMap);
  p.BeginDocument(fName);
  p.NewPage;
  p.PageOrientation:=poLandscape;
  p.PageSize:=psCustom;
  p.PageWidth:=bMap.width;
  p.PageHeight:=bMap.height;
  p.Graphics.Fill.Color:=gcNull;

  p.Header:='';
  p.HeaderSize:=0;
  p.Footer:='';
  p.FooterSize:=0;

  p.Graphics.DrawImage(aPicture,
                       gcNull,
                       RectF(0,0,bMap.width,bMap.height),
                       false,
                       false,
                       itOriginal,
                       1.0,
                       false);

  p.EndDocument(true);
 finally
  p.Free;
  aPicture.Free
 end;
end;

Ideas?

Thanks,

Mark
Back to Top
Drake Mark View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 Jan 2011
Posts: 122
Post Options Post Options   Quote Drake Mark Quote  Post ReplyReply Direct Link To This Post Posted: 08 Dec 2019 at 4:16am
OK, I took a break, then worked on it more and found the correct settings order. Not the order in the user manual.
Here you go.
procedure SaveScreenToPDF(bMap:TBitmap; const fName:string);
var
 p:TAdvPDFLib;
 aPicture:TPicture;
begin
 p:=TAdvPDFLib.Create;
 aPicture:=TPicture.Create;
 try
  aPicture.Assign(bMap);

  p.PageWidth:=bMap.width;
  p.PageHeight:=bMap.height;
  p.PageSize:=psCustom;
  p.Header:='';
  p.HeaderSize:=0;
  p.Footer:='';
  p.FooterSize:=0;

  p.BeginDocument(fName);
  p.NewPage;

  p.Graphics.Fill.Color:=gcNull;
  p.Graphics.DrawImage(aPicture,
                       gcNull,
                       RectF(0,0,bMap.width,bMap.height),
                       false,
                       false,
                       itOriginal,
                       1.0,
                       false);

  p.EndDocument(true);
 finally
  p.Free;
  aPicture.Free
 end;
end;

Back to Top
Pieter Scheldeman View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 3463
Post Options Post Options   Quote Pieter Scheldeman Quote  Post ReplyReply Direct Link To This Post Posted: 09 Dec 2019 at 10:04am
This is possibly due to underlying structural changes in the PDF lib handling, where the pages where generated at the end, and now they are generated with each NewPage call. Thank you for your feedback.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down