Forum > General

Printer Paper Orientation

<< < (4/4)

J-G:

--- Quote from: paweld on August 17, 2022, 12:15:03 pm ---Attached to the previous post are the modified sources from which I removed the RadioGroup control.
--- End quote ---
Ah... apologies  -  I saw the reference to RadioGroup and made incorrect assumptions  :-[

--- Quote from: paweld ---In Printer.Title you specify the name of the report, not the name of the target PDF file.
Look in the attached example, in my case the report title is passed to the PDF printer every time.
--- End quote ---
That is exactly what I'm doing  -  ???

Your latest code works exactly as I wish and I can follow the logic which is exactly the same as mine - albeit more robust and handling bitmaps -  I've now written a small project (,ZIP Attached) which only deals with the creation of a box which can be modified and the orientation evaluated from the size created.  The size is adjusted dynamically using two TTrack Components. I haven't included tests to limit the dimensions other than they can both be between 1 & 297.

This still leaves the Printer.orientation and the filename untouched so shows exactly what I'm not getting.

It doesn't have 'SetAutoPageOrientation' and I can't see anything in your Code/Form which allows me to create such an [Event]  -  I can see that it is in the 'Public' section but I can't see it in the [Events] of any of your components. I have no idea how you created it so I can't (as yet) add it into my code for testing.

paweld:
'SetAutoPageOrientation' procedure is called each time the preview generate

J-G:

--- Quote from: paweld on August 17, 2022, 05:23:06 pm ---'SetAutoPageOrientation' procedure is called each time the preview generate

--- End quote ---
I can see that  -  what I can't see is how the procedure/event is created.

It's surely not simply 'typed' in?

Hmmm....  it is !!       since the Proc started 'TForm1.',   I had assumed that it was created by clicking on the [...] of an [Event] but I've just typed it into my test project and added the If...Then...Else structure - - - - which was already being called at each [Print]  - - - -  the project compiled without problem but it's had no effect on the problem so that isn't the solution.

Have you seen the result provided by my test project?  Do you get the same result?  ie. no filename at first run and orientation not being set.





paweld:
Move the print name and page orientation setting before calling BeginDoc;, and it will work, ie
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.PrintImgClick(Sender: TObject);Var  W : word;begin  with Printer do   try                            Title := F_Name+'.PDF';     if P_Orient = 'P' then       Orientation := poPortrait     else       Orientation := poLandscape;     BeginDoc;     with Canvas.Font do     ...instead of

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.PrintImgClick(Sender: TObject);Var  W : word;begin  with Printer do   try     BeginDoc;     Title := F_Name+'.PDF';     if P_Orient = 'P' then       Orientation := poPortrait     else       Orientation := poLandscape;     with Canvas.Font do   ...

J-G:

--- Quote from: paweld on August 17, 2022, 07:53:28 pm ---Move the print name and page orientation setting before calling BeginDoc;, and it will work,
--- End quote ---

D'oh!   --   I said that I must be missing a 'Magic Bullet'  !!

That's a day of both our lives that we won't get back  :D

However I have certainly learned quite a bit, and it may be that someone doing a search on this forum in the future may stumble across this answer which might save them some head-scratching.

Thanks for your efforts and tremendous patience in the face of my inability to really see how your Code differed from mine. I have spent the past hour going through not only your code line by line but even the settings of some of the components in the vain hope that I might see some difference.

Navigation

[0] Message Index

[*] Previous page

Go to full version