Delphi Pdf的使用方法

此方法安装了llPDFLib.v3.6 控件、对pdf左侧、右侧正文进行了操作。

procedure TForm1.Button1Click(Sender: TObject);
var node,nd1:TPDFOutlineNode;
    PW,ph:integer;
    bmp:TBitmap;
begin
  bmp:=TBitmap.Create;
  bmp.LoadFromFile('d:\4601.bmp');
  sPdf:=TPDFDocument.Create(nil);
  //pdf文档信息
  sPdf.DocumentInfo.CreationDate:=Now;
  sPdf.DocumentInfo.Producer:='Producer';
  sPdf.DocumentInfo.Author:='Author';
  sPdf.DocumentInfo.Creator:='Creator';
  sPdf.DocumentInfo.Keywords:='Keywords';
  sPdf.DocumentInfo.Subject:='subject';
  sPdf.DocumentInfo.Title:='Title';

  sPdf.FileName:='d:\tt.pdf';
  sPdf.Compression:=ctFlate;
  spdf.OwnerPassword:='123';
  sPdf.ProtectionEnabled:=True;
  sPdf.PageMode:= pmUseOutlines;
  sPdf.AutoLaunch:=true;
  sPdf.PageLayout:=plSinglePage;

  sPdf.BeginDoc;
  node:=sPdf.Outlines.Add(nil,'目录1',TPDFGoToPageAction.Create,GB2312_CHARSET);
  node.Expanded:=True;
  TPDFGoToPageAction(node.Action).PageIndex:=0;
  nd1:=sPdf.Outlines.AddChild(node,'第一章',TPDFGoToPageAction.Create,GB2312_CHARSET);
  nd1.Expanded:=true;
  TPDFGoToPageAction(nd1.Action).PageIndex:=0;
  pw:=sPdf.PageWidth;
  ph:=sPdf.PageHeight;
  sPdf.CurrentPage.SetActiveFont('黑体',[fsUnderline],50,GB2312_CHARSET);
  with sPdf do
  begin
    Canvas.Font.Size:=50;
    Canvas.Font.Color:=clRed;
    Canvas.Font.Style:=[fsBold,fsUnderline];
    Canvas.MoveTo(0,10);
    Canvas.LineTo(PW,10);
    SetTextAlign(sPdf.Canvas.Handle, TA_CENTER or TA_TOP); //居中
    Canvas.TextOut(Round(pw/2),30,'新的故事就要开始了');
    Canvas.TextOut(50,30,IntToStr(pw)+','+inttostr(ph));
    Canvas.MoveTo(0,50);
    Canvas.LineTo(PW,50);
    Canvas.Draw(100,100,bmp);
  end;
  sPdf.NewPage;
  nd1:=sPdf.Outlines.AddChild(node,'第二章',TPDFGoToPageAction.Create,GB2312_CHARSET);
  nd1.Expanded:=true;
  TPDFGoToPageAction(nd1.Action).PageIndex:=1;
  sPdf.EndDoc;
  sPdf.Free;
  bmp.Free;
end;

  

转载于:https://www.cnblogs.com/hejoy91/p/3527122.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值