Page 1 of 2

Bug : PrintPreview v4.72

PostPosted: April 23rd, 2007, 9:25 pm
by akeix
Good evening,

I am French. Excuse me for my English.

PrintPreview does not take account of the orientation of paper to create file pdf.

In portrait, there is no problem.
In landscape, the PDF file is created in portrait.


I modified the SaveAsPdf function but that functions only on the first page.
Here modification:

Code: Select all
procedure TPrintPreview.SaveAsPDF(const FileName: String);
var
  I: Integer;
  Mem: TMemoryStream;
begin
  if dsPDF.Handle > 0 then
  begin
    dsPDF.BeginDoc(PChar(FileName));
    try



      if  FOrientation = poPortrait then
        dsPDF.SetPage(2, 0, 0, 0)
      else
        dsPDF.SetPage(2, 1, 0, 0);



      Mem := TMemoryStream.Create;
      try
        for I := 1 to TotalPages do
        begin
          if I > 1 then
            dsPDF.NewPage;
          Mem.Clear;
          Pages[I].SaveToStream(Mem);
          dsPDF.PrintPageMemory(Mem.Memory, Mem.Size);
        end;
      finally
        Mem.Free;
      end;
    finally
      dsPDF.EndDoc;
    end;
  end
  else
    raise EMissingPDFLibrary.Create('Cannot locate ' + dsPDF_lib);
end;



I am not an expert in Delphi. I make especially C or of C++.

I use the version demonstration of dspdf.dll.

Thank you for this component.

Akeix

PostPosted: April 23rd, 2007, 10:10 pm
by Kambiz
Thank you very much for informing this issue.

The problem is lack of documentation of dspdf. I'll contact the author for the correct usage of the functions.

PostPosted: April 23rd, 2007, 10:31 pm
by Kambiz
Hopefully it fixed easily.
The update is available to download.

Thank you!

PostPosted: April 25th, 2007, 4:48 am
by akeix
Hello,

I downloaded the new version of PrintPreview (4.73).
I looked at the modification which you made.
in fact, it was very simple. :D
I will have to think of it.

Thank you for this marvellous component.

Akeix

PostPosted: April 27th, 2007, 11:11 am
by DwrCymru
If anyone is interested I wrote a function that returns the "ps" value for some of the "TPaperType" used in the print preview.

Code: Select all
Function PaperTypeToPDFPageSize(Const PaperType : TPaperType) : Integer;
 begin

   Case PaperType of
     pCustom     : Result := 00;
     pLetter     : Result := 01;
     pLegal      : Result := 04;
     pExecutive  : Result := 11;
     pA3         : Result := 03;
     pA4         : Result := 02;
     pA5         : Result := 09;
     pB4         : Result := 08;
     pB5         : Result := 05;
     pFolio      : Result := 10;
     pEnvDL      : Result := 15;
     pEnvB4      : Result := 12;
     pEnvB5      : Result := 13;
     pEnvMonarch : Result := 16;

    else

       Result := 0; // Default to custom

   end;
end; // PaperTypeToPDFPageSize


in the "SaveAsPDF" I changed the "dsSetPage" to :

Code: Select all
dsPDF.SetPage(PaperTypeToPDFPageSize(PaperType), Ord(Orientation), PaperWidth, PaperHeight);


Feel free to use the code.

Dave

PostPosted: April 27th, 2007, 12:16 pm
by Kambiz
DwrCymru, thank you very much. I released version 4.74 of the component with your code.

PostPosted: April 27th, 2007, 2:01 pm
by DwrCymru
Your very welcome, the PrintPreview is a great component, keep up the good work. You can find more info on the VCL used in the DLL by going here : http://www.llion.net/llpdflib.php and there is also a trial version you can download which contains a help file describing the properties of the component.

All the best.

Dave

PostPosted: April 28th, 2007, 7:38 am
by akeix
Hello,

the library llPDFLib 3.6 is paying (299 $ for a licence!).

The DLL dspdf.dll is almost free because it is enough to send a postcard to its author to receive the full version.

This approach is closer to Kambiz which offers its components in freeware.

It is my opinion.

Cordially,

Akeix

PostPosted: April 28th, 2007, 9:02 am
by Johnny_Bit
In terms of money... Take a look at GNU Linux and all the tools that are in it (any major distro). You can get perfect PDF making tool with GNU license, that not only gives that for free, but also allows you to look at the source and/or change to make it work better for you.

PostPosted: April 28th, 2007, 4:33 pm
by DwrCymru
I agree with Johnny_Bit, why would anyone pay $299.99 for a piece of code when there are many alternatives out there with source code available for free, which you can then modify when you find it does not do what you want or has bugs in it that you need fixing ASAP.

You have to admire the author of "dspdf.dll" though for paying out all that money and then giving a needed functionality away for just a postcard.

Dave

PostPosted: April 28th, 2007, 6:12 pm
by akeix
Good evening,

I agree with you.

Cool still an improvement!

Cheer with Kanbiz and you all!

Akeix

PostPosted: May 3rd, 2007, 10:19 am
by beinars
Hi!

I'm new here and like this Print Preview component very much!

Very well written indeed.

I'm also using this dll, DSPDF.DLL

What I need is a address to whom I can send postcard to, as to get fully functional DLL.

All the best
Einarsson

PostPosted: May 3rd, 2007, 10:32 am
by HPW
Found at http://delphistep.cis.si/ in support:

Grega Loboda
Tuga Vidmarja 2
4000 KRANJ
SLOVENIA

PostPosted: May 3rd, 2007, 11:59 am
by beinars
HPW wrote:Found at http://delphistep.cis.si/ in support:

Grega Loboda
Tuga Vidmarja 2
4000 KRANJ
SLOVENIA


Thanks!

Did send him a card from my country Iceland, one with pics of our great waterfall, Gullfoss!

PostPosted: May 3rd, 2007, 2:28 pm
by Kambiz
beinars wrote:
HPW wrote:Found at http://delphistep.cis.si/ in support:

Grega Loboda
Tuga Vidmarja 2
4000 KRANJ
SLOVENIA


Thanks!

Did send him a card from my country Iceland, one with pics of our great waterfall, Gullfoss!

What about us? :D