From f2d659b6ea2dcc265f52e768bc35395bcd49bc69 Mon Sep 17 00:00:00 2001 From: mattias Date: Wed, 21 Jun 2023 12:47:27 +0200 Subject: [PATCH] fcl-pdf: fixed dump hexstring --- packages/fcl-pdf/examples/pdfdump.lpi | 1 - packages/fcl-pdf/examples/pdfdump.pp | 24 +++++++++++++----------- packages/fcl-pdf/src/fppdfobjects.pp | 13 +++++-------- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/packages/fcl-pdf/examples/pdfdump.lpi b/packages/fcl-pdf/examples/pdfdump.lpi index 04148585b9..3e040b5d77 100644 --- a/packages/fcl-pdf/examples/pdfdump.lpi +++ b/packages/fcl-pdf/examples/pdfdump.lpi @@ -4,7 +4,6 @@ - diff --git a/packages/fcl-pdf/examples/pdfdump.pp b/packages/fcl-pdf/examples/pdfdump.pp index 47b9b02985..3ebda9e3ef 100644 --- a/packages/fcl-pdf/examples/pdfdump.pp +++ b/packages/fcl-pdf/examples/pdfdump.pp @@ -25,7 +25,9 @@ uses type { TPDFDumpApplication } - TInfoSection = (isInfo,isCatalog,isTrailer,isObjects, isFonts, isPages,isPageContents,isPageText, isDictionaries); + + TInfoSection = (isInfo, isCatalog, isTrailer, isObjects, isFonts, + isPages, isPageContents, isPageText, isDictionaries); TInfoSections = Set of TInfoSection; TPDFDumpApplication = class(TCustomApplication) @@ -40,17 +42,17 @@ type Protected procedure DisplayPageText(Doc: TPDFDocument; aIndex: Integer; aPage: TPDFPageObject); procedure DoLog(sender: TObject; aKind: TPDFLogkind; const aMessage: string); reintroduce; - Procedure DoProgress(Sender : TObject;aKind : TPDFProgressKind; aCurrent,aCount : Integer); + Procedure DoProgress(Sender: TObject; aKind: TPDFProgressKind; aCurrent, aCount : Integer); procedure DisplayCatalog(Doc: TPDFDocument); procedure DisplayInfo(Doc: TPDFDocument); procedure DisplayObjects(Doc: TPDFDocument); procedure DisplayFonts(Doc: TPDFDocument); - procedure DisplayPageContents(Doc: TPDFDocument; aIndex: Integer; aPage: TPDFPageObject); + procedure DisplayPageContents(Doc: TPDFDocument; aIndex: Integer; aPage: TPDFPageObject); procedure DisplayPages(Doc: TPDFDocument); procedure DisplayTrailer(Doc: TPDFDocument); Public function ProcessOptions : Boolean; - procedure Usage(Msg : String); + procedure Usage(Msg: String); procedure DumpFile(FN: String); procedure DoRun; override; end; @@ -316,13 +318,13 @@ begin UnicodeMap:=nil; end else If cmd is TPDFTextCommand then - begin - rawText:=TPDFTextCommand(Cmd).GetFullText(UnicodeMap); - // Writeln('GetCodePage : ',CodePageToCodePageName(StringCodePage(Rawtext))); - SetCodePage(RawText,CP_UTF8); - Writeln(RawText); - end; - end; + begin + rawText:=TPDFTextCommand(Cmd).GetFullText(UnicodeMap); + //Writeln('GetCodePage : ',CodePageToCodePageName(StringCodePage(Rawtext))); + SetCodePage(RawText,CP_UTF8); + Writeln(RawText); + end; + end; end; procedure TPDFDumpApplication.DisplayPages(Doc : TPDFDocument); diff --git a/packages/fcl-pdf/src/fppdfobjects.pp b/packages/fcl-pdf/src/fppdfobjects.pp index eea4e756ad..1d38e0ccd3 100644 --- a/packages/fcl-pdf/src/fppdfobjects.pp +++ b/packages/fcl-pdf/src/fppdfobjects.pp @@ -1434,15 +1434,12 @@ begin Result:=''; if Length(Tokens)>=2 then For I:=1 to Length(Tokens)-2 do - begin - if Tokens[I].TokenType=ptString then - - Result:=Result+aUnicodeMap.InterPret(Tokens[I].TokenData) - else if Tokens[i].IsNumber then - begin + case Tokens[I].TokenType of + ptString,ptHexString: + Result:=Result+aUnicodeMap.InterPret(Tokens[I].TokenData); + ptNumber: if Abs(Tokens[i].AsDouble)>PDFTextArraySpaceTreshold then - Result:=Result+' ' - end + Result:=Result+' '; else Raise EConvertError.Create('Unexpected char'); end;