将 DDE 消息传递到 Acrobat Reader 时路径中的特殊字符出现问题

发布于 2024-11-09 15:38:55 字数 602 浏览 4 评论 0原文

我已经研究一个问题有一段时间了,但没有找到解决方案。也尝试过谷歌,但没有走上正轨...

任何帮助将不胜感激!

问题是:

我正在发送 DDE 命令,打开 PDF 文档以静默打印它。如果路径包含非 ASCII 字符,则问题出在路径上。它不会被识别并且会抛出错误。我应该如何处理路径字符串才能避免这种情况并让 Acrobat reader 理解路径?我尝试过用“o”代替“ø”,效果完美......提前致谢!

string file = @"C:\Users\Bø\1_tmp_printpages.pdf";

client.Execute("[DocOpen(\"" + file + "\")]", 60000);
client.Execute("[FilePrintSilent(\"" + file + "\")]", 60000);
client.Execute("[DocClose(\"" + file + "\")]", 60000);
client.Execute("[AppExit]", 60000);

我正在使用 NDde 传递 DDE 消息。

I've been looking into a problem for some time without finding a solution to it. Tried google as well, without getting on track...

Any help would be appreciated!

Problem is:

I'm sending a DDE-command, to open a PDF document to print it silently. Problem is with the path, if it has non-ASCII chars. It would not get recognized and it throws an error. What should I do with the path string to avoid this and to get Acrobat reader to understand the path? I've tried with an "o" instead of "ø", and that works flawlessly... Thanks in advance!

string file = @"C:\Users\Bø\1_tmp_printpages.pdf";

client.Execute("[DocOpen(\"" + file + "\")]", 60000);
client.Execute("[FilePrintSilent(\"" + file + "\")]", 60000);
client.Execute("[DocClose(\"" + file + "\")]", 60000);
client.Execute("[AppExit]", 60000);

I'm using NDde to pass DDE messages.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寄与心 2024-11-16 15:38:55

由于我无法找到除 C# NDde 之外的 DDE 库,因此我无法处理路径中的非 US-ASCII 符号。因此我决定使用不同的方法,动词。

这是我的新代码,它接受非 US-ASCII 符号。它位于 try 块内,之后我正在执行一些逻辑来终止 AcroRd32。但静默打印 PDF 的代码本身就在下面......:)

            System.Diagnostics.Process P = new Process();
            P.StartInfo.FileName = mc.PrintPages;
            P.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; 
            P.StartInfo.Verb = "print";
            P.StartInfo.Arguments = printDialog1.PrinterSettings.PrinterName.ToString();
            P.StartInfo.CreateNoWindow = true;           
            P.Start();

Since I couldnt find a DDE library other than NDde for C#, I was not able to process non US-ASCII symbols in my path. Therefore I decided to use a different approach, verbs.

Here is my new code that accepts non US-ASCII symbols. It's inside a try-block, and I'm doing some logic to kill AcroRd32 afterwards. But the code itself to print PDF silently is underneath... :)

            System.Diagnostics.Process P = new Process();
            P.StartInfo.FileName = mc.PrintPages;
            P.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; 
            P.StartInfo.Verb = "print";
            P.StartInfo.Arguments = printDialog1.PrinterSettings.PrinterName.ToString();
            P.StartInfo.CreateNoWindow = true;           
            P.Start();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文