Solved

I have problems getting Acrobat PDF programmatically getting the filename to print the PDF using the register.

Posted on 2014-10-20
2
14 Views
Last Modified: 2016-06-22
I need help with getting Acrobat to bypass the save dialog for filenames in order to programmatically add the filename and continue printing using the Windows registry.  I have been reading in distiller manual and Q&A sites that this would work.    I did get filenames listed in the registry sometimes, but nothing happened.  Most of the time I
get  my document path only and untitled.pdf as the filename.  Once I got the filename only with no path.  Here is some code attached below...


Open in new window

void CMainFV::SetAdobeRegistryPrint()
{
      CHPCCiDBApp *pTheApp = (CHPCCiDBApp *)AfxGetApp();

        LPCTSTR lpValueName;
      CONST BYTE *lpData;
      DWORD cbData;

//      HKEY hkey; // defined in mainfv.h

      if (RegOpenKey(HKEY_CURRENT_USER,_T("Software\\Adobe\\Acrobat Distiller\\PrinterJobControl"),&hkey) != ERROR_SUCCESS)    // (handle to open key,,  subkeys to open, handle address to open key
      {
                  AfxMessageBox("Unable to open registry key!", MB_OK);
                  return;
      }

      if (pTheApp->OS_ProcessorType == 64)
      {
         lpValueName = "LastPdfPortFolder - splwow64.exe";
        // lpValueName = "40cd65f0";

      }
      else  // 32
      {

            AfxMessageBox("just a check!", MB_OK);
                        

      }

      
      if (RegSetValueEx(hkey, lpValueName, 0, REG_SZ,  (LPBYTE) "C:\\Users\\JOHNM\\Documents\\FUNZ.pdf",  strlen("C:\\Users\\JOHNM\\Documents\\FUNZ.pdf") * sizeof(char)) != ERROR_SUCCESS)
      {
            RegCloseKey(hkey);
            AfxMessageBox("Unable to set registry value name!", MB_OK);
      }
      else
            AfxMessageBox("Registry value name set!", MB_OK);




}
0
Comment
Question by:John Morrison
2 Comments
 
LVL 34

Accepted Solution

by:
sarabande earned 500 total points
ID: 40393870
why not calling ShellExecute with "print" option?

if acrobat was associated to .pdf print, you would call

ShellExecute(NULL, _T("print"),  strPathToFile, NULL, NULL, SW_HIDE);

Open in new window

where strPathToFile should be a full qualified path to the pdf file to print.

if another printer for .pdf is associated (type "assoc .pdf" in a command window) you could try

ShellExecute(NULL, _T("print"),  strPathToAcrobatExe, strPathToFile, NULL, SW_HIDE);

Open in new window

which would invoke acrobat and pass the filename as first argument.

Sara
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question