Popup of nova driver when appending data

Have questions about novaPDF (desktop or server), or having problems using it? Ask here for help.
heij1421
Posts: 1
Joined: Mon Nov 29, 2010 2:36 pm

Popup of nova driver when appending data

Postby heij1421 » Mon Nov 29, 2010 2:50 pm

Hi All,

I have created a vb-script to create a PDF document and then add a *.doc, *.docx, *.xls or *.xlsx file to this PDF file.
When I run the program this 'sometimes' succeeds, but also sometimes failes. When it failed, it does not append it to the original file name, but the nova PDF driver comes with a popup screen. In this screen a file name is suggested (rad*.PDF). When I press the SAVE button ,this RAD file consists of the converted DOC document, but is was not appended to the original file name.

Can anyone help me with this? I use version 7.0 build 329 of the novapdf driver (novaPDF for SDK v7)

Part of the program:

Public Function CSAddAttachment(ByVal PrintJob As e4layout.ILayoutTransaction, ByVal sAttachment As String) As efprocess.ProcessInvoiceResult

On Error GoTo ErrorHandler:

Dim sPrinterName As String
Dim sFileName As String
Dim sExtension As String
Dim sActiveProfile As String
Dim lActiveProfilePublic As Long
Dim lPosLeft As Long
Dim lDocTeller As Long
Dim lContinue As Long

sPrinterName = ""
sFileName = ""
sExtension = ""

'Select the correct PDF printer
If PdfPrinterPresent(sPrinterName) Then
Set pNova = Nothing

Set pNova = New NovaPdfOptions

With pNova
'initilize the PDF printer

.InitializeSilent sPrinterName, NOVA_USER, NOVA_KEY, ""
'.InitializeSilent sPrinterName, "", "", ""
'and set it to default for this process
.SetDefaultPrinter
'Get the current profile
.GetActiveProfile sActiveProfile, lActiveProfilePublic
' and make a copy of it (to restore it later)
On Error Resume Next
.CopyProfile sActiveProfile, PROFILE_NAME, PROFILE_IS_PUBLIC
If Err.Number <> 0 Then
' ignore profile exists error
If NV_PROFILE_EXISTS = Err.Number Then
Debug.Print "Profile Randstad facturering already exists"
Else
Return
End If
End If
'On Error GoTo ErrorHandler:
'set the copy profile as active profile ...

'and adjust a number of settings
'.SetOptionLong NOVAPDF_SAVE_DESTINATION, False, PROFILE_NAME, PROFILE_IS_PUBLIC
'don't prompt when saving
.SetOptionLong NOVAPDF_SAVE_PROMPT, False, PROFILE_NAME, PROFILE_IS_PUBLIC
lPosLeft = InStrRev(m_sCSPDF, "\")

'but store it directly in the main PDF file
.SetOptionString NOVAPDF_SAVE_FOLDER, Left(m_sCSPDF, (lPosLeft - 1)), PROFILE_NAME, PROFILE_IS_PUBLIC
.SetOptionString NOVAPDF_SAVE_FILE, Right(m_sCSPDF, Len(m_sCSPDF) - lPosLeft), PROFILE_NAME, PROFILE_IS_PUBLIC
'and append data when it already exists
.SetOptionLong NOVAPDF_SAVE_CONFLICT_STRATEGY, FILE_CONFLICT_STRATEGY_APPEND, PROFILE_NAME, PROFILE_IS_PUBLIC
.SetOptionLong NOVAPDF_SILENT_PRINT, True, PROFILE_NAME, PROFILE_IS_PUBLIC
.SetOptionLong NOVAPDF_ACTION_OPEN_DOCUMENT, False, PROFILE_NAME, PROFILE_IS_PUBLIC
'.SetOptionLong NOVAPDF_ACTION_USE_DEFAULT_VIEWER, False, PROFILE_NAME, PROFILE_IS_PUBLIC
'make the profile active
.SetActiveProfile PROFILE_NAME, PROFILE_IS_PUBLIC
End With

'Get the document data and type
ReadAttachedDocument (sAttachment)
sExtension = GetAttachmentType(sAttachment)
sFileName = OpenAttachment(sExtension)

If Len(Trim(sFileName)) > 4 Then

Select Case UCase(sExtension)
Case "DOC", "DOCX"
' print word document
Dim objWord As Object
Dim objDoc As Object

pNova.InitializeOLEUsage "Word.Application"
Set objWord = CreateObject("Word.Application")
pNova.LicenseOLEServer

'[MARI1860 01-10-2010]BR 34.161.640 Wait for PDF print to be finished
'Register Event window and File saved event
Call pNova.RegisterEventWindow(hWnd)
Call pNova.RegisterNovaEvent(NOVAPDF_EVENT_FILE_SAVED)

Set objDoc = objWord.Documents.Open(Trim(sFileName), False, True)
objDoc.PrintOut False

'[MARI1860 01-10-2010]BR 34.161.640 Wait for PDF print to be finished
'wait till the event PDF file saved is fired by pNova
'On succes Unregister Window/event else wait.....
lContinue = 1
Do While lContinue <> 0
Call pNova.WaitForNovaEvent(60000, lContinue)
Loop
Call pNova.UnRegisterEventWindow

objDoc.Close False
objWord.Quit False

Set objWord = Nothing
Set objDoc = Nothing

Case "XLS", "XLSX"
' print excel sheet
Dim objExcel As Object

pNova.InitializeOLEUsage "Excel.Application"
Set objExcel = CreateObject("Excel.Application")
pNova.LicenseOLEServer

'[MARI1860 01-10-2010]BR 34.161.640 Wait for PDF print to be finished
'Register Event window and File saved event
Call pNova.RegisterEventWindow(hWnd)
Call pNova.RegisterNovaEvent(NOVAPDF_EVENT_FILE_SAVED)

objExcel.Workbooks.Open sFileName

objExcel.Workbooks(1).PrintOut

'[MARI1860 01-10-2010]BR 34.161.640 Wait for PDF print to be finished
'wait till the event PDF file saved is fired by pNova
'On succes Unregister Window/event else wait.....
lContinue = 1
Do While lContinue <> 0
Call pNova.WaitForNovaEvent(60000, lContinue)
Loop
Call pNova.UnRegisterEventWindow

objExcel.Workbooks(1).Close
objExcel.Workbooks(1).Quit

Set objExcel = Nothing

Case "PDF"

' wm_Nova_FileSaved = RegisterWindowMessage(MSG_NOVAPDF2_FILESAVED)
' wm_Nova_PrintError = RegisterWindowMessage(MSG_NOVAPDF2_PRINTERROR)
'
' If oldHandler <> 0 Then
' oldHandler = SetWindowLongApi(hwnd, GWL_WNDPROC, oldHandler)
' End If
' oldHandler = SetWindowLongApi(hwnd, GWL_WNDPROC, AddressOf VB_WindowProc)

' Dim r As Long
'Start the PDF print action (Use Acrobat Reader!) in a shell process via ShellExecute
pNova.RegisterEventWindow hWnd
Call pNova.RegisterNovaEvent(NOVAPDF_EVENT_FILE_SAVED)

pNova.LicenseShellExecuteFile sFileName
ShellPrintFile sFileName, GetActiveWindow()
' r = ShellExecute(hwnd, "print", sFileName, "", "", SW_HIDE)

'[MARI1860 01-10-2010]BR 34.161.640 Wait for PDF print to be finished
'wait till the event PDF file saved is fired by pNova
'On succes Unregister Window/event else wait.....
lContinue = 1
Do While lContinue <> 0
Call pNova.WaitForNovaEvent(60000, lContinue)
Loop
pNova.UnRegisterEventWindow
' oldHandler = SetWindowLongApi(hwnd, GWL_WNDPROC, oldHandler)
'Kill the Acrobat Reader Process so the process can go no
TerminateEXE ("AcroRd32.exe")

Case Else
'no action
End Select
' Return to previous settings
End If

DeleteTempAttachment (sFileName)

'Restore the original profile
pNova.SetActiveProfile sActiveProfile, lActiveProfilePublic
pNova.DeleteProfile PROFILE_NAME, PROFILE_IS_PUBLIC

'restore default printer
pNova.RestoreDefaultPrinter
Set pNova = Nothing
End If

Exit Function

ErrorHandler:
'Restore the original profile

Support
Posts: 223
Joined: Wed Dec 16, 2009 12:46 pm
Location: Cluj-Napoca, Romania
Contact:

Re: Popup of nova driver when appending data

Postby Support » Tue Nov 30, 2010 9:45 am

Hello,

The code you posted seems fine, I did not notice any problems that would generate the behavior you describe.

I suggest you install and try your application with version 7.2 of novaPDF SDK, currently available on our site, because meanwhile we made some corrections regarding the usage of profiles from SDK.

If you have the same errors with the latest version of novaPDF SDK, then please give us more information about your application:

- did you set the "Create temporary profile for each printing job" option in the novaPDF options (Profiles tab)?

- do you call this function in a multithreaded environment? Could it happen that there are executed two or more calls of this function in different threads / processes?

- when the Save As dialog appears, is it always for the same type of documents? Does it happen for Excel files?

- the "rad" prefix for the PDF file name is related to the file name of the document that is currently printed or does it have other provenience?

Thank you.


Return to “Support & Troubleshooting”