[8.01-32bit] Document name truncated in print job

Bug reports will be moved here when the described bug has been fixed

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
white
Power Member
Power Member
Posts: 5815
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

[8.01-32bit] Document name truncated in print job

Post by *white »

When printing a file list or printing a text file from lister, the document name of the print job is truncated at 31 characters.

So the print queue could look like this:

Code: Select all

Document name
-------------
Total Commander - C:\Program Fi
Total Commander - C:\Program Fi
Total Commander - C:\1234567890
Lister - 1234567890123456789012
1234567890123456789012345678901
A print job named "Total Commander - C:\Program Fi" isn't very meaningful.
It's also inconvenient when printing to pdfcreator where the document name of the print job is used as a suggestion for the name of the pdf document.

(Tested using Windows XP Pro)
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

To my knowledge, this is a limitation of the printer spooler - at least in older versions. Do you know whether XP allows longer names now?
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 5815
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

ghisler(Author) wrote:To my knowledge, this is a limitation of the printer spooler - at least in older versions. Do you know whether XP allows longer names now?
I haven't noticed this truncating with other programs. Even Windows notepad.exe seems to have no trouble with file names with more than 200 characters.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

OK, it seems to be a limitation of Delphi 2 printers.pas, the BeginDoc function has a title variable of 32 bytes (32 characters). I will check whether I can change this. I hope that this doesn't crash older Windows versions...
Author of Total Commander
https://www.ghisler.com
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW »

There shouldn't be any problem under old Windows versions. Documentation doesn't limit the title length. Also Delphi 5, which generates applications compatible with Win95, doesn't have such a limit:

Code: Select all

procedure TPrinter.BeginDoc;
var
  DocInfo: TDocInfo;
begin
  CheckPrinting(False);
  SetState(psHandleDC);
  Canvas.Refresh;
  TPrinterCanvas(Canvas).UpdateFont;
  FPrinting := True;
  FAborted := False;
  FPageNumber := 1;
  FillChar(DocInfo, SizeOf(DocInfo), 0);
  with DocInfo do
  begin
    cbSize := SizeOf(DocInfo);
    lpszDocName := PChar(Title);
  end;
  SetAbortProc(DC, AbortProc);
  StartDoc(DC, DocInfo);
  StartPage(DC);
end;
where Title is an AnsiString:

Code: Select all

{$H+}
property Title: string read FTitle write FTitle;
Regards
herman5
Junior Member
Junior Member
Posts: 43
Joined: 2012-08-20, 16:39 UTC

Post by *herman5 »

MarcinW wrote:There shouldn't be any problem under old Windows versions. Documentation doesn't limit the title length. Also Delphi 5, which generates applications compatible with Win95, doesn't have such a limit:
Chris uses Delphi 2 and 3 not 5.
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW »

Yes, I know. So I pasted the piece of corrected code from Delphi 5, so he can replace the code in his Delphi 2.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I just increased the length of the variable from 32 to 260 characters in Delphi 2, and it seems to work fine.
Author of Total Commander
https://www.ghisler.com
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW »

Besides MAX_PATH, it's worth to add also space for "Total Commander - " prefix.
User avatar
white
Power Member
Power Member
Posts: 5815
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

Tested OK using TC 8.50b6 32bit and Windows XP.
Maximum length is now 259 characters.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Thanks!
Author of Total Commander
https://www.ghisler.com
Post Reply