PDFCreator 将打印 TIFF 而不是 PDF

发布于 2024-09-13 07:52:03 字数 1571 浏览 2 评论 0原文

我正在尝试将 RTF 文档转换为 PDF。我有这样的代码:

// TestCOMPDF.cpp : Defines the entry point for the console application.
//

#include <windows.h>
#include <tchar.h>
#include <objbase.h>
#include <atlbase.h>

#import "MSVBVM60.DLL" rename ( "EOF", "VBEOF" ), rename ( "RGB", "VBRGB" ) //if you don't use this you will be in BIG trouble
#import "PDFCreator.exe" 

int _tmain(int argc, _TCHAR* argv[])
{

 CoInitialize(NULL);
 {

  CComPtr<PDFCreator::_clsPDFCreator> pdfObject;
  HRESULT hr = pdfObject.CoCreateInstance(L"PDFCreator.clsPDFCreator");
  pdfObject->cStart("/NoProcessingAtStartup", 1);

  PDFCreator::_clsPDFCreatorOptionsPtr opt = pdfObject->GetcOptions();

  opt->UseAutosave = 1;
  opt->UseAutosaveDirectory = 1;
  opt->AutosaveDirectory = "c:\\temp\\";
  opt->AutosaveFormat = 0; // for PDF
  opt->AutosaveFilename = "gigi13";
  pdfObject->PutRefcOptions(opt);
  pdfObject->cClearCache();
  _bstr_t DefaultPrinter = pdfObject->cDefaultPrinter;
  pdfObject->cDefaultPrinter = "PDFCreator";
  hr = pdfObject->cPrintFile("c:\\temp\\RTF\\garage.rtf");

  pdfObject->cPrinterStop = false;

  while(true)
  {
   printf("sleep\n");
   Sleep(1000);
   if(pdfObject->cCountOfPrintjobs == 0)
    break;
  }

  printf("done\n");

  pdfObject->cPrinterStop = true;

  pdfObject->cDefaultPrinter = DefaultPrinter;
 }

 CoUninitialize();

 return 0;
}

当运行此代码示例而不是直接创建 PDF 时,它会提示我一个“保存”对话框,为我提供仅输出的选项以及选择 TIFF 文件的选项(这不是想要的)。有人可以指出我正确的方向或提供一些建议吗?

谢谢,

尤利安

I am trying to convert a RTF document to PDF. I have this code:

// TestCOMPDF.cpp : Defines the entry point for the console application.
//

#include <windows.h>
#include <tchar.h>
#include <objbase.h>
#include <atlbase.h>

#import "MSVBVM60.DLL" rename ( "EOF", "VBEOF" ), rename ( "RGB", "VBRGB" ) //if you don't use this you will be in BIG trouble
#import "PDFCreator.exe" 

int _tmain(int argc, _TCHAR* argv[])
{

 CoInitialize(NULL);
 {

  CComPtr<PDFCreator::_clsPDFCreator> pdfObject;
  HRESULT hr = pdfObject.CoCreateInstance(L"PDFCreator.clsPDFCreator");
  pdfObject->cStart("/NoProcessingAtStartup", 1);

  PDFCreator::_clsPDFCreatorOptionsPtr opt = pdfObject->GetcOptions();

  opt->UseAutosave = 1;
  opt->UseAutosaveDirectory = 1;
  opt->AutosaveDirectory = "c:\\temp\\";
  opt->AutosaveFormat = 0; // for PDF
  opt->AutosaveFilename = "gigi13";
  pdfObject->PutRefcOptions(opt);
  pdfObject->cClearCache();
  _bstr_t DefaultPrinter = pdfObject->cDefaultPrinter;
  pdfObject->cDefaultPrinter = "PDFCreator";
  hr = pdfObject->cPrintFile("c:\\temp\\RTF\\garage.rtf");

  pdfObject->cPrinterStop = false;

  while(true)
  {
   printf("sleep\n");
   Sleep(1000);
   if(pdfObject->cCountOfPrintjobs == 0)
    break;
  }

  printf("done\n");

  pdfObject->cPrinterStop = true;

  pdfObject->cDefaultPrinter = DefaultPrinter;
 }

 CoUninitialize();

 return 0;
}

When running this code sample instead of creating directly the PDF it prompts me with a Save dialog offering me the option to the output only with the option of choosing a TIFF file (which is not wanted). Can someone point me into the right direction or offer some suggestions?

Thanks,

Iulian

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

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

发布评论

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

评论(1

孤城病女 2024-09-20 07:52:05

这只是一个猜测...我遇到了类似的问题 - 不是在以编程方式使用 PDFCreator 时(这超出了我的能力),而是在使用它作为我的标准打印机来打印 PDF 时。

首先我使用了几天,没有任何问题。不是我安装的,而是我的伙伴安装的。正如我所说...它确实有效,并且创建了漂亮的 PDF。

然后,不知何故,我们家用计算机上的某个人(我们是 3 个不同的人使用它)一定更改了设置(可能是无意中),使其输出 TIFF 而不是 PDF。对我来说,我的默认打印机被命名为“PDFcreator”,这让我很困惑为什么它突然想要创建 TIFF。

与此同时,我在用户界面的所有设置中进行了很多检查,并学会了如果出现问题应该去哪里查找。

最新版本在其左侧树视图面板中列出了一个名为“保存”的项目。如果选择它,您可以配置默认文件名约定以及“标准保存格式”。就我而言,在下拉列表视图中选择了“TIFF”而不是“PDF”。

查看您的代码,您以某种方式调用 PDFCreator.exe (我不明白详细信息,但我可以在您的代码中看到这个字符串)。我敢打赌:不知何故,您的代码用来运行的用户帐户的标准保存格式设置为 TIFF。您可能会查看打印机设置(在我的 Windows XP 上,我只需键入控制打印机,然后右键单击 PDFCreator 打印机名称以选择属性...)并找到没有什么可疑的。

但是,PDFcreator 将每个用户的设置存储到不同的位置,可能在 %userprofile%\local settings\temp\pdfcreator\... 中,甚至在注册表中...

This is only a guess... I had a similar problem -- not when using PDFCreator programmatically (this is beyond my capabilities), but when using it as my standard printer to print to PDFs.

First I used it for a couple of days without any problem. Not I had installed it, but my partner. As I said... it just worked, and created beautiful PDFs.

Then, somehow, someone on our home computer (we are 3 different persons using it) must have changed the setting (maybe inadvertedly) to make it output TIFF instead of PDFs. For me, my default printer was named "PDFcreator" and it confused the hell out of me why it suddenly wanted to create TIFFs.

Meanwhile I've poked a lot in the user interface of all its settings, and learned to know where to look if something goes wrong.

The newest version in its lefthand treeview panel lists an item named "Save". If you select it, you can configure default filename conventions as well as "Standard save format". In my case in the dropdown listview there was "TIFF" selected instead of "PDF".

Looking at your code, you are somehow calling PDFCreator.exe (I don't understand the details, but I can see this string in your code). My bet would go towards this: somehow, the user account which your code uses to run under has his Standard save format set to TIFF. It may be that you look at the printer settings (on my Windows XP, I just type control printers, and rightclick the PDFCreator printername to select Properties...) and find nothing suspicious.

However, PDFcreator stores its settings for each user into a different location, probably in %userprofile%\local settings\temp\pdfcreator\..., or even in the registry...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文