TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Lee Mac on August 18, 2010, 02:38:33 PM
-
I found this:
http://livedocs.adobe.com/acrobat_sdk/9/Acrobat9_HTMLHelp/wwhelp/wwhimpl/js/html/wwhelp.htm?&accessible=true (http://livedocs.adobe.com/acrobat_sdk/9/Acrobat9_HTMLHelp/wwhelp/wwhimpl/js/html/wwhelp.htm?&accessible=true)
which has a reference for using OLE Automation, but I'm not sure if its possible through VL?
Any advice is appreciated.
Lee
-
I not sure i understand the question.
> ... I'm not sure if its possible through VL?
i doubt it. What would you want to?
http://livedocs.adobe.com/acrobat_sdk/9/Acrobat9_HTMLHelp/Overview_GettingStarted.3.10.html
-
ah, just noticed the title said: "Adobe reader". ...my answer "doubt it" changes to "nope".
-
Print PDF's mostly... but I don't really know where to start :|
-
wild guess, sir:
... get the interface (vla-getinterface ...)
... get the property documents
... open the doc required for print
... invoke the print method
... close the doc
... in between that there must be a way/method to set the printer, etc.
... to see all the methods and properties exported - maybe a import the table library via vlisp too, add your prefixes and then in the apropos search for those prefixes...
very mickey mouse help, but better than nothing. :)
-
Thanks Luis, that's the way I was visualising it, but I can't seem validate any of the objects listed in the SDK reference - so perhaps it can't be done...
-
<snip>
Adobe Reader does not support OLE.
Same link as what i posted before.
http://livedocs.adobe.com/acrobat_sdk/9/Acrobat9_HTMLHelp/Overview_GettingStarted.3.10.html
-
<snip>
Adobe Reader does not support OLE.
Same link as what i posted before.
http://livedocs.adobe.com/acrobat_sdk/9/Acrobat9_HTMLHelp/Overview_GettingStarted.3.10.html
Ok - so next logical question: Can you print PDF's without using AdobeReader?
-
That is a very vague question (how long is a string) but Im gonna say: sure. However, you should know that you're traveling down a rabbit hole because printing isnt a simple or consistent task.
Methods:
1. Ghostscript
2. Windows (binary copy to port or network)
3. redmon
4. ...
Now whichever method you choose will give you X results and if you choose another method you can get Y results (and that is with one TYPE of PDF file). -i.e. if you use Windows port: "xcopy /B mypdf.pdf //lpt1" may work with this (let's say an HP Laser jet) printer and give you X results because the PDF driver (version 1.?) on the printer uses HPGL only and not PS. OR if you use Ghostscript to send a PDF to a windows printer it will only send Postscript PDFs this way with these results.
So my question is: can you print a PDF without Adobe Reader (And BTW, Adobe reader--if you were to open the file and hit the print button--will print a file differently too.)?
What kind of PDF are you printing (PS--binary or text--or HPGL)?
EDIT: Fixed wording error.
-
One way that I can think of is use lisp to attach the PDF to a CAD File, then plot the cad file. I know it's a round about way to get there, but it should work.
-
Hi
With PdfCreator ?
(setq pdf (vlax-create-object "PDFCreator.clsPDFCreator"))
I never work with him
@+
-
That is a very vague question (how long is a string) but Im gonna say: sure. However, you should know that you're traveling down a rabbit hole because printing isnt a simple or consistent task.
Methods:
1. Ghostscript
2. Windows (binary copy to port or network)
3. redmon
4. ...
Now whichever method you choose will give you X results and if you choose another method you can get Y results (and that is with one TYPE of PDF file). -i.e. if you use Windows port: "xcopy /B mypdf.pdf //lpt1" may work with this (let's say an HP Laser jet) printer and give you X results because the PDF driver (version 1.?) on the printer uses HPGL only and not PS. OR if you use Ghostscript to send a PDF to a windows printer it will only send Postscript PDFs this way with these results.
So my question is: can you print a PDF without Adobe Reader (And BTW, Adobe reader--if you were to open the file and hit the print button--will print a file differently too.)?
I take your point about using different programs to print the PDF, I just wondered if there was another way to bypass the reader and just print the file (programmatically of course) - but I haven't spent too much time outside of the comforts of AdobeReader and so would be stabbing in the dark using the other programs/methods that you recommend.
What kind of PDF are you printing (PS--binary or text--or HPGL)?
I've never heard of HPGL and will google it momentarily, but I believe I am printing PS (PostScript?)
-
One way that I can think of is use lisp to attach the PDF to a CAD File, then plot the cad file. I know it's a round about way to get there, but it should work.
Hmmm... I'd rather not go this route - I don't particularly want to mess around with the PDF file too much :|
-
Hi
With PdfCreator ?
(setq pdf (vlax-create-object "PDFCreator.clsPDFCreator"))
I never work with him
@+
Thanks Patrick, I'll be sure to look into that. :-)
-
Wait a minute. What do you mean by "print"? Do you mean: "Create"?
I'm talking about an actual physical piece of paper. The PDF file nor the printing of it has anything to do with Adobe Reader. Adobe Reader only displays the PDF on your screen.
-
I should probably be clearer (need to reread 'How to ask questions...')
To clarify: I am looking for a way to print a PDF file (to paper) programmatically so that I may print multiple PDF files automatically. I felt the easiest way to do this would be through something I already know: Visual LISP. However, having hit a few obstacles I'm open to ideas.
Lee
-
However, having hit a few obstacles I'm open to ideas.
Get out of vlisp (forgood)(donotstayinthereandsomehowwasteallthetalentyouhaveandhaveshownonallyourposts) - jump into another language - C# can be good for you.
My two pesos - HTH
-
I completely agree - and I've dabbled... but its just so easy to slip back into the nice and easy world of LISP/VLISP... :-(
-
have you tried: "xcopy /B mypdf.pdf //<some port>" or "xcopy /B LPT1" ?
Open a command prompt and type: "net help use"
...
get LPT1 pointed at some printer.
...
you're done.
-
How about a spooler. A folder where files should be dropped and then sent immediately to printer? Checkout http://www.lerup.com/printfile/ it's interesting.
v.
-
How about a spooler. A folder where files should be dropped and then sent immediately to printer? Checkout http://www.lerup.com/printfile/ it's interesting.
v.
Welcome to theSwamp.
That looks like a fancy version of Redmon. Cool find.
I would imagine that the type of file will still lead to problems -i.e. file of not type: Text, PS, EPS, etc. but may be a viable solution non the less.
-
I completely agree - and I've dabbled... but its just so easy to slip back into the nice and easy world of LISP/VLISP... :-(
I did some code in C++/ATL some time ago for a comercial product using this: PDF-XChange PRO 3 SDK by Traker Software - www.docu-track.com.
Also, found some info for you:
http://www.codeproject.com/KB/cpp/ReaderWrapper.aspx
(John have commented already about the unstable COM access)
http://vidmar.net/weblog/archive/2008/04/14/printing-pdf-documents-in-c.aspx
And this one:
http://aspalliance.com/514_CodeSnip_Printing_PDF_from_NET.all
-
have you tried: "xcopy /B mypdf.pdf //<some port>" or "xcopy /B LPT1" ?
Open a command prompt and type: "net help use"
...
get LPT1 pointed at some printer.
...
you're done.
Would this be run through the command prompt? (Sorry for obvious questions).
-
I did some code in C++/ATL some time ago for a comercial product using this: PDF-XChange PRO 3 SDK by Traker Software - www.docu-track.com.
Also, found some info for you
Thanks Luis, I'll be sure to have a look around :-)
-
have you tried: "xcopy /B mypdf.pdf //<some port>" or "xcopy /B LPT1" ?
Open a command prompt and type: "net help use"
...
get LPT1 pointed at some printer.
...
you're done.
Would this be run through the command prompt? (Sorry for obvious questions).
I dont understand?
if the xcopy method works...
(startapp (strcat "xcopy /B " (getfile) " //LPT1"))
Why dont you explain what you have and what you want to do.
-e.g. I would like to send the PDFs created in this office to a HP laser jet 8150 Plotter.
The PDFs we make are made through a program called: PDF995.
This would give us much more information then we are getting (right now your not really telling us anything). Those two sentences would tell us:
1. the PDFs are created in house (no surprises) with the same standards.
2. the PDFs are a Postscript type of PDF (PDF995 uses Ghostscript).
3. the Plotter has both a PS and an HPGL driver (I can look it up on the HP website).
Right now i can only assume that you are either creating a fancy routine to post in the show your stuff forum or you are doing this as a request. Both of those situations are going to be trouble for you because PDFs are not really a "standard" thing (there is a bunch of different programs that create them and they all have their own methods--the PDF file format is very "loose" so to speak) and you will get a bunch of bug fixes.
Look, its this simple: If you have a Postscript type PDF (created with Ghostscript, PDF995, PDFCreator, etc) and your plotter has a PS driver, either send the file via a windows XCOPY or have Ghostscript or Redmon send the file for you. If you have an HPGL type of PDF then use the software that created it (Kip request, Oce reprodesk).
You can issue the XCOPY command to windows or call Ghostscript like the above example.
-
have you tried: "xcopy /B mypdf.pdf //<some port>" or "xcopy /B LPT1" ?
Open a command prompt and type: "net help use"
...
get LPT1 pointed at some printer.
...
you're done.
Would this be run through the command prompt? (Sorry for obvious questions).
I dont understand?
if the xcopy method works...
(startapp (strcat "xcopy /B " (getfile) " //LPT1"))
I didn't properly understand your post either: I've never used the 'xcopy' method, and your previous post gave little information on how to run it - hence my question.
Why dont you explain what you have and what you want to do.
-e.g. I would like to send the PDFs created in this office to a HP laser jet 8150 Plotter.
The PDFs we make are made through a program called: PDF995.
This would give us much more information then[sic] we are getting (right now your not really telling us anything). Those two sentences would tell us:
1. the PDFs are created in house (no surprises) with the same standards.
2. the PDFs are a Postscript type of PDF (PDF995 uses Ghostscript).
3. the Plotter has both a PS and an HPGL driver (I can look it up on the HP website).
The PDF's are all created using the same PDF creator and are all of Postscript type - I'm not sure of the Plotter, but would assume it has a PS driver.
Right now i can only assume that you are either creating a fancy routine to post in the show your stuff forum
Not the case.
or you are doing this as a request. Both of those situations are going to be trouble for you because PDFs are not really a "standard" thing (there is a bunch of different programs that create them and they all have their own methods--the PDF file format is very "loose" so to speak) and you will get a bunch of bug fixes.
This is to help in my summer job in which many PDF's are plotted, so I am looking for a quicker way to do it.
Look, its this simple: If you have a Postscript type PDF (created with Ghostscript, PDF995, PDFCreator, etc) and your plotter has a PS driver, either send the file via a windows XCOPY or have Ghostscript or Redmon send the file for you. If you have an HPGL type of PDF then use the software that created it (Kip request, Oce reprodesk).
You can issue the XCOPY command to windows or call Ghostscript like the above example.
Now that you have demonstrated how to go about using XCopy, I shall have a go at that which you describe.
-
awesome.
You can call many command line apps that way. Here is just one example:
http://www.theswamp.org/index.php?topic=14793.0
Here are tons of command line apps for you to use.
http://gnuwin32.sourceforge.net/packages.html
HTH
-
Many thanks Se7en, you have been a great help :-)
I'll be sure to let you know how I get on :-)
-
As an update on proceedings...
I looked into the XCopy function here:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/xcopy.mspx?mfr=true (http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/xcopy.mspx?mfr=true)
But there doesn't seem to be a "/B" option, as you demonstrate - I haven't as yet tried your suggestion, but upon reading the docs on XCopy: is it not just for copying files?
I also looked into the ShellExecute function, under the iShellDispatch2 object
http://msdn.microsoft.com/en-gb/library/bb774148%28v=VS.85%29.aspx (http://msdn.microsoft.com/en-gb/library/bb774148%28v=VS.85%29.aspx)
I have seen a couple of VB examples that use this method to silently print PDF's, but I either cannot get the arguments correct, or I get an error referring to file associations :-(
-
Lee,
To bad my printer is not working, so can't really test it... but just tried and appears to (work?):
(startapp "C:\\Program Files\\Adobe\\Reader 9.0\\Reader\\AcroRd32.exe /t /h C:\\Test.pdf")
Do not know if you have something like the above line...
-
Luis, what are the '/t' and '/h', and how do these control the Adobe Reader? i.e. how did you know to use them?
-
Have a look here: http://www.robvanderwoude.com/commandlineswitches.php#Acrobat
-
Many thanks! 8-)
-
http://support.microsoft.com/kb/158081
-
http://support.microsoft.com/kb/158081
I see - thanks John.
-
Lee,
To bad my printer is not working, so can't really test it... but just tried and appears to (work?):
(startapp "C:\\Program Files\\Adobe\\Reader 9.0\\Reader\\AcroRd32.exe /t /h C:\\Test.pdf")
Do not know if you have something like the above line...
Upon first testing, this appears to work! :-) Many thanks Luis :wink:
And a big thank you to everyone else who has contributed to this thread, much appreciated indeed - I have learnt a lot.
-
Luis, what are the '/t' and '/h', and how do these control the Adobe Reader? i.e. how did you know to use them?
By implementing the T&E technology on a 80% - other 18% some reading about line parameters - and the last 2% tried two combinations in lisp with the startapp.
Now seriously, did a search on the net, with [AcroRd32.exe command line parameters] and noticed the parameters others have used, and started from there.
Now, does it work? :)
-
Now, does it work? :)[/size]
Indeed it does :-)
-
Now, does it work? :)[/size]
Indeed it does :-)
Good :)
added:
The /t switch-option is an undocumented feature that causes the document to be printed with no prompting dialogs or user input required.
The /h = hide
AFAIK...
-
on-line help (http://livedocs.adobe.com/acrobat_sdk/9/Acrobat9_HTMLHelp/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Acrobat9_HTMLHelp&file=DevFAQ_UnderstandingSDK.22.31.html)
-
Thanks again guys :-)
-
Some good news, some bad.
Just tried this at work and got mixed results -
The reader window is opened for each document printed and each document is added to the print queue - then the reader window is closed (all except one window).
However, only the first document is actually printed - I get a timeout error for the rest:
ERROR: timeout
OFFENDING COMMAND: timeout
STACK:
0
-mark-
-mark-
-mark-
/DecodeABC
-dictionary-
-dictionary-
/CIEBasedABC
-mark-
/N10
-savelevel-
The printer is a HP Color LaserJet 5550 PS on a network.
I have also used a delay in the code of around 1.5 secs (using delay command) - but whatever delay is used, it seems to have no effect on the outcome.
We are using Adobe Acrobat 7.0 (but the reader file is still the same: AcroRd32.exe).
Any help is immensely appreciated, if you need more info, just ask.
Lee
-
I recommend *not* using Acrobat.
I recommend using either Ghostscript, Redmon, or Windows copy function (i recommended only these tools for a reason). Choose a method and find the syntax you need to use. Make sure the tool you decide is in the Windows PATH environment variable. Use the STARTAPP function in Auto Lisp.
I recommend that you open a command prompt in windows and start typing in things like:
path ;; <-- will list the windows path env var
copy /? ;; <-- help for the COPY command
net help use ;; <-- help for the NET USE command
Use google to find out what LPT1 is and use NET HELP USE to find out how to set LPT1 or just deal with the UNC path.
Good luck.
-
Many many thanks Se7en for your direction :-) I read up on copy and net help use and also found this which was quite helpful:
http://support.microsoft.com/kb/314499 (http://support.microsoft.com/kb/314499)
-
Good, now you know how to set one of the LPT ports... what's next (what method are you going to use)?
Did you look up Ghostscript, Redmon, or Windows Copy? What is the difference (what way will using Ghostscript to send a file vs using windows Copy differ)?
-
I didn't look up Ghostscript or Redmon, but would rather focus on the Windows side of things as this is for work and so I probably won't be able to use too many external applications.
I was thinking of using the second method as shown on that MSoft page - using the MSDos print function with "/d:\\printserver\\printername", but I'm not sure whether this would actually print PDF's as it says only for use with ASCII files :|
Lee
-
I didn't look up Ghostscript or Redmon, but would rather focus on the Windows side of things as this is for work and so I probably won't be able to use too many external applications.
Then why were you trying to use Acrobat Reader (What im saying is that your statement doesn't make a whole lot of sense to me but...)?
I was thinking of using the second method as shown on that MSoft page - using the MSDos print function with "/d:\\printserver\\printername", but I'm not sure whether this would actually print PDF's as it says only for use with ASCII files
You are correct; it will not print like you want it to (PRINT will just print the contents of the file...the PS). Use the COPY command to copy to the LPT port you established or the UNC path if one is not already set up for you.
Remember this page: http://support.microsoft.com/kb/158081
EDIT: removed words.
-
I didn't look up Ghostscript or Redmon, but would rather focus on the Windows side of things as this is for work and so I probably won't be able to use too many external applications.
Then why were you trying to use Acrobat Reader (What im saying is that your statement doesn't make a whole lot of sense to me but...)?
Sorry, let me rephrase - I would rather focus on using programs that are already installed on the work computers: Acrobat Reader being one of them.
-
You are correct; it will not print like you want it to (PRINT will just print the contents of the file...the PS). Use the COPY command to copy to the LPT port you established or the UNC path if one is not already set up for you.
Remember this page: http://support.microsoft.com/kb/158081
Thanks Se7en, I'll try it at work tomorrow :-)
-
So i assume by now `tomorrow' has came and went. Easy, difficult, great, blew-up, launched thermo-nuclear-warhead, what?!
-
I didn't get around to coding the 'copy' at work (as I would have to map the LPT1 port to the network port using net.exe), but for kicks I tried the print function but got 'invalid switch' but I'm not going to proceed using that function anyway.
Quick question about the use of net.exe - I was reading this (http://support.microsoft.com/kb/314499/en-us) article last night (regarding 'Method 1') - will this method affect the printer network port for other users?
Also, I notice that it says to use '/persistent:yes' in the expression - does this mean I would call this method once, print all my files and the printer port would remain mapped to the network port for every file? If so, how would I unmap it after I am finished - or would it not be an issue to leave it this way?
You see, the way I was thinking of approaching it was something like this:
Pseudo Code
Get List of Filenames to print (full filepath included for each file) - done!
Map Printer port LPT1 to Network Printer Port (would this need to be done for each file?)
Use copy statement for each file in the list of filenames
- Perhaps 'unmap' printer port.
What are your thoughts?
-
Completely off the top of my head (or out of an orifice, take your pick), have you tried using VL to work with an Explorer object? I know they can view PDF and should have a print method as well, which may be exposed.
-
no the LPT(#) port(s) (I think you only get three) are just a shortcut like a shortcut on your desktop or a mapped network drive and they are computer specific. Its been years since i mapped a LPT port (and ive only mapped one to something useful only a handful of times anyways...you can point it at a website, printer, whatever...its an old hacker trick to remap lpt1 to something goofy.)
If i remember right all you have to do to map is: net use LPT1 //printerserver/printer
Years ago i wrote a stand-alone VB progy that would just take a bunch of files and send them to one of three printers using the COPY /B method but you dont have to use a LPT port; just pass a fully qualified UNC path.
So...
1. get list of files.
- append path to file name
2. mapcar - copy /b list-item //server/printer
done.
IMO you are making this WAY to difficult. This is a shorty program; this should only take you a few minutes to code up if its just for your use. I would a lot myself maybe a half an hour for coding, and testing (to make sure i didn't launch any rockets).
-
Completely off the top of my head (or out of an orifice, take your pick), have you tried using VL to work with an Explorer object? I know they can view PDF and should have a print method as well, which may be exposed.
VOTE: Second one.
And what happens when you right click on a file and choose print (Hint/Answer: it uses the application associated with the type to open it an print it)?
-
Due to all kinds of trouble with networking and people and subcontractors don't following standards, I had everybody to produce plt files. Printer drivers are on server for everybody to download and make the plts. I hate to search for ctb and stb files, to set custom paper sizes and other stuff so the plt is the way to go. Sometimes we produce one "booklet" and all the managers seeing it want their own copy, but only for their scope (structures, earthworks, drainage, etc) and since we don't know how many we should plot plts help us a lot. Then we take the plts for a booklet and dump them to a folder and fire up a cmd that looks like this:
net use lpt3 /delete ;;;Ensure that lpt3 is not assigned
net use lpt3 \\roms02004\ROMP02071 ;;;Assign lpt3 to a plotter network port
timeout 10 ;;;Nice thing to have a delay to reach the plotter or printer before anybody messes up your papers; can be found on the 'net because no longer comes with either XP or 7, it was in the 2k
copy /b d:\acadtemp\plot\PLOTTER\*.plt lpt3 ;;;The copy job
net use lpt3 /delete ;;;Freeing the lpt3.
I know it's dirty but it gets the job done. The folder with plt files should not reside in the "my Documents" or "desktop" anything that has something to do with active directory and "documents and settings", don't ask me why I found out the hard way.
Good luck,
v.
-
Hi guys,
Once again I thank you for all the information you have posted in this thread - it is truly appreciated and I have learnt a great deal.
>> IMO you are making this WAY to difficult. This is a shorty program; this should only take you a few minutes to code up if its just for your use. I would a lot myself maybe a half an hour for coding, and testing (to make sure i didn't launch any rockets).
Think about it from someone who is stumbling in the dark - yes its only a few lines of code, but I want to make sure that I completely understand the procedure and all possible consequences before I go ahead and experiment (for obvious reasons). Please bear in mind that I have used very very few DOS commands and have little to no experience in this area.
Anyway, back to the issue at hand, here is today's update:
I tried a multitude of methods today, all involving the DOS copy function, all of which did not throw an error, but also unfortunately did not print anything either, the jobs were not added to the print queue at all.
<EDIT: forget my crap code - forgot to use the strcat function... me = idiot with lack of sleep ... will try again tomorrow - thanks for your patience >
-
Lee, we are all stumbling in the dark. And as for `completely understanding all the possible consequences' goes, you are just starting down a rabbit hole and i told you that already.
Printing is a very difficult task; most people think its easy because all they do is hit the little print button in the application they are using. Now, you are discovering that even getting a file to a plotter is difficult (you will learn more very soon).
BTW, do you understand "net use LPT# ..." is machine specific and will NOT harm other workstations on your network?
-
Of course it's machine specific, but for whatever reason it could be assigned from a previous print job or other data transfer (data collector or virtual LPT for USB, only Windoze knows) and I want to be sure I don't copy somewhere into the ughnown.
I'm not an expert, I just assumed that starting with it fresh will save some head scratching, it works for me so I don't intend to fix it.
Regards,
v.
-
Printing is a very difficult task; most people think its easy because all they do is hit the little print button in the application they are using.
IMO you are making this WAY to[sic] difficult. This is a shorty program; this should only take you a few minutes to code up if its just for your use.
Errr...
BTW, do you understand "net use LPT# ..." is machine specific and will NOT harm other workstations on your network?
Yes, I understood what you posted about it being like a 'shortcut' from one computer to the network port.
-
oh come on Lee, I was talking about the AutoLisp portion being simple...don't put words into my mouth.
-
Vali, good point.
-
oh come on Lee, I was talking about the AutoLisp portion being simple...don't put words into my mouth.
Yeah sorry, that was a cheap dig.
Anyway, I tried the 'copy' method today but, unfortunately was unsuccessful. The code runs without error, but nothing seems to happen.
Here is the code I have been trying, assume that 'pdfLst' is a list of full filenames of PDF files.
(startapp "net use lpt3 /delete")
(startapp "net use lpt3 \\\\<printserver>\\<printer>")
(foreach file pdfLst
(startapp (strcat "copy /b \"" file "\" lpt3"))
)
(startapp "net use lpt3 /delete")
(foreach file pdfLst
(startapp (strcat "copy /b \"" file "\" \\\\<printserver>\\<printer>"))
)
(foreach file pdfLst
(startapp (strcat "copy /b \"" file "\" //<printserver>/<printer>"))
)
Each with the same result as described above.
So far the closest I have got to printing is using:
(setq adobe "C:\\Program Files\\Adobe\\Reader\\AcroRd32.exe")
(foreach file pdfLst
(startapp (strcat adobe " /t /h \"" file "\""))
)
Which actually registers the necessary files on the print queue, but only the first is sent. The first file is open for longer than the subsequent files, so perhaps these files are not open long enough for the data to be sent to the printer... but, in any case, the printer registers a timeout error and fails to print all but the first file.
Lee
-
The only thing i got at this point is: are you sure you have the server name and the printer share name properly spelled and used? I'm thinking that you are sending the file into never-never land.
SH stands for SHELL...Type "sh enter enter" on the acad command line to open a prompt and send a file that way once.
-
Here it is something I just found out, but could not make it to work:
(vl-load-com)
(setq prog-id "AcroPDF.PDF.1")
(setq pdf (vlax-create-object prog-id))
(vlax-invoke-method pdf 'LoadFile "C:\\test.pdf") ;; returns :vlax-false no idea why or how to set this...
(setq pdf (vlax-create-object prog-id))
; IAcroAXDocShim: IAcroAXDocShim Interface
; Property values:
; messageHandler = nil
; src = ""
; Methods supported:
; execCommand (1)
; GetVersions ()
; goBackwardStack ()
; goForwardStack ()
; gotoFirstPage ()
; gotoLastPage ()
; gotoNextPage ()
; gotoPreviousPage ()
; LoadFile (1)
; postMessage (1)
; Print ()
; printAll ()
; printAllFit (1)
; printPages (2)
; printPagesFit (3)
; printWithDialog ()
; setCurrentHighlight (4)
; setCurrentHightlight (4)
; setCurrentPage (1)
; setLayoutMode (1)
; setNamedDest (1)
; setPageMode (1)
; setShowScrollbars (1)
; setShowToolbar (1)
; setView (1)
; setViewRect (4)
; setViewScroll (2)
; setZoom (1)
; setZoomScroll (3)
T
_$
(vlax-release-object pdf)
-
The only thing i got at this point is: are you sure you have the server name and the printer share name properly spelled and used? I'm thinking that you are sending the file into never-never land.
SH stands for SHELL...Type "sh enter enter" on the acad command line to open a prompt and send a file that way once.
I'll definitely check that - thanks mate.
-
Here it is something I just found out, but could not make it to work:
That's interesting Luis - I'll investigate that too when I get a spare minute - thanks. :-)
-
Here it is something I just found out, but could not make it to work:
That's interesting Luis - I'll investigate that too when I get a spare minute - thanks. :-)
I get the same results as you Luis - unable to load a file. :-(
-
Here it is something I just found out, but could not make it to work:
That's interesting Luis - I'll investigate that too when I get a spare minute - thanks. :-)
I get the same results as you Luis - unable to load a file. :-(
well.... :-( - how about the exe, did it worked?
-
Here it is something I just found out, but could not make it to work:
That's interesting Luis - I'll investigate that too when I get a spare minute - thanks. :-)
I get the same results as you Luis - unable to load a file. :-(
well.... :-( - how about the exe, did it worked?
The .exe method was the closest I got to actually printing...
See here:
http://www.theswamp.org/index.php?topic=34551.msg398482#msg398482 (http://www.theswamp.org/index.php?topic=34551.msg398482#msg398482)
-
nope... the one sent to you via email
-
nope... the one sent to you via email
Ahh - apologies, my email has since changed so I rarely check my old one, I shall have a look now and also send you my new email address.
-
Unless I'm mistaken, the following doesn't work because pdf is still nil.
Here it is something I just found out, but could not make it to work:
(vl-load-com)
(setq prog-id "AcroPDF.PDF.1")
(setq pdf (vlax-create-object prog-id))
(vlax-invoke-method pdf 'LoadFile "C:\\test.pdf") ;; returns :vlax-false no idea why or how to set this...
because...
<snip>
Adobe Reader does not support OLE.
Same link as what i posted before.
http://livedocs.adobe.com/acrobat_sdk/9/Acrobat9_HTMLHelp/Overview_GettingStarted.3.10.html
-
@Lee: Just wondering; is there a reason you are trying to do this from code? If you select the files you want to print in explorer then select "print" from the right click menu then everything prints without a problem (at least on my system).
-
Thanks!
I know and even if that is not possible, I still gave it a try... and that's why I am in the programming field - :-)
Went the C# route and that looks better (promising) - btw - once there is a working sample will try to post it at the .net side.
Unless I'm mistaken, the following doesn't work because pdf is still nil.
Here it is something I just found out, but could not make it to work:
(vl-load-com)
(setq prog-id "AcroPDF.PDF.1")
(setq pdf (vlax-create-object prog-id))
(vlax-invoke-method pdf 'LoadFile "C:\\test.pdf") ;; returns :vlax-false no idea why or how to set this...
because...
<snip>
Adobe Reader does not support OLE.
Same link as what i posted before.
http://livedocs.adobe.com/acrobat_sdk/9/Acrobat9_HTMLHelp/Overview_GettingStarted.3.10.html
-
Thanks!
I know and even if that is not possible, I still gave it a try... and that's why I am in the programming field - :-)
Went the C# route and that looks better (promising) - btw - once there is a working sample will try to post it at the .net side.
Tell me about it :) I didn't want to believe it either! But, after importing the type library and banging my head against the wall for a couple of hours I just had to assume that even though it looked like all the necessary methods had been exposed, there was still something behind the scenes stopping me from creating the connection.
A bit of further reading suggests that you can use DDE to communicate with Reader.
-
Using C# ?
I referenced the activex file:
i.e: C:\Program Files\Common Files\Adobe\Acrobat\ActiveX\AcroPDF.dll
And this one allows you to print, to have the pdf control and use it on a form, take out the toolbar, etc...
Thanks!
I know and even if that is not possible, I still gave it a try... and that's why I am in the programming field - :-)
Went the C# route and that looks better (promising) - btw - once there is a working sample will try to post it at the .net side.
Tell me about it :) I didn't want to believe it either! But, after importing the type library and banging my head against the wall for a couple of hours I just had to assume that even though it looked like all the necessary methods had been exposed, there was still something behind the scenes stopping me from creating the connection.
A bit of further reading suggests that you can use DDE to communicate with Reader.
-
@Lee: Just wondering; is there a reason you are trying to do this from code? If you select the files you want to print in explorer then select "print" from the right click menu then everything prints without a problem (at least on my system).
Hi Daniel,
Yes, I realise this can be done, but it doesn't give much control over the printing - for example all the files are in a weird order and some are perhaps at the wrong orientation. I first thought manipulating Adobe to print file by file might be a relatively easy task (using the relevant ActiveX object methods), but it appears not.
BTW, with Luis' VL code, 'pdf' is not nil on my machine but rather a valid VLA object.
Lee
-
Now that im back to work from my vacation i gave this a quick try and it worked for me; One giant hint for you:
The printer name isnt always the same name you see in "Printers and Faxes" section of your control panel. Here are two methods for you to try and find the proper name for the printer.
Method 1 (this would be the fake hacker or script kiddie way): Open a windows command prompt and type NET VIEW this should show you the print server name (along with others). Now open a win explore window and try to navigate there. Now you should see several printers, juxtapose a view of the "Printers and Faxes" on your computer to see which is which.
Method 2 (This would be the IT way): go to "Printers and Faxes". Right click on the printer in question and choose "Printer properties". Go to the "Ports" tab and see what the fully qualified path and name is of the printer.
COPY <PLOT NAME> <PATH YOU JUST LOOKED UP> /B
-
Now that im back to work from my vacation i gave this a quick try and it worked for me; One giant hint for you:
I'm loving how direct this answer is, having just this morning read through the whole of this gem (http://catb.org/esr/faqs/smart-questions.html) - an enlightening read, offering many things that I would implement if I had the chance to start this thread again.
When I get back to work after the bank holiday weekend I shall be sure to give your methods a go and get back to you with my results.
Many thanks for your time helping me investigate this Se7en - it is sincerely appreciated.
Lee
-
Yes, that is a VERY good read and I'm glad you liked it.
-
Yes, that is a VERY good read and I'm glad you liked it.
That - and the article about 'hackers' :-)
-
I haven't read that one yet.
He has got a very nice style about his writings doesn't he?
I cant wait to read his "The Art of Unix Programming" paper. Ive skimmed it and it seemed like it had some very cool stuff in it.
-
I haven't read that one yet.
He has got a very nice style about his writings doesn't he?
Definitely - I love his humour, especially in his reference to 'crackers' ( you'll read that in the hackers article ).
I cant wait to read his "The Art of Unix Programming" paper. Ive skimmed it and it seemed like it had some very cool stuff in it.
Yeah, after reading his articles I feel like I need to advance a lot more into other languages and systems - I'm glad he notes LISP as a notable language to learn though. :-)
-
heh, not AutoLisp. Im pretty sure he's talking about Common Lisp. And Just so you know, you could fit AutoLisp in Common Lisp's bathroom closet.
If you would like a taste of whats to come if you choose to wander into the Common Lisp ring, read this.
http://www.paulgraham.com/onlisp.html
-
heh, not AutoLisp. Im pretty sure he's talking about Common Lisp. And Just so you know, you could fit AutoLisp in Common Lisp's bathroom closet.
I thought you might say something like that...
I'll have a read :-)
-
Developments:
1) Tried method as describe by Se7en above: printer path is correct.
Result:
Job not added to print queue, no noticeable result. Could this be a permissions thing? Seeing as I'm not administrator on the computer?
2) Advancement in OLE Automation approach.
After a touch of research, I found that the exe print command could be found using something like:
(defun GetPrintCmd ( / wsh reg result )
(setq wsh (vlax-create-object "WScript.Shell"))
(if (setq reg (vlax-invoke wsh 'RegRead "HKCR\\.pdf\\"))
(setq result (vlax-invoke wsh 'RegRead (strcat "HKCR\\" reg ".7\\shell\\print\\command\\")))
)
(vlax-release-object wsh)
result
)
(For the relevant version of Adobe)
I tried using the result of the above to manipulate the .exe as before, and the jobs were added to the queue. But, as before, only the first job prints and the others register that seemingly only half the data has been sent - causing a timeout error.
But, during my digging in the registry, I found entries for the AcroExch.App Object, using the ProgID AcroExch.App.1 - this returned a valid object which I could query for properties.
I then found info on the net (http://techsupt.winbatch.com/ts/T000001031F29.html) relating to how to manipulate such objects for printing, and translated it to VL:
(defun c:test ( / pdf_file adobe pddoc printdoc n avdoc )
(setq pdf_file "H:\\My Documents\\Test.pdf")
(setq adobe (vlax-create-object "AcroExch.app.1"))
(setq pddoc (vlax-create-object "AcroExch.PDDoc.1"))
(setq printdoc (vlax-create-object "AcroExch.AvDoc.1"))
(vlax-invoke printdoc 'open pdf_file "")
(setq n (vlax-invoke pddoc 'GetNumPages))
(princ (strcat "\nPages: " (itoa n)))
(setq avdoc (vlax-invoke adobe 'GetActiveDoc))
(print (vlax-invoke avdoc 'PrintPages 0 n 1 0 0))
(vlax-invoke pddoc 'Close)
(vlax-invoke adobe 'CloseAllDocs)
(vlax-invoke adobe 'Exit)
(vlax-release-object pddoc)
(vlax-release-object adobe)
(vlax-release-object printdoc)
(princ)
)
This opens the document OK, but the PrintPages method seems to return 0, indicating an error during printing :-(
-
> permissions ...
Not sure, but i doubt it.
Thought:
I'm seeing some people saying some of the same things you are though. Would this be a "HP" brand of printer? Apparently there is some firmware problems (no link because im still researching and im not even sure this is the same issue yet).
-
Would this be a "HP" brand of printer?
Indeedy. :-(
The printer is a HP Color LaserJet 5550 PS on a network.
-
Try to plot via the windows command prompt (start->applications->accessories->cmd prompt) and see what happens.
BTW, You will not get any further using the Adobe reader route then you already have and i hope you realize that now; You need to divert that attention elsewhere. If you need/can/whatever give a third party tool like Redmon (now RedmonEE) a try because it has an exe that is devoted to just sending files to a printer.
-
Try to plot via the windows command prompt (start->applications->accessories->cmd prompt) and see what happens.
Will do.
BTW, You will not get any further using the Adobe reader route then you already have and i hope you realize that now; You need to divert that attention elsewhere. If you need/can/whatever give a third party tool like Redmon (now RedmonEE) a try because it has an exe that is devoted to just sending files to a printer.
It does seem that way, yes. I only really pursued it because it was the method that came closest to a print over the other methods, but I seem to have hit a major wall with it.
Third-party software is likely to be a last resort if I'm honest due to IT restrictions... :|