Author Topic: Set page-size of Windows-printers via Autolisp  (Read 4354 times)

0 Members and 1 Guest are viewing this topic.

Peter2

  • Swamp Rat
  • Posts: 653
Set page-size of Windows-printers via Autolisp
« on: November 08, 2013, 06:17:24 PM »
I'm playing around with flexible, automated page-sizes which should be configured by Autolisp. One of my ideas (not solutions ...) is

- to add a special paper-size via "Windows - Printers - Print server propeerties - Forms" (sorry, if not correctly re-translated from German) and
- to modify the paper-size via Autolisp (vl-registry-write ...)

Now I have a registry-entry like this:
Code: [Select]
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Forms\PDF_Formatter]
"FormKeyword"=hex:7b,35,44,42,42,30,42,43,43,2d,43,43,46,41,2d,34,37,42,45,2d,\
  41,34,46,41,2d,45,41,35,44,32,39,41,46,36,33,32,32,7d,00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Forms]
"PDF_Formatter"=hex:d0,bf,0b,00,80,6d,0d,00,00,00,00,00,00,00,00,00,d0,bf,0b,\
  00,80,6d,0d,00,4c,00,00,00,00,00,00,00


Now the questions are:
a) Is the basic idea realisable? If yes - how to handle the registry?
b) Or are there better solutions?

Thanks and regards

Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

kruuger

  • Swamp Rat
  • Posts: 637
Re: Set page-size of Windows-printers via Autolisp
« Reply #1 on: January 08, 2015, 04:12:36 PM »
hi Peter
any luck with this ?

did anyone was able to add custom paper sizes via lisp ?
digging google all day but nothing  :(

thx
kruuger

Peter2

  • Swamp Rat
  • Posts: 653
Re: Set page-size of Windows-printers via Autolisp
« Reply #2 on: January 09, 2015, 03:25:34 AM »
hi Peter
any luck with this ?...
Hi kruuger

no success  :-(. I hoped to find a common way for all printers, but at least I found a special printer device with separate paper settings in the registry.
But no solution for the original question.
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

kruuger

  • Swamp Rat
  • Posts: 637
Re: Set page-size of Windows-printers via Autolisp
« Reply #3 on: January 09, 2015, 03:47:38 AM »
hi Peter
any luck with this ?...
Hi kruuger

no success  :( . I hoped to find a common way for all printers, but at least I found a special printer device with separate paper settings in the registry.
But no solution for the original question.
:( thanks for info Peter
kruuger

Didge

  • Bull Frog
  • Posts: 211
Re: Set page-size of Windows-printers via Autolisp
« Reply #4 on: January 09, 2015, 06:42:08 AM »
Hi Guys,

Although not a direct answer to defining page sizes through lisp, this option may offer a work-around.
I use a standard template file containing all my regular page setups for a multitude of different plotters, printers & PDF's etc.  This coding will then import a specified page setup from that template.
You will need to edit the "template" variable to point towards your own DWT file.

Hope that helps.
Didge.

Code: [Select]
; (SET-PAGE-SETUP "A3 PDF")
(defun SET-PAGE-SETUP (name / Get-Active-Doc Get-Setups PutPageSetup template f oldfiledia)
  (defun Get-Active-Doc (/) (vla-get-activedocument (vlax-get-acad-object)))
  (defun Get-Setups (/ ret)
    (vl-catch-all-apply '(lambda () (vla-RefreshPlotDeviceInfo (vla-get-Layout (vla-get-PaperSpace (Get-Active-Doc))))))
    (vlax-for x (vla-get-Plotconfigurations (Get-Active-Doc)) (if (= (vla-get-ModelType x) :vlax-false) (setq ret (cons (vla-get-name x) ret))))
    (if ret (setq ret (cons '"Current" (vl-sort ret '<))))
    (cond (ret) ('("Current")))
  )
  (defun PutPageSetup (layout setup / item-p)
    (defun item-p (collection item /)
      (if (not (vl-catch-all-error-p (vl-catch-all-apply '(lambda () (setq item (vla-item collection item)))))) item)
    )
    (and (setq layout (item-p (vla-get-layouts (Get-Active-Doc)) layout))
         (setq setup (item-p (vla-get-plotconfigurations (Get-Active-Doc)) setup))
         (not (vla-copyfrom layout setup))
    )
  )
  (setq template "C:\\TEMP\\STANDARD-PAGE-SETUPS.DWT")
  (if (not (vl-position (strcase name) (mapcar 'strcase (Get-Setups))))
    (if (setq f (findfile template))
      (progn
        (setq oldfiledia (getvar "filedia"))(setvar "filedia" 0)
        (vl-cmdf "-psetupin" f name)
        (setvar "filedia" oldfiledia)
      )
      (alert (strcat "Unable to locate template file: \n\n" template))
    )
  )
  (if (vl-position (strcase name) (mapcar 'strcase (Get-Setups))) (putpagesetup (getvar "ctab") name))
  (vl-cmdf "RegenAll")
  (princ)
)

Think Slow......

kruuger

  • Swamp Rat
  • Posts: 637
Re: Set page-size of Windows-printers via Autolisp
« Reply #5 on: January 09, 2015, 06:52:08 AM »
yes. that is workaround. probably will use it.
thanks Didge
kruuger


HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Set page-size of Windows-printers via Autolisp
« Reply #6 on: January 12, 2015, 04:50:42 AM »
Thanks Didge

blasto

  • Mosquito
  • Posts: 4
Re: Set page-size of Windows-printers via Autolisp
« Reply #7 on: July 07, 2015, 04:30:23 AM »
Hi Didge,

if possible can you send your dwt file?
thanks