|
Any idea.. how to do the same in C#?
R Pooran Prasad
|
|
|
|
|
I need to know when the Adobe Acrobat Reader has completed printing, especially for large documents. So far the only way I have found to do this involves sending an [AppExit] DDE message and then waiting for the process to terminate. This has many unfortunate side affects including closing other open PDF's. I have tried to use the DDECallBack mechanism, but these call backs do not appear to be invoked in all cases, e.g. it appears to work only if the calling process actually caused the acrordr32.exe process to be created.
Any ideas on serializing printing?
Peter
|
|
|
|
|
When I add the two files into my VC project and build it, an compile error occurs.
The error says "fatal error C1083: Cannot open include file: 'sstpdf2.h': No such file or directory". I search the file in my computer, but I can't find it.
What can I do?
Thanks
|
|
|
|
|
|
I can't find this either.
I don't see any references in the coments.
The link provided doesn't seem to be helpful.
|
|
|
|
|
no, for some reason/somehow I stuffed the link = it pointed to an earlier comment ... I'll see if I can find it again
|
|
|
|
|
ok, got it - the text of the reply was
"Sorry,
This file is not required to use the class.
Only one dependecy is required :
#include "ddeml.h" (already include in the .h)
Just comment that line, and that will be ok.
vince "
if you go down to now the second page of comments wou'll see a 'Compiling error' noted by Piccinano .. this was the response
happy ?
|
|
|
|
|
Absolutely
(I saw that comment just after your previous reply.)
THANKS!
|
|
|
|
|
Hello,
Is it possible to merge 2 pdf files into 1 with DDE? I have Acrobat SDK 7.0 and I try to use the method InsertPages but I can't get it to work. I checked with COM Viewer and the documentation that I pass the right arguments to this function, also I saw on the internet that other people do absolutely the same thing, however I keep getting an error: "Wrong number of arguments".
Please if anyone know a way to merge 2 pdf files drop me a message.
Thanks in advance.
Best Regards,
Drago
|
|
|
|
|
This seems like a really useful class, but I can't get the DocClose or AppExit functions to work. The doc opens and then that's it. I added a DocSaveAs that also won't work. I don't seem to be getting any error messages. Interestingly, the Print command works fine. Any direction would be much appreciated. I have Acrobat Standard 7.0 installed
|
|
|
|
|
I just found out that if you string all of the commands you want to make together into one and send that through then it works. so i changed the DocOpen function to have a CmdLine = "[DocOpen(%s)][DocSaveAs(%s,%s)][DocClose(%s)]"
I just need it for batch processing so it may be wise to change this class to create this string from a series of calls and then have an Execute() method.
|
|
|
|
|
Hi,
I tried this code on Acrobat Reader 6.0 and 7.0 and I always get these errors:
DDE Connection Failed.
Command failed: [DocOpen("\1.pdf")]
Command failed: [DocClose("\1.pdf")]
Command failed: [AppExit()]
The file gets opened, printed, but Acrobat is not closed. How can I make it exit?
|
|
|
|
|
(* slightly off topic *)
Printing via DDE works with the code given by iver (see last thread), but the Acrobat Reader has to be started manually by a call to "CreateProcess".
But does anyone manage to hide it ? I tried calling CreateProcess with STARTUPINFO.dwFlags = STARTF_USESHOWWINDOW and STARTUPINFO.wShowWindow = SW_HIDE or SW_MINIMIZE or both of them, or another attempt was dwCreationFlags = CREATE_NO_WINDOW, but nothing helped, the Acrobat Reader seems to ignore theses settings. I can only start the application, and send the virtual keys for opening the system menu and hide the app this way.
Does anybody know a way how to handle the printing without that much "noise" on the screen ? I mean, how to hide the Acrobat Reader right from start, or even printing silently without AcroReader ?
I tried ghostscript, but with this, on some colour laser printers it generates 500 Megabytes for a simple page's print job, there seems to be no way to change this by setting. I tried debugging the source code, but working this way, the config file (gs_init.ps) is not interpreted correctly, and it doesn't work at all.
Any hint appreciated.
|
|
|
|
|
Unfortunately, hiding the application window does not work with version 7.0 because of a bug. I'm still waiting for the adobe guys to fix the bug, but it's still there in 7.0.3.
The best solution I know is to use an older version like 6.0.2......
Anyway. If you use verson 6, the following code works:
...
STARTUPINFO startupInfo;
memset (&startupInfo, 0, sizeof(STARTUPINFO));
startupInfo.cb = sizeof(STARTUPINFO);
startupInfo.wShowWindow = SW_HIDE;
startupInfo.dwFlags |= STARTF_USESHOWWINDOW;
PROCESS_INFORMATION processInfo;
memset (&processInfo, 0, sizeof(PROCESS_INFORMATION));
// Launch the viewer.
int ret = CreateProcess ((const char *)viewerPath.c_str(), NULL, NULL, NULL, false, NORMAL_PRIORITY_CLASS,NULL, NULL, &startupInfo, &processInfo);
if (ret) {
m_AcrobatProcess = processInfo.hProcess;
} else {
m_AcrobatCannotStart = true;
}
...
Use m_AcrobatProcess later to shut down acrobat reader with something like
...
int ret = TerminateProcess(m_AcrobatProcess, 0);
...
|
|
|
|
|
hi iver,
By this way I can hide the acrobat reader when it starts up.
But if I send a FilePrintToEx DDE message to it, it will show
automatically. Any way to solve this problem?
Thanks very much!
Leon
|
|
|
|
|
I have Acrobat Reader 7, and I can only open, but not print via DDE. Seems to be the version; DdeClientTransaction yields always 0, and DdeGetLastError returns me "DMLERR_INVALIDPARAMETER". The command is
[FilePrintSilent("C:\test.pdf")]
I can see this is correct, and the file of yource is there, I can view it with this class.
Can it be that Acro 7 has changed the way to use DDE ? When I watch the detailed file settings for ".PDF" files, i can oly see an entry for "Open", but nothing more.
|
|
|
|
|
As far as i know there are no changes in the DDE. BUT (!) there are some bugs in 7.0.
- FilePrintSilent makes the application window pop up even if it is started with no window
- Calling TerminateProcess on the reader results in "Access Denied"
The latter has been fixed in version 7.0.1, but the first one is still a problem here as well.
Another problem I found earlier using 6.0 was that "AppExit" made the application crash. I don't know if this was ever fixed or not (I switched to using TerminateProcess...)
The following code works on 7.0.1:
(Acrobat reader is started before calling Print(..) )
void Print(std::string FileName)
{
char ddeCmdBuf[512];
UINT retVal;
DWORD id = 0;
// Start the DDE
// Print the file
// Shut down the DDE
retVal = DdeInitialize (&id, &DdeCallback , APPCMD_CLIENTONLY, 0);
if (DMLERR_NO_ERROR == retVal) {
DWORD dwResult;
HCONV hConversation = NULL;
HSZ hszServerName, hszTopicName;
// Initialize DDE conversation with server.
hszServerName = DdeCreateStringHandle (id, "acroview", 0);
hszTopicName = DdeCreateStringHandle (id, "control", 0);
retVal = DMLERR_NO_ERROR - 1;
int timeOut = 60;
while ((retVal != DMLERR_NO_ERROR) && (timeOut != 0)) {
--timeOut;
hConversation = DdeConnect (id, hszServerName, hszTopicName, NULL);
retVal = DdeGetLastError (id);
if (DMLERR_NO_ERROR != retVal) {
Sleep(1000);
}
}
if (DMLERR_NO_ERROR != retVal) //We have tried for 60 seconds to make acrobat start
MessageBox (NULL, "Could not connect to server.", "DdeOpen - Error", MB_OK);
else {
// Execute the DDE Command.
//Print file
memset (ddeCmdBuf, 0, sizeof(ddeCmdBuf));
sprintf(ddeCmdBuf, "[FilePrintSilent(\"%s\")]", FileName.c_str());
DdeClientTransaction ((unsigned char *)ddeCmdBuf, (DWORD)strlen(ddeCmdBuf), (HCONV)hConversation,
NULL, (UINT)CF_TEXT, (UINT)XTYP_EXECUTE, (DWORD)1000, &dwResult);
UINT result = DdeGetLastError(id);
DdeDisconnect (hConversation);
}
// Release resources.
DdeFreeStringHandle (id, hszServerName);
DdeFreeStringHandle (id, hszTopicName);
DdeUninitialize (id);
}
}
Enjoy!
I
|
|
|
|
|
Thanks, iver, this code indeed works with Version 7.0.1
But I can't hide the Reader, this is stuff for another thread.
|
|
|
|
|
Well, how do I use this thing in a VB.Net application ? I would like to build a service that will watch a directory and print all pdf files sent to the directory. Your progam seems perfect for silent printing but how do I make it work in VB.Net app ?
I do not have any expericne in C++.
Thanks
Stephane
|
|
|
|
|
|
I tried your class in a simple MFC applcation, but it open the pdf but don't do anything more. Don't print, don't close document and don't exit reader.
I have Acrobat Reader 6.0.
I've noticed that the DdeCreateDataHandle return always NULL .
have you any suggestion?
Thanks in advance
Roberto
|
|
|
|
|
I'm also experiencing the same problem. I'm using Adobe Reader 6, the pdf opens, but will not print, close, or exit. DdeCreateDataHandle always returns NULL.
Did you find a solution Robig?
|
|
|
|
|
DdeGetLastError returns DMLERR_INVALIDPARAMETER.
Also, If I have Adobe Reader open, then all works as it should. The pdf opens, prints, closes.
|
|
|
|
|
Is there a way to pass the printer you want to print to besides the default one?
|
|
|
|
|
Got a problem with your wraper, I have Adobe 6.0 pro & Adobe reader 7.0 installed on my system. Each time i run my app it starts pro and does not work correctly. But if i open reader and run my app it works in reader just fine..
How do i tell my app to run reader only??
|
|
|
|
|