View Full Version : Open PDF file from ACAD
mvsawyer
2010-11-15, 07:56 PM
Is there a command that will allow me to open up a PDF file from autocad similar to the "EXPLORER" or "NOTEPAD" command? I notice when using these commands that a DOS(?) window quickly pops up and disappears.
BlackBox
2010-11-15, 08:23 PM
Here's what I use to open our CTB documents. This detects which version of AutoCAD is being used, then opens the appropriate document, as it relates to that version (each has a different standard):
(defun c:CTB ()
(vl-load-com)
(cond (*vrsn*)
((setq *vrsn* (vlax-product-key))))
(cond
((vl-string-search "R16.2" *vrsn*) ; 2006
(startapp
"C:\\Program Files\\Adobe\\Reader 8.0\\Reader\\AcroRd32.exe"
"FilePath\\FileName.pdf"))
((vl-string-search "R17.2" *vrsn*) ; 2009
(startapp
"C:\\Program Files\\Adobe\\Reader 8.0\\Reader\\AcroRd32.exe"
"FilePath\\FileName.pdf"))
(T (alert "This Version of AutoCAD Not Supported. ")))
(princ))
Hope this helps!
mvsawyer
2010-11-15, 08:37 PM
using your code I can get Adobe to open but get an error stating the file cannot be found. I've copied the file in the same folder as the adobe executable. Anything I'm doing wrong here?
(defun c:NEC ()
(startapp "C:\\Program Files (x86)\\Adobe\\Acrobat 8.0\\Acrobat\\Acrobat.exe"
"C:\\Program Files (x86)\\Adobe\\Acrobat 8.0\\Acrobat\\NECH08.pdf")
(princ)
);eof
mvsawyer
2010-11-15, 08:43 PM
I moved the file to the C drive and it worked...Can't imagine what the problem is. Thanks for your help.
mvsawyer
2010-11-15, 08:52 PM
Rookie Lisper mistake. I forgot to enclose the file name in quotes since it has spaces in it.
(defun c:NEC ()
(startapp "C:\\Program Files (x86)\\Adobe\\Acrobat 8.0\\Acrobat\\Acrobat.exe"
\""C:\\Program Files (x86)\\Adobe\\Acrobat 8.0\\Acrobat\\NECH08.pdf\"")
(princ)
);eof
jaberwok
2010-11-15, 08:56 PM
Just in case anyone cares -
you can open any document with its registered application from within acad.
Do File\Open and type *.* or *.doc or *.pdf in the filename box. Navigate to the file, right-click and select Open.
rkmcswain
2010-11-16, 06:08 PM
Is there a command that will allow me to open up a PDF file from autocad similar to the "EXPLORER" or "NOTEPAD" command?
If you want to open the PDF using the registered application, regardless of what might be installed, then take a look at this: http://cadpanacea.com/node/22. This way you avoid trying to guess what program might be installed, and where it's installed, etc.
If you insist on specifically opening Adobe as shown above, then you might want to consider using the %programfiles% variable so don't have to guess (or test for) \Program Files vs. \Program Files (x86)
mvsawyer
2010-11-16, 06:14 PM
I knew there was a way to use the shell like explorer or notpad does. Great link rkmcswain. Thanks alot!
BlackBox
2010-11-16, 09:56 PM
If you want to open the PDF using the registered application, regardless of what might be installed, then take a look at this: http://cadpanacea.com/node/22. This way you avoid trying to guess what program might be installed, and where it's installed, etc.
If you insist on specifically opening Adobe as shown above, then you might want to consider using the %programfiles% variable so don't have to guess (or test for) \Program Files vs. \Program Files (x86)
The code posted above was explicit, as all CAD users had that specific version installed. My region's offices are in transition right now to our new systems (servers, applications, directory structures, etc.) and this will come in handy as we move ahead.
Thanks for sharing RK, cheers! :beer:
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.