Submitting a Document to Print

If you are a VB developer and have questions about using our products from VB, here is the place to post them.
Post Reply
brianp
Posts: 10
Joined: Thu Oct 16 2003

Submitting a Document to Print

Post by brianp »

Is there a function or property that can be set to specify what document needs to be converted to PDF? I am using the Developer version 2.10e of Document converter. In the application, I will have an Excel file and it would go through and initialize everything and then specify the path and file name of the Excel file to convert to PDF. Is there something that could make this happen or do I have to go through and instantiate the Excel object through the application and then call print? My application is in C++.

Thanks in advance.
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

You can use our BatchConvert() function to convert 1 or more files in one folde to pdf. You will find more information about BatchConvert() in our developers' manual.

You may also open the Excel file from inside C++ and call Print, I don't have a C++ sample to do so but I can post a VB sample if it helps.

Thanks.
brianp
Posts: 10
Joined: Thu Oct 16 2003

Submitting a document to print

Post by brianp »

Thanks I will look into the BatchConvert() if you could provide a VB sample that would help out alot.

Thanks,
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hi,

Please find here a VB6 sample to open an Excel file and print it to the PDF Printer. In this sample all the commands are included in one sub command1_click() but in reality you can add the declarations under General in the Form load event.

Also, a good practice would be to initialize the PDF Printer,call DriverInit, when launching your application and call DriverEnd before closing your application and not when printing ends.

Here I am assuming that the whole application is just one sub.

Private Sub Command1_Click()

'Create an instance of the Excel application and an Excel Workbook.
Dim xlApp As New Excel.Application
Dim wkBook As New Excel.Workbook

'Declare a new CDintfEx object
Dim pdf As New CDIntfEx.CDIntfEx

'Attach to the existing PDF Printer
pdf.DriverInit "Amyuni PDF Converter"

'Enable the Printer
'pdf.EnablePrinter LicenseTo, ActivationCode

' set output PDF file name
pdf.DefaultFileName = "C:\Temp\Test.pdf"

' Set File options.
pdf.FileNameOptionsEx = 1 + 2 ' NoPrompt + UseFileName

' Open a workbook
Set wkBook = xlApp.Workbooks.Open("C:\Temp\ExcelCharts.xls")

'Call EnablePrinter right before each printout or in the EnablePre event.
pdf.EnablePrinter LicenseTo, ActivationCode

' Print the workbook ( with the default options of the printer)
wkBook.PrintOut ActivePrinter:=PrinterName

'Close the opened workbook
wkBook.Close

' Quit Word
wordapp = Quit

' Reset 0ptions to zero
pdf.FileNameOptionsEx = 0

pdf.DriverEnd

'Release used objects
Set wkBook = Nothing
Set xlApp = Nothing
Set pdf = Nothing

Hope this helps.
Post Reply