亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? usealpdf.pas

?? 給PDF文件加蓋印章或背景
?? PAS
?? 第 1 頁 / 共 2 頁
字號:
{*
* Copyright (c) 2007 ,北京量子偉業時代信息技術有限公司開發部
* All rights reserved.
*
* 文件名稱:uSealPDF
* 文件標識:
* 摘    要:歸檔章類
*
* 當前版本:1.0
* 作    者:占國太
* 完成日期:2008-5-29
*}


unit uSealPDF;

interface
uses
  Windows, SysUtils, StrUtils, Classes,PdfDoc, PdfTypes, PdfFonts;

type
  PPdfObj = ^TPdfObj;
  TPdfObj = record
    number,
      offset: integer;
    filePtr: pchar;
  end;
  TPdfSeal=class(TObject)
   private
    FsParam1: string;
    FsParam2: string;
    FsParam3: string;
    FsParam4: string;
    FsParam5: string;
    FsParam6: string;
    Faction:string;
    FallowParams:string;
    FownerParam:string;
    FuserParam: string;
    tmpPath:string;
    PdfTkPath:string;
    FiPosition: integer;
    function GetPdfPageCount(const filename: string): integer;
    function CreateTempPDF(P1, P2, P3, P4, P5, P6: string; var TempFile: string; iPos: integer = 2): boolean;
  public
    constructor Create;virtual;
    destructor Destroy; override;
    property sParam1: string read FsParam1 write FsParam1;
    property sParam2: string read FsParam2 write FsParam2;
    property sParam3: string read FsParam3 write FsParam3;
    property sParam4: string read FsParam4 write FsParam4;
    property sParam5: string read FsParam5 write FsParam5;
    property sParam6: string read FsParam6 write FsParam6;
    property action:string  read Faction write Faction;
    property allowParams:string read FallowParams write FallowParams;
    property ownerParam:string read FownerParam write FownerParam;
    property userParam: string read FuserParam write  FuserParam;
    property iPosition:integer read FiPosition write FiPosition;
    procedure DeleteAllTmpPdfFiles;
    function DoSealOk(PdfFileName,NewPDF:string): boolean;
  end;

implementation

function GetTempDirectory: string;
var
  tempFolder: array[0..MAX_PATH] of char;
begin
  if GetTempPath(MAX_PATH, @tempFolder) = 0 then
    raise Exception.Create('GetTempPath: Invalid temp path')
  else
    result := tempFolder;
end;
function ExtractRes(ResType, ResName, ResNewName: string): boolean;
var
  Res: TResourceStream;
begin
  if not FileExists(ResNewName) then
  begin
    Res := TResourceStream.Create(Hinstance, Resname, Pchar(ResType));
    Res.SavetoFile(ResNewName);
    Res.Free;
  end;
  Result := FileExists(ResNewName);
end;

const
  NEVER_GIVE_UP = 0;

function WinExecAndWait32(const DosCommand: string;
  ShowWindow, GiveUpTimeOutSecs: Word; out textOutput: string): DWord;
const
  BufferSize = 8192;
var
  StartUpInfo: TStartupInfo;
  ProcessInfo: TProcessInformation;
  OutputReadPipeHdl, OutputWritePipeHdl: THandle;
  SecAttribs: TSecurityAttributes;
  Buffer: PChar;
  timeCnt, BytesRead, BytesAvailable, WaitResult: DWord;
  PipeCreated, ProcessCreated: boolean;
begin
  //nb: 1. The max command line length for CreateProcess() is 32767 characters.
  Result := DWORD(-1); //ie result when unable to create process
  if GiveUpTimeOutSecs = NEVER_GIVE_UP then
    GiveUpTimeOutSecs := $FFFF; //(ie about 18hrs so not quite never :))
  SecAttribs.nLength := SizeOf(TSecurityAttributes);
  SecAttribs.bInheritHandle := true;
  SecAttribs.lpSecurityDescriptor := nil;
  PipeCreated := CreatePipe(OutputReadPipeHdl,
    OutputWritePipeHdl, @SecAttribs, BufferSize);
  StartUpInfo.cb := Sizeof(StartUpInfo);
  StartUpInfo.wShowWindow := ShowWindow;
  Buffer := AllocMem(BufferSize + 1);
  try
    if PipeCreated then
    begin
      fillChar(startUpInfo, sizeof(startUpInfo), 0);
      startUpInfo.dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
      startUpInfo.hStdInput := 0;
      startUpInfo.hStdOutput := OutputWritePipeHdl;
      startUpInfo.hStdError := OutputWritePipeHdl;
      ProcessCreated := CreateProcess(nil, PChar(DosCommand),
        @SecAttribs, @SecAttribs, true, NORMAL_PRIORITY_CLASS,
        nil, nil, startUpInfo, ProcessInfo);
      textOutput := '';
    end else
    begin
      startUpInfo.dwFlags := STARTF_USESHOWWINDOW;
      ProcessCreated := CreateProcess(nil, PChar(DosCommand),
        nil, nil, false, NORMAL_PRIORITY_CLASS or CREATE_NEW_CONSOLE,
        nil, nil, startUpInfo, ProcessInfo);
    end;

    if ProcessCreated then
    begin
      timeCnt := 0;
      repeat
        WaitResult := WaitForSingleObject(ProcessInfo.hProcess, 100);

        if PipeCreated then
        begin
          //nb: a full pipe buffer would cause an endless loop ...
          if not PeekNamedPipe(OutputReadPipeHdl,
            nil, 0, nil, @BytesAvailable, nil) then break;
          if (BytesAvailable > 0) then
          begin
            //Interestingly, it appears that if the default pipe buffer is larger
            //that that supplied in CreatePipe(), then the default size is used.
            BytesRead := 0;
            if BytesAvailable > BufferSize then
              ReadFile(OutputReadPipeHdl, Buffer[0], BufferSize, BytesRead, nil)
            else
              ReadFile(OutputReadPipeHdl, Buffer[0], BytesAvailable, BytesRead, nil);
            Buffer[BytesRead] := #0;
            OemToAnsi(Buffer, Buffer);
            textOutput := textOutput + Buffer;
          end;
        end;
        //Application.ProcessMessages;
        inc(timeCnt, 100);
      until (WaitResult <> WAIT_TIMEOUT) or (timeCnt > GiveUpTimeOutSecs * 1000);

      if not GetExitCodeProcess(ProcessInfo.hProcess, Result)
        and (result = STILL_ACTIVE) then
        TerminateProcess(ProcessInfo.hProcess, result);

      CloseHandle(ProcessInfo.hProcess);
      CloseHandle(ProcessInfo.hThread);
    end;

    if PipeCreated then
    begin
      CloseHandle(OutputWritePipeHdl);
      CloseHandle(OutputReadPipeHdl);
    end;
  finally
    FreeMem(Buffer);
  end;
end;

function MakeGUID: string;
var
  aGuid: TGUID;
begin
  CreateGuid(aGuid);
  Result := GUIDToString(aGuid);
  Delete(Result, 1, 1);
  Delete(Result, length(Result), 1);
  Result := AnsiReplaceText(Result, '-', '');
end;

{TPdfSeal}
procedure TPdfSeal.DeleteAllTmpPdfFiles;
var
  i: integer;
  sr: TSearchRec;
begin
  i := FindFirst(tmpPath + '*.pdf', faAnyFile, sr);
  while i = 0 do
  begin
    SetFileAttributes(pchar(tmpPath + sr.Name), 0); //remove read-only etc
    DeleteFile(tmpPath + sr.Name);
    i := FindNext(sr);
  end;
  FindClose(sr);
end;

function TPdfSeal.GetPdfPageCount(const filename: string): integer;
var
  ms: TMemoryStream;
  k, cnt, pagesNum, rootNum: integer;
  p, p2: pchar;
  PdfObj: PPdfObj;
  PdfObjList: TList;

  //Summary of steps taken to parse PDF file for page count :-
  //1. Locate 'startxref' at end of file
  //2. get 'xref' offset and go to xref table
  //3. fill my pdfObj List with object numbers and offsets
  //4. handle subsections within xref table.
  //5. read 'trailer' section at end of each xref
  //6. store 'Root' object number if found in 'trailer'
  //7. if 'Prev' xref found in 'trailer' - loop back to step 2
  //8. locate Root in my full pdfObj List
  //9. locate 'Pages' object from Root
  //10. get Count from Pages.

  function GetNumber(out num: integer): boolean;
  var
    tmpStr: string;
  begin
    tmpStr := '';
    while p^ < #33 do inc(p); //skip leading CR,LF & SPC
    while (p^ in ['0'..'9']) do
    begin
      tmpStr := tmpStr + p^;
      inc(p);
    end;
    result := tmpStr <> '';
    if not result then exit;
    num := strtoint(tmpStr);
  end;

  function IsString(const str: string): boolean;
  var
    len: integer;
  begin
    len := length(str);
    result := CompareMem(p, pchar(str), len);
    inc(p, len);
  end;

  function FindStrInDict(const str: string): boolean;
  var
    nestLvl: integer;
    str1: char;
  begin
    //06-Mar-07: bugfix- added nested dictionary support
    //nb: PDF 'dictionaries' start with '<<' and terminate with '>>'
    result := false;
    nestLvl := 0;
    str1 := str[1];
    while not result do
    begin
      while not (p^ in ['>', '<', str1]) do inc(p);
      if (p^ = '<') then
      begin
        if (p + 1)^ = '<' then begin inc(nestLvl); inc(p); end;
      end
      else if (p^ = '>') then
      begin
        if (p + 1)^ = '>' then
        begin
          dec(nestLvl);
          inc(p);
          if nestLvl <= 0 then exit;
        end
      end else
      begin
        result := (nestLvl < 2) and IsString(str);
      end;
      inc(p);
    end;
  end;

begin
  //on error return -1 as page count
  result := -1;
  try
    ms := TMemoryStream.Create;
    PdfObjList := TList.Create;
    //application.ProcessMessages;
    try
      ms.LoadFromFile(filename);

      //find 'startxref' ignoring '%%EOF'
      p := pchar(ms.Memory) + ms.Size - 5;
      //21-Jun-05: bugfix
      //sometimes rubbish is appended to the pdf so
      //look deeper for 'startxref'
      p2 := pchar(ms.Memory);
      repeat
        while (p > p2) and (p^ <> 'f') do dec(p);
        if (p = p2) then exit;
        if StrLComp((p - 8), 'startxref', 9) = 0 then break;
        dec(p);
      until false;
      inc(p);

      rootNum := -1; //ie flag not yet found

      //xref offset ==> k
      if not GetNumber(k) then exit;
      p := pchar(ms.Memory) + k + 4;

      while true do //top of loop  //////////////////////////////
      begin
        //get base object number ==> k
        if not GetNumber(k) then exit;
        //get object count ==> cnt
        if not GetNumber(cnt) then exit;
        //07-Mar-07: bugfix
        //it is possible to have 0 objects in a section
        while p^ < #33 do inc(p); //skip CR, LF, SPC

        //p2 := p; //for debugging only

        //add all objects in section to list ...
        for cnt := 0 to cnt - 1 do
        begin
          new(PdfObj);
          PdfObjList.Add(PdfObj);
          PdfObj.number := k + cnt;
          if not GetNumber(PdfObj.offset) then exit;
          PdfObj.filePtr := pchar(ms.Memory) + PdfObj.offset;
          //14-Apr-07: workaround ... while each entry SHOULD be
          //exactly 20 bytes, not everyone seems to adhere to this.
          while not (p^ in [#10, #13]) do inc(p);
          while (p^ in [#10, #13]) do inc(p);

          //debugging only ...
          //if p <> p2 + 20 then halt; p2 := p;
        end;
        //check for and process further subsections ...

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91视频精品在这里| 一区二区在线观看av| 日韩免费性生活视频播放| 成人aa视频在线观看| 久久爱www久久做| 久久av中文字幕片| 裸体一区二区三区| 免费观看在线综合色| 日本不卡在线视频| 人妖欧美一区二区| 久久国产三级精品| 国产精品一区二区三区四区| 久久69国产一区二区蜜臀| 久久99国内精品| 国产一区二区导航在线播放| 国产iv一区二区三区| 丰满少妇久久久久久久| 成人性生交大片| 一本久久精品一区二区| 欧美日韩一区二区电影| 欧美一级二级三级蜜桃| 欧美成人a∨高清免费观看| 亚洲精品一区二区精华| 日本一区二区三区高清不卡| 1024精品合集| 午夜激情综合网| 国产美女久久久久| 99久久er热在这里只有精品66| 一本到不卡免费一区二区| 欧美中文字幕久久| 欧美精品一区在线观看| 亚洲人成网站影音先锋播放| 丝袜美腿成人在线| 国产一区不卡精品| 在线精品视频小说1| 日韩视频在线永久播放| 中文字幕一区二区三| 日韩成人精品在线| eeuss鲁片一区二区三区在线观看 eeuss鲁片一区二区三区在线看 | 欧美精选在线播放| 久久网这里都是精品| 亚洲特级片在线| 美女视频黄久久| 色婷婷一区二区三区四区| 精品国产一区二区三区久久久蜜月 | 99久久精品国产一区| 欧美日韩精品欧美日韩精品| 久久久久久久性| 午夜av一区二区三区| 国产91丝袜在线播放九色| 欧美日韩一区在线| 国产精品久久久久久久久动漫| 亚洲成av人片| 91免费国产在线| 久久精品一区二区三区av| 午夜视频一区在线观看| 99久久久国产精品| 欧美国产乱子伦| 久久99国产精品免费网站| 欧美性猛交xxxx黑人交| 国产精品私人影院| 国产真实乱子伦精品视频| 欧美日韩一本到| 亚洲男人天堂一区| 成人国产精品免费观看动漫| 日韩欧美在线综合网| 视频一区二区中文字幕| 972aa.com艺术欧美| 国产精品视频在线看| 国产一区二区三区电影在线观看| 在线成人免费视频| 三级一区在线视频先锋| 欧美视频一区二区三区在线观看| 中文字幕精品三区| 国产成人精品免费网站| 国产欧美一区二区精品婷婷| 麻豆视频观看网址久久| 91精品国产免费| 日韩av网站免费在线| 欧美日韩高清在线| 视频一区在线播放| 欧美电影免费观看完整版| 日本v片在线高清不卡在线观看| 欧美高清精品3d| 日本中文字幕一区二区有限公司| 欧美精品三级日韩久久| 男女视频一区二区| 久久美女艺术照精彩视频福利播放| 美日韩一区二区| 久久中文字幕电影| 东方aⅴ免费观看久久av| 国产精品免费av| 色综合久久中文字幕综合网| 亚洲最大成人网4388xx| 欧美丰满美乳xxx高潮www| 免费人成精品欧美精品| www欧美成人18+| 成人动漫av在线| 一区二区免费视频| 51精品视频一区二区三区| 老司机精品视频一区二区三区| 亚洲精品一区二区在线观看| 丁香一区二区三区| 中文字幕一区二区三区在线播放 | 国产成人鲁色资源国产91色综| 欧美一二三四在线| 国产成人久久精品77777最新版本| 国产亚洲福利社区一区| 91官网在线免费观看| 久久丁香综合五月国产三级网站 | 韩国v欧美v亚洲v日本v| 国产精品不卡视频| 911精品国产一区二区在线| 国产麻豆欧美日韩一区| 最新日韩av在线| 在线电影院国产精品| 韩国一区二区三区| 一区二区三区在线播放| 日韩欧美成人一区二区| 91丨porny丨中文| 久久99国产精品麻豆| 亚洲一区二区偷拍精品| 久久亚洲精品国产精品紫薇| 91国偷自产一区二区开放时间| 国产原创一区二区三区| 午夜精品一区二区三区电影天堂| 久久久噜噜噜久噜久久综合| 欧美影视一区在线| 成人激情黄色小说| 精油按摩中文字幕久久| 亚洲电影一区二区| 中文字幕一区二区三区av| 欧美va亚洲va香蕉在线| 日本韩国精品一区二区在线观看| 久久99精品视频| 日韩黄色免费电影| 亚洲三级理论片| 国产精品欧美久久久久无广告| 日韩欧美国产午夜精品| 欧美日韩mp4| 在线一区二区三区做爰视频网站| 国产成人精品在线看| 韩国理伦片一区二区三区在线播放 | 亚洲欧美一区二区在线观看| 精品国产一区二区三区忘忧草| 欧美日韩精品免费观看视频| 色哟哟一区二区三区| av动漫一区二区| 成人国产电影网| 粉嫩一区二区三区性色av| 国产一区不卡视频| 国产资源在线一区| 国产美女久久久久| 国产精一品亚洲二区在线视频| 韩国三级在线一区| 国产黄色91视频| 国产精品主播直播| 国产成人av资源| 成人动漫精品一区二区| 99re66热这里只有精品3直播 | 日本午夜精品视频在线观看| 亚洲大尺度视频在线观看| 亚洲成a人片综合在线| 亚洲成人免费在线| 午夜久久久影院| 美脚の诱脚舐め脚责91| 日韩1区2区3区| 久久99精品久久久久婷婷| 国产一区二区视频在线| 国模套图日韩精品一区二区| 国产精品123区| 91在线播放网址| 欧美日韩国产在线播放网站| 欧美情侣在线播放| 欧美大片在线观看一区二区| 国产日韩欧美a| 亚洲婷婷综合色高清在线| 亚洲一二三区不卡| 久久精品国产色蜜蜜麻豆| 经典三级一区二区| 白白色亚洲国产精品| 91成人看片片| 2020国产精品自拍| 国产精品国产馆在线真实露脸| 一区二区三区精品在线| 麻豆精品在线观看| 成人高清视频在线观看| 欧美视频第二页| 国产亚洲精品中文字幕| 亚洲综合久久久| 国产精品自产自拍| 欧美午夜精品久久久| 精品成人一区二区三区| 亚洲男人的天堂av| 日本欧美大码aⅴ在线播放| 国产精品亚洲第一| 欧美日韩成人在线一区| 国产精品灌醉下药二区| 日韩av一区二区在线影视| 波多野洁衣一区|