Link to home
Start Free TrialLog in
Avatar of Treppenmeister
Treppenmeister

asked on

How to print within a delphi application longer than 3.2 metres?

I want to print a graphics on a plotter. The plotter is supporting a printing range of 50 metres. I am using Delphi 7.

Since I don't want to waste paper I set the paperlength through PDeviceMode.dmPaperLength - but unfortunately the unit windows delivered with Delphi 7 is using shortint which means that I am limited to a printing area of 32767 x 32767 tenth mm. So the printing area is limited to approx. 3,27 x 3,27 m.

Any idea how I can change this? Has Delphi 8 a support of integer for the DeviceMode.dmPaperLength ?

Or is the limitation set by Windows?
Avatar of Chadak
Chadak

Hi!

     Just a guess, maybe you could hack the printer class to pass a integer isntead of a small int, but i'm not sure if the printer dirver will accept this ( guess every printer driver might not have the same reaction ).

   Or anyway if you use that kind of printer, they must have post-script support, so post-script would be the best to use.

Chad
Probably 32767 x 32767 is the limit of the GDI. At least pixel positions are limited to to 32767.
Avatar of Treppenmeister

ASKER

In the printer driver I can set for the paper size a user size with a maximum length of 16 m.

But when I set the size of the printing area within of Delphi (since only within the application I know how the dimensions of the graphics will be), then I get that dilemma.

1) I could tell the user, that the printing job will have a size of 4,2 m and he has to set it manually - how userfriendly :( !
2) I can use predefined sizes - let's say 5 m length. But the result will be that all print outs will be 5 m long - uninteresting whether 80 cm would be enough or not.
3) I could ignore the papersize the plotter tells me and just print out what I want - in the hope that the plotter will recognize the size by itself (this is not very professional)

None of these ways is one I would prefer.
Did anyone patched already successfully the printers class?

@chadak:
The plotter does not understand postscript. It is a cutting-plotter - this means, that I can define a colour which will be the cutter and so I can cut out the template after printing it.

Another problem is at the moment still, that the printer driver does not await, that somebody wants to print on a negative length (when I want to set the size to 4.27 m , then the printer class sets it to -1.00) - and the printer driver interprets it wrong and tells me, that the printing area is something more than 1.6 km. While using that printing area the plotter is crashing and has to be switched off. But next Monday I will have a talk with the driver support team.
SOLUTION
Avatar of MrJul
MrJul

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aikimark
How about talking directly to the plotter driver instead of going through the Windows device drivers?

How about streaming the control codes to the plotter device?

Does the plotter vendor support a high-level language interface or OLE/ActiveX control or system object?
@akimark:
The windows device drivers would have the advantage, that i could use them universal - uninteresting which plotter or printer is in use.

If there is a special way to communicate with the cutting plotter from vendor 1, then there is certainly a second one with another plotter from vendor 2. To support this will cost a lot of time. And no customer is willing to pay for this. The plotter vendor is promising that the plotter can print till a maximum of 40 m (also when i can set the length within the driver only for max. 16 m). And if our application does not suppprt it, then it is our fault and not the support from the printer vendor. At least in the eyes of the customer.

What do you think about the following trick:
Print out all in a 1:2 scale and let the plotter scale all to 200%. It is a technical drawing I want to print out - the plotter has a resolution of 284 dpi. Could something like this work?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Unfortunately the plotter vendor couldn't help me. They only said that they are sorry for the problems I have and that I should use third party software. They also meant that the way via HPGL would not work, since there would be the same limitations.

The crazy thing is that I can print out more than 3.27 m. I (the user) only have to set the desired plotting area within the plotter driver menu. I can define there user specified sizes. And when I define there a plotting area of 5000 mm x 800 mm then I can print 5 x 0.8 m. But the problem is, that I have to set this for every printing task indivudually.

So the PageWidth and the PageHeight (in the printers.pas) are integers. And the plotting area can be bigger than 32k by 32k.
Only the PDeviceMode.dmPaperLength (in the windows.pas) are shortint.

I conclude that I am only limited by setting the size.
then it seems like you should be able to make a few registry calls to set the size of your plotting area programmatically prior to starting the plotting process.
I found now where in the registry the information is hidden. But I have the following problem:

This is okay:
1) Open printdialog within the application
2) Length is 40000
3) close printdialog
4) edit registry from 40000 to 42000
5) Open printdialog
6) Length is 42000

But:
1) Open printdialog within the application
2) Length is 40000
3) start printing
4) edit registry from 40000 to 42000
5) cancel breaking within application
5) Open printdialog
6) Length is 40000

7) restart application
8) Open printdialog within the application
9) Length is 42000


As soon as I started the printing the value (binary) in the registry has no effect anymore. I have to restart the application.
Is this a normal behaviour? Any ideas?
Of course this is normal behavior.  That is why I wrote "...prior to starting the plotting process."

The registry is read by the vendor's plot engine at the start of the process.

Question: Is the print dialog your form or the form produced by the vendor's software?
We are using the standard tprintdialog of Delphi. The user is choosing the printer and after that we are opening an own dialog to choose for which parts of a stairs the user wants to plot a template.
E.g. he decides to plot out all hand-rails. Then it is possible that 1st hand-rail is 120 cm long, the 2nd 434 cm and the 3rd 278 cm long. Before the printing we have to tell the plotter the size of the plotting area. (otherwise there is too much paper wasted)
As long the templates are smaller than 327 cm I can set the size by Paperlength.
For bigger sizes I could edit the registry - but I have then the above mentioned behaviour. I mean - no chance to use it really.


I know that another application for designing stairs had the same problem, but finally solved it. So there has to be a way.
How about ending the document between different sized plots?
If the actual device doesn't have a method for that (Printer.EndDoc;), I think there is a Windows API you can invoke.
We use begindoc / enddoc for every  single plot. With before the printing I meant 'before every single plot'. That works fine as long we stay within the mentioned 3.27 m plotting area.
Here are a couple of ideas:
1. programmatically iterate through all the printing devices and allow the user to choose the plotter from your dialog, thus eliminating the (separate) Windows printer selection dialog.

2. allow the user to select multiple items for plotting and set the plotter size to accomodate the total plot areas.
I don't know whether I was not clear enough or whether I do not understand you.

In our application the user is selecting his standard printer (not the windows standard printer) for every type of printing. When we start the printing job, then the delphi/windows - printing dialog will be opened (just in case the user want to change the standard). After that the user can decide which items he wants to print out.

At the moment we print out every item separately. We could theoretically also print two or more items an one printing canvas. But the maximum length from plotter to plotter is different. And at the graphtec plotters (the ones where we have the problems now) you set the maximum printing length on hardware side. The standard which is used is 6 m.
Let's look at the above mentioned 3 handrails - 120 / 278 / 434 cm
I could design two printing jobs - one with the handrail 1+2 and one with the 3. I could set then the printing length manually to 440 cm. And I waste only one time about 40cm. But there are many many items to print and in the most cases separately. So this is not a solution. The printing job will be done partly over night. So a manually setting of the length is not always possible.

The best advice I got till now was to print out at a scale of 1:2 and let the plotter scale the plot by 200%.

But perhaps I do have an understanding problem. Unfortunately we do not have a graphtec plotter here for testing and all what I do is 'talking' with the printer driver. By the way - the plotter is a pen-plotter.

I have  for instance also the problem, that HP plotters do not 'listen' to me. And I cannot set the paperlength automatically. They just ignore the settings.
I am in a dilemma. The answers helped me a little bit - but they are not the real answer to my question. I have still the problem I mentioned - but perhap there is no solution. Since I am forced to close this question I will give the points to the person who helped me most.