从打印作业中提取文档名称

发布于 2025-01-06 13:35:43 字数 119 浏览 0 评论 0原文

如果您有原始 Postscript 数据,是否有可靠的方法从 Postscript 打印作业中提取文档名称或作业名称?

我见过打印发布站软件,它用打印的文档名称或 URL 来标记每个作业,所以这似乎是可能的。

Is there a reliable way to extract a document name or job name from a postscript print job if you have the raw postscript data?

I've seen print release station software that labels each job with a document name or url it was printed from, so it seems possible.

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

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

发布评论

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

评论(3

鹿港巷口少年归 2025-01-13 13:35:43

没有可靠的方法来做到这一点,因为 PostScript 语言中没有这样的(元数据)信息。 如果您的文件符合 DSC(文档结构约定),那么您可以查找注释。这些记录在 DSC 参考手册中。有效的 PostScript 文件不必符合 DSC。

除此之外,没有任何信息可供提取,至少就 PostScript 而言是这样。

There is no reliable way to do this, as there is no such (metadata) information in the PostScript language. If your files are DSC (Document Structuring Convention) compliant then you can look for comments. These are documented in the DSC reference manual. Valid PostScript files need not be DSC compliant.

Other than that, there is no information there to extract, at least as far as PostScript is concerned.

傻比既视感 2025-01-13 13:35:43

使用 C++ 从打印作业中提取文档名称。

    #include <WinSpool.h>

wstring GetDocumentName(wstring m_strFriendlyName)
{
  wstring strDocName = L"";
  HANDLE hPrinter ;
  if ( OpenPrinter(const_cast<LPWSTR>(m_strFriendlyName.c_str()), &hPrinter, NULL) == 0 )
  {    
    /*OpenPrinter call failed*/
    return false;
  }

  DWORD dwBufsize = 0;
  PRINTER_INFO_2* pinfo = 0;
  GetPrinter(hPrinter, 2,(LPBYTE)pinfo, dwBufsize, &dwBufsize); //Get dwBufsize

  PRINTER_INFO_2* pinfo2 = (PRINTER_INFO_2*)malloc(dwBufsize); //Allocate with dwBufsize
  GetPrinter(hPrinter, 2,(LPBYTE)pinfo2, dwBufsize, &dwBufsize);

  DWORD numJobs = pinfo2->cJobs;
  free(pinfo2); 

  JOB_INFO_1 *pJobInfo = 0;
  DWORD bytesNeeded = 0, jobsReturned = 0;

  //Get info about jobs in queue.
  EnumJobs(hPrinter, 0, numJobs, 1, (LPBYTE)pJobInfo, 0,&bytesNeeded,&jobsReturned);
  pJobInfo = (JOB_INFO_1*) malloc(bytesNeeded);
  EnumJobs(hPrinter, 0, numJobs, 1, (LPBYTE)pJobInfo, bytesNeeded, &bytesNeeded, &jobsReturned);


  JOB_INFO_1 *pJobInfoInitial = pJobInfo;
  for(unsigned short count = 0; count < jobsReturned; count++)
  {
    if (pJobInfo != NULL)
    {
      strDocName  = pJobInfo->pDocument; // Document name
      DWORD dw = pJobInfo->Status;         
    }
    pJobInfo++;
  }

  free(pJobInfoInitial);
  ClosePrinter( hPrinter );
  return strDocName;
}

To extract document name from print job using C++.

    #include <WinSpool.h>

wstring GetDocumentName(wstring m_strFriendlyName)
{
  wstring strDocName = L"";
  HANDLE hPrinter ;
  if ( OpenPrinter(const_cast<LPWSTR>(m_strFriendlyName.c_str()), &hPrinter, NULL) == 0 )
  {    
    /*OpenPrinter call failed*/
    return false;
  }

  DWORD dwBufsize = 0;
  PRINTER_INFO_2* pinfo = 0;
  GetPrinter(hPrinter, 2,(LPBYTE)pinfo, dwBufsize, &dwBufsize); //Get dwBufsize

  PRINTER_INFO_2* pinfo2 = (PRINTER_INFO_2*)malloc(dwBufsize); //Allocate with dwBufsize
  GetPrinter(hPrinter, 2,(LPBYTE)pinfo2, dwBufsize, &dwBufsize);

  DWORD numJobs = pinfo2->cJobs;
  free(pinfo2); 

  JOB_INFO_1 *pJobInfo = 0;
  DWORD bytesNeeded = 0, jobsReturned = 0;

  //Get info about jobs in queue.
  EnumJobs(hPrinter, 0, numJobs, 1, (LPBYTE)pJobInfo, 0,&bytesNeeded,&jobsReturned);
  pJobInfo = (JOB_INFO_1*) malloc(bytesNeeded);
  EnumJobs(hPrinter, 0, numJobs, 1, (LPBYTE)pJobInfo, bytesNeeded, &bytesNeeded, &jobsReturned);


  JOB_INFO_1 *pJobInfoInitial = pJobInfo;
  for(unsigned short count = 0; count < jobsReturned; count++)
  {
    if (pJobInfo != NULL)
    {
      strDocName  = pJobInfo->pDocument; // Document name
      DWORD dw = pJobInfo->Status;         
    }
    pJobInfo++;
  }

  free(pJobInfoInitial);
  ClosePrinter( hPrinter );
  return strDocName;
}
我很坚强 2025-01-13 13:35:43

您可能看到的是应用程序提交给打印后台处理程序的文档名称。此外,它可能不可靠,但大多数打印驱动程序将 PJL 或 XML 格式的文档名称放在打印作业的顶部。通过一些灵活的规则,您也许能够充满信心地提取这些数据。

当然,这假设 PS 数据是由打印机驱动程序生成的。

What you might be seeing is the document name that the application submitted to the print spooler. Also, it may not be reliable but most print drivers put the document name in PJL or XML at the top of the print job. With some flexible rules you might be able to pull this data with some confidence.

This, of course, assumes that the PS data was generated by a printer drivers.

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