VeryPDF / DocPrint Support, how to set output PDF file name

Hello - we instant messaged each other and I'm trying to get docprint to work in Visual FoxPro with my Omni ActiveX control.

I have found that this command works just fine:

docPrint = CreateObject("DocPrintCom.docPrint")
But - I need to send printer output to it.  I'm not sure if I need to change the default printer or not.  Currently, I can print the ActiveX control like this (where oForm is set to the OmniForm activeX control)

thisform.oForm.printform(1, thisform.oForm.pagecount, 1)

The parameters for the method printform are  printform(frompage, topage, copies)

That command will print to the default printer.  How can I get it to print to a PDF using your control and name it something like  C:\TEST.PDF  ?

Thank you.
===============================
You can call SetOutputFileName_docPrintPDFDriver() function from your code to set the output filename to docPrint PDF Driver, please refer to following sample code,

****************************************************
'Default output filename, you can change it to anything that you want
Const szOutputFileName = "C:\docPrint_output.pdf"

'You can select docPrint or docPrint PDF Driver printers at here
Const sPrinterName = "docPrint PDF Driver"

Private Declare Function SetDefaultPrinter Lib "winspool.drv" Alias "SetDefaultPrinterA" (ByVal pszbuffer As String) As Long

Sub SaveString(hKey As Long, strPath As String, strValue As String, strData As String)
Dim Ret
'Create a new key
RegCreateKey hKey, strPath, Ret
'Save a string to the key
RegSetValueEx Ret, strValue, 0, REG_SZ, ByVal strData, LenB(strData)
'close the key
RegCloseKey Ret
End Sub

Sub SaveStringLong(hKey As Long, strPath As String, strValue As String, strData As Long)
Dim Ret
'Create a new key
RegCreateKey hKey, strPath, Ret
'Set the key's value
RegSetValueEx Ret, strValue, 0, REG_DWORD, strData, 4
'close the key
RegCloseKey Ret
End Sub

Private Sub SetOutputFileName_docPrintPDFDriver(ByVal m_ptrOutputFile As String)
SaveStringLong HKEY_CURRENT_USER, "Software\verypdf\pdfcamp", "AutomaticOutput", 1
SaveStringLong HKEY_CURRENT_USER, "Software\verypdf\pdfcamp", "AutomaticValue", 2
SaveStringLong HKEY_CURRENT_USER, "Software\verypdf\pdfcamp", "AutoView", 0

'SaveStringLong HKEY_CURRENT_USER, "Software\verypdf\pdfcamp", "EmbedNum", 0
SaveStringLong HKEY_CURRENT_USER, "Software\verypdf\pdfcamp", "Unit", 3

SaveStringLong HKEY_CURRENT_USER, "Software\verypdf\pdfcamp", "PageSelect", 10
SaveStringLong HKEY_CURRENT_USER, "Software\verypdf\pdfcamp", "PageSize", 7

SaveStringLong HKEY_CURRENT_USER, "Software\verypdf\pdfcamp", "Bitcount", 1
SaveStringLong HKEY_CURRENT_USER, "Software\verypdf\pdfcamp", "xResolution", 300
SaveStringLong HKEY_CURRENT_USER, "Software\verypdf\pdfcamp", "yResolution", 300
SaveStringLong HKEY_CURRENT_USER, "Software\verypdf\pdfcamp", "PageW", 0
SaveStringLong HKEY_CURRENT_USER, "Software\verypdf\pdfcamp", "PageH", 0

SaveString HKEY_CURRENT_USER, "Software\verypdf\pdfcamp", "AutomaticDirectory", m_ptrOutputFile
End Sub

Private Sub PrintWord_Click()
' You need install MS Word in order to get this function to work

SetDefaultPrinter sPrinterName
SetOutputFileName_docPrintPDFDriver szOutputFileName

On Error GoTo FileOpenDlg_ErrHandler
FileOpenDlg.CancelError = True
FileOpenDlg.Flags = cdlOFNFileMustExist Or cdlOFNPathMustExist Or cdlOFNExplorer Or cdlOFNLongNames
FileOpenDlg.Filter = "MS Word documents (*.doc)|*.doc"
FileOpenDlg.FilterIndex = 1
FileOpenDlg.ShowOpen

On Error Resume Next
Dim wordApp As Object
Dim wDoc As Object

Set wordApp = CreateObject("Word.Application")

Err = 0
Set wDoc = wordApp.Documents.Open(FileOpenDlg.FileName, , 1)

If Err = 0 Then
wordApp.ActivePrinter = sPrinterName
Call wordApp.PrintOut(False)

wDoc.Close
Set wDoc = Nothing
End If

Call wordApp.Quit
Set wordApp = Nothing

FileOpenDlg_ErrHandler:
Exit Sub

End Sub
****************************************************

You can call SetDefaultPrinter() function to set "docPrint PDF Driver" to default printer, call SetOutputFileName_docPrintPDFDriver() function to set output filename, then you can print a document to "docPrint PDF Driver" printer, you will get a PDF file at specify path easily.

VeryPDF
====================================
I saw this example:

Private Sub Command1_Click()
Set docPrint = CreateObject("DocPrintCom.docPrint")
nRet = docPrint.docPrintCOM_Register("XXXXXXXXXXXXXX", "VeryPDF.com Company")
nRet = docPrint.RunCmd("-i https://www.verypdf.com -o C:\output.pdf -* XXXXXXXXXXXXXX -d -O 2 -s ShowHTMLStatusBar=1 -l 10000", 0)
MsgBox "Return value = " & Str(nRet)
End Sub

But how do I print to a file from the Omni control with:  thisform.oForm.printform(1, thisform.oForm.pagecount, 1)

Also, I have the trial version so do I just skip the register command?

Thanks,
====================================
You can call SetOutputFileName_docPrintPDFDriver() function from your code to set the output filename to docPrint PDF Driver, please refer to following sample code,

====================================
'Default output filename, you can change it to anything that you want
Const szOutputFileName = "C:\docPrint_output.pdf"

'You can select docPrint or docPrint PDF Driver printers at here
Const sPrinterName = "docPrint PDF Driver"

Private Declare Function SetDefaultPrinter Lib "winspool.drv" Alias "SetDefaultPrinterA" (ByVal pszbuffer As String) As Long

Private Sub SetOutputFileName_docPrintPDFDriver(ByVal m_ptrOutputFile As String)
SaveStringLong HKEY_CURRENT_USER, "Software\verypdf\pdfcamp", "AutomaticOutput", 1
SaveStringLong HKEY_CURRENT_USER, "Software\verypdf\pdfcamp", "AutomaticValue", 2
SaveStringLong HKEY_CURRENT_USER, "Software\verypdf\pdfcamp", "AutoView", 0

'SaveStringLong HKEY_CURRENT_USER, "Software\verypdf\pdfcamp", "EmbedNum", 0
SaveStringLong HKEY_CURRENT_USER, "Software\verypdf\pdfcamp", "Unit", 3

SaveStringLong HKEY_CURRENT_USER, "Software\verypdf\pdfcamp", "PageSelect", 10
SaveStringLong HKEY_CURRENT_USER, "Software\verypdf\pdfcamp", "PageSize", 7

SaveStringLong HKEY_CURRENT_USER, "Software\verypdf\pdfcamp", "Bitcount", 1
SaveStringLong HKEY_CURRENT_USER, "Software\verypdf\pdfcamp", "xResolution", 300
SaveStringLong HKEY_CURRENT_USER, "Software\verypdf\pdfcamp", "yResolution", 300
SaveStringLong HKEY_CURRENT_USER, "Software\verypdf\pdfcamp", "PageW", 0
SaveStringLong HKEY_CURRENT_USER, "Software\verypdf\pdfcamp", "PageH", 0

SaveString HKEY_CURRENT_USER, "Software\verypdf\pdfcamp", "AutomaticDirectory", m_ptrOutputFile
End Sub

Private Sub PrintForm_Click()

SetDefaultPrinter sPrinterName
SetOutputFileName_docPrintPDFDriver szOutputFileName

thisform.oForm.printform(1, thisform.oForm.pagecount, 1)
End Sub
====================================

You can call SetDefaultPrinter() function to set "docPrint PDF Driver" to default printer, call SetOutputFileName_docPrintPDFDriver() function to set output filename, then you can print a document to "docPrint PDF Driver" printer, you will get a PDF file at specify path easily.

In above example, you can call “thisform.oForm.printform(1, thisform.oForm.pagecount, 1)” function to print the document to docPrint PDF Driver and create PDF file easily, please to try.

VeryPDF
====================================

VN:F [1.9.20_1166]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *


Verify Code   If you cannot see the CheckCode image,please refresh the page again!