Solved

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

Posted on 2014-10-20
2
6 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 32

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
bigHeights  challenge 13 56
Build VS2015 project in bat command 3 70
base64 decode encode 12 98
Need more details 5 85
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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 …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now