Print Page | Close Window

how to let get GetPrinterDevModeToString printDi

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3820
Printed Date: 26 Apr 24 at 1:50PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: how to let get GetPrinterDevModeToString printDi
Posted By: mitchellhu
Subject: how to let get GetPrinterDevModeToString printDi
Date Posted: 12 Jun 20 at 3:19AM
1.DenbenuPdf library Version : DebenuPDFLibrary1211
2.Develop Tool : Delphi Xe2 update 4

Try to use GetPrinterDevModeToString to save Delphi TPrinterDialog setting;
but I found it is seem impossibe, because the Delphi TprinterDialg no any printsettings
variable to keep setting. 

I use QP.GetPrinterDevModeToString to keep the settings, but it seems get the default setting only,
so use use QP.SetPrinterDevModeFromString and QP.PrintDocument will get print PDf file size no as expected.

nomorely, a MS Excel file can be setup print size by its printsetupDialg , then print the right size as he/she need. so , I think Debenupdf library could do it correctly also, 
Please give some suggestion.
//P.S: Why Debenu/Foxit support system seems not working any more!!!



Replies:
Posted By: Ingo
Date Posted: 12 Jun 20 at 8:49PM
"...
Why Debenu/Foxit support system seems not working any more?
..."

There was another user few days ago telling about good contact with the support team.
For me it's the same... I send normal emails and i get an answer.
Perhaps you want to discuss a problem which can't be solved with QuickPDF?



-------------
Cheers,
Ingo



Posted By: mitchellhu
Date Posted: 17 Jun 20 at 12:31AM
Thanks for you replay.
I make a support on Foxit/Denbenu web last week, but still have no any replay from then.
I buy DebenuPdflibray1211 for Delphi form Denbenu. 
Before Denbenu merge into Foxit, Denbenu always help me to solve problem quickly , but even get a reply is impossible. 
sorry for my bad English ability, maybe I miss some contact information on the web site. 
please show me the correct way(mail) to contact them.

Thank you.


Posted By: mitchellhu
Date Posted: 17 Jun 20 at 3:24PM
try to some test , still not work.....I do not know why
=============================================================
//button1 : get the printer 'CutePDF Writer' DevMode data to AnsiString variable : DeModeString
=============================================================
procedure TForm1.Button1Click(Sender: TObject);
var
  QP : TDebenuPDFlibrary1211;
begin
  if PrinterSetupDialog1.Execute then // change the papersize form A4 to A2
  begin
    QP := TDebenuPDFlibrary1211.Create;
    DeModeString := QP.GetPrinterDevModeToString('CutePDF Writer');
    QP.Free;
  end;
end;

==============================================================
Button3: set newprinter('CutePDF Writer') and set DevMode data from AnsiString variable : DeModeString
==============================================================
procedure TForm1.Button3Click(Sender: TObject);
VAR
  QP : TDebenuPDFlibrary1211;
  printoptions : Integer;
  newPrinter : string;
begin
   QP := TDebenuPDFlibrary1211.Create;
   QP.UnlockKey('myregkey');
   QP.LoadFromFile(sFilenameEdit1.Text,'');
   printoptions := QP.PrintOptions(1, 0, 'test');
   newPrinter := QP.NewCustomPrinter('CutePDF Writer');
   QP.SetPrinterDevModeFromString(DeModeString);
   QP.PrintDocument(newPrinter , 1, 1, printoptions); //
   Qp.Free
end;
===========================================================
but the print out file size is A4 not A2

I do not know why?



Posted By: mitchellhu
Date Posted: 19 Jun 20 at 2:12AM
finally, I got contact with Foxit.
and they prove GetPrinterDevModeToString(MyPrinter) function contains a bug in QPL before version 18.11. also , they apply a alternative solution to get DeMode Sting as below:

var

  DevModeString: AnsiString;

  PrinterName: string;


procedure TForm1.btnGetDevModClick(Sender: TObject);

var

  MyPrinter, MyDriver, MyPort: array[0..255] of Char;

  DeviceHandle: THandle;

  DevMode: PDeviceMode;

  DevModeLen: Integer;

begin

  if PrinterSetupDialog1.Execute then

  begin

    Printer.GetPrinter(MyPrinter, MyDriver, MyPort, DeviceHandle);


    // This function contains a bug in QPL before version 18.11

    // DevModeString := QP.GetPrinterDevModeToString(MyPrinter);


    // Get the devmode string directly from the printer

    if DeviceHandle <> 0 then

    begin

      DevMode := GlobalLock(DeviceHandle);

      if (SizeOf(DevMode^) = DevMode^.dmSize) then

      begin

        DevModeLen := DevMode^.dmSize + DevMode^.dmDriverExtra;

        SetLength(DevModeString, DevModeLen);

        if (DevModeLen > 0) then

        begin

          Move(DevMode^, DevModeString[1], DevModeLen);

        end;

      end;

      GlobalUnlock(DeviceHandle);

    end;


    PrinterName := MyPrinter;

  end;

end;


procedure TForm1.btnPrintClick(Sender: TObject);

var

  CustomPrinter: string;

begin

  QP.SetPrinterDevModeFromString(DevModeString);

  CustomPrinter := QP.NewCustomPrinter(PrinterName);

  QP.DrawText(100, QP.PageHeight - 100, 'Top Left');

  QP.DrawText(100, 100, 'Bottom Left');

  QP.DrawText(QP.PageWidth - 100, 100, 'Bottom Right');

  QP.DrawText(QP.PageWidth - 100, QP.PageHeight - 100, 'Top Right');

  QP.PrintDocument(CustomPrinter, 1, 1, QP.PrintOptions(1, 0, 'My Doc'));

end;

so, case close.
Thanks for Ingo's replay , let me try to contact to again and again . Ha! Ha!
finally...... Foxit/Debenu still good as usual!





Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk