Solved

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

Posted on 2004-09-17
18
338 Views
Last Modified: 2010-08-05
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?
0
Comment
Question by:Treppenmeister
18 Comments
 
LVL 1

Expert Comment

by:Chadak
Comment Utility
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
0
 
LVL 11

Expert Comment

by:robert_marquardt
Comment Utility
Probably 32767 x 32767 is the limit of the GDI. At least pixel positions are limited to to 32767.
0
 

Author Comment

by:Treppenmeister
Comment Utility
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.
0
 
LVL 4

Assisted Solution

by:MrJul
MrJul earned 50 total points
Comment Utility
This is a Windows limitation this Windows.pas is just a port from windows.h header, and then from the API.
It means you cannot modify this structure since Windows DLL will still use the old ones.
0
 
LVL 45

Expert Comment

by:aikimark
Comment Utility
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?
0
 

Author Comment

by:Treppenmeister
Comment Utility
@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?
0
 
LVL 45

Accepted Solution

by:
aikimark earned 450 total points
Comment Utility
Treating the plot like drawing a picture to a printer will not be a winning strategy for you, given it's 32K pixel/dimension limit.  From your most recent comment, it looks like you are creating your own commercial product and need to drive a variety of plotters from different vendors.

Here are some suggestions:
1. Choose an industry-standard interface, such as HPGL or HPGL/2, and only support plotters that support this industry standard language.
2. Purchase a commercial product or find freeware that will drive a variety of plotters.
3. Take advantage of software that (usually) comes with your users' plotters.
4. Think vector graphics, not raster graphics.
5. Support the plotters your customers currently own and add support for future plotters with future releases of your software.
6. Create a large (raster) graphics file on disk and launch a utility to convert it to HPGL format.

======================
Some helpful Delphi links:

TMMPlot (for viewing HPGL files)
http://www.programmersheaven.com/zone2/cat495/5845.htm
http://www.programmersheaven.com/d/click.aspx?ID=F5845

CADSoftTools
http://www.cadsofttools.com/default.aspx?PageName=All%20pages
http://www.cadsofttools.com/default.aspx?PageName=Converters
0
 

Author Comment

by:Treppenmeister
Comment Utility
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.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 45

Expert Comment

by:aikimark
Comment Utility
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.
0
 

Author Comment

by:Treppenmeister
Comment Utility
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?
0
 
LVL 45

Expert Comment

by:aikimark
Comment Utility
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?
0
 

Author Comment

by:Treppenmeister
Comment Utility
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.
0
 
LVL 45

Expert Comment

by:aikimark
Comment Utility
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.
0
 

Author Comment

by:Treppenmeister
Comment Utility
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.
0
 
LVL 45

Expert Comment

by:aikimark
Comment Utility
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.
0
 

Author Comment

by:Treppenmeister
Comment Utility
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.
0
 

Author Comment

by:Treppenmeister
Comment Utility
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.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video discusses moving either the default database or any database to a new volume.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now