DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Setting PrintHeight with Script

I would like to use DIAdem (v10.1) to generate PDF's via script.  I think I have the basics, but have a problem when it comes to printing a Letter-sized page in landscape orientation.  Starting with a new instance of DIAdem, I can find that PrintWidth = 10 (inches) and PrintHeight = 17 (inches).  I then go about setting the printing and layout parameters for a landscape, letter-sized printout.  I want to use the entire page for printing.  Here is a code snippet that illustrates the problem:

 'Initial probes show DIAdem starts with PrintWidth = 10 and PrintHeight = 17
  PrintWidth  = 8.5 'inches, letter-size page width
 'PrintHeight = 11.0 inches, but this is a Read-Only variable
  PicRatio    = 11.0 / PrintWidth ' because PrintHeight = PrintWidth * PicRatio

  PrintName   = "winspool,DIAdem PDF Export,LPT1:"
  PdfFileName = "C:\test.pdf"
  Call PicPrint("WinPrint")
' if use PicPrintDlg and Cancel the dialog,
                            ' PrintHeight gets set correctly
 
  PrintHeight   '<< probe here to see if PrintHeight gets set


Please keep in mind that the above code is not to show printing a page in landscape, but simply to show setting of the PrintHeight variable which seems to be used for landscape printing (but not for portrait?).  In any case, if you run this code with a breakpoint and stepping through, you'll see that the only way that PrintHeight gets set is by calling a dialog version of PicPrint (even cancelling the dialog still sets PrintHeight).



0 Kudos
Message 1 of 7
(3,957 Views)

Hi James,

I was able to reproduce your problem on my DIAdem 10.1 with your code.  I was not able to identify a simple parameter change to fix your code, though I tried a good bit.  What I was able to do is get the result you are after with the PicPDFExport() command.

PrintLeftMarg = 0.0
PrintTopMarg  = 0.0
PrintWidth    = 11.0
PicRatio      = 8.5/PrintWidth
PrintOrient   = "landscape"
PDFFile = "C:\test.pdf"
Call PicPDFExport(PDFFile)

Let me know if this doesn't do what you want,
Brad Turpin
DIAdem Product Support Engineer
National Instruments

0 Kudos
Message 2 of 7
(3,943 Views)
Brad -

The short answer is that the PicPDFExport command does generate the landscape PDF, but does not allow as much layout control - e.g., setting margins - but I think I will have to live with it for the time being.

My layouts are using relative positioning based around an absolute page size.  They anticipate that the report worksheet will translate 1:1 to the printed page, so I have to mess a little with the margins to account for the preset ones that PicPDFExport uses.  It shouldn't be much of a problem, but is there a way for me to determine the minimum margins used by this function?

Thanks!

James Brunner
Summitek Instruments
0 Kudos
Message 3 of 7
(3,938 Views)

I'm having the exact same problem.

I found a solution in another thread, as posted by "Twigeater".

Add a call to PrintMaxScale just before the Call PicPrint("WinPrint").

It fixed my issue.

Message 4 of 7
(3,769 Views)
jbrandim -

Thanks for the idea, however this still doesn't work for me.  I may not be understanding completely, perhaps you could post a simple example?

While playing a bit more (now with DIAdem 10.2) I find that the PrintMaxScale() simply uses the current print settings rather than those set within the script.  It seems the only way to get the print settings (e.g. File > Print... on Report tab) set to those called in the script is to call PicPrintDlg().  Unfortunately my script should run unattended, so I cannot tolerate the dialog.

Using PDFExport() is a poor substitute as it is not very flexible as far as printing ranges, setting page/margin sizes, etc.

James
0 Kudos
Message 5 of 7
(3,603 Views)
My script must also run unattended.  Here is a sample that shows how I generate PDFs.
This works for me...
'---------------------------------------------------------------------------------
  PdfFileName = "C:\HDF\LandscapeTest.pdf"
  Landscape = True
 
  PrintName = "windspool,DIAdem PDF Export,LPT1:"
 
  If Landscape Then
    PrintLeftMarg    =0.23
    PrintTopMarg     =0.23
    PrintWidth       =10.51
    PrintOrient      ="landscape"
  Else
    PrintLeftMarg    =0.23
    PrintTopMarg     =0.23
    PrintWidth       =8.01
    PrintOrient      ="portrait"
  End If
  Call PrintMaxScale
  Call PicPrint("WinPrint")
'---------------------------------------------------------------------------------
0 Kudos
Message 6 of 7
(3,595 Views)
Thanks for the example, I can see now what's happening and perhaps explain things a bit better.

To get a quick idea of what I am trying to do, use your example, but set it to print on a 3"h x 5"w page.  Try to get a rectangle page border set within the page at exactly 0.75 inch margins.

First, the PrintMaxScale() function behaves as the "Min. Borders" button in the File > Print... dialog on the Reports tab.  This is not very useful if you want direct control of the page layout regardless of the eventual output device.  It still seems to be a useful backdoor, however, when coercing the PrintHeight.

I want to be able to generate PDF's for various layouts besides standard paper sizes.  I want exact control over page size and margins (sometimes assymetric around the page).  I did not like to use the PDFExport() function as it uses fixed margins which cannot be easily compensated to give the resulting exact margin.  These built-in margins also seem to depend upon the page orientation (!).

The most precise technique I have found uses the PicPrint() or PicPrintNoDlg().  I set the page size and margins accordingly, but have found that the PageHeight does NOT get set properly without using the dialog version of the functions.  This of course wreaks havoc with the final output.

Still, your idea to use the PrintMaxScale() function does have some use because it will force changes to the PrintHeight variable without resorting to a dialog call.  The trick is to make the call after setting the PicRatio and PrintOrient, but prior to setting PrintWidth, PrintTopMargin, and PrintLeftMargin.

In any case, I appreciate the discussion, and am always keen to hear others' experiences with the intricacies of DIAdem.

James
0 Kudos
Message 7 of 7
(3,574 Views)