Need help with creation of PDF file

The Amyuni PDF Converter is our Printer Driver that enables you to convert any documents to PDF format. If you have any questions about installing and using the Amyuni PDF Converter please post them here.
Post Reply
Arsen
Posts: 1
Joined: Thu Jul 27 2006

Need help with creation of PDF file

Post by Arsen »

Hi,
If someone can please proof read and help me find the reason why I can’t create the PDF file.

When I run bellow pasted code it freezes when tmpPrnDoc.Print() line is reached. Any ideas what can cause it?


Private Sub CreatePDF()

Dim strPrinter, strFileName, sPath, sOutputFile As String
Dim strLicensee, strActivation, sCurrentSession As String
Dim Dr As Directory
Dim pdf As New CDIntfEx.CDIntfEx
Dim tmpPrnDoc As PrintDocument

Try
strPrinter = "GFSPDFPrinter"
sCurrentSession = Session.SessionID

sPath = ConfigurationSettings.GetConfig("Paths")("pdfPath")

If Not Dr.Exists(sPath) Then
Dr.CreateDirectory(sPath)
sPath = sPath + "\"
End If

strFileName = sCurrentSession & ".pdf"
sOutputFile = sPath & strFileName

pdf.DriverInit(strPrinter)
pdf.PrinterLanguage = 1
pdf.EnablePrinter(Licensee, ActivationCode)
pdf.Resolution = 600
pdf.SetDefaultPrinter()
pdf.FileNameOptionsEx = 1 + 2 + 16 + 2097152 + 4194304 + 16777216
pdf.DefaultFileName = sOutputFile

tmpPrnDoc = New PrintDocument
AddHandler tmpPrnDoc.PrintPage, New System.Drawing.Printing.PrintPageEventHandler(AddressOf toPrinter)

tmpPrnDoc.Print()
pdf.RestoreDefaultPrinter()
pdf.DriverEnd()
pdf = Nothing



Catch ex As Exception
Response.Write(ex.ToString)
Response.End()
Finally

Response.Flush()
Response.Close()
End Try


End Sub
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

I beleive you need to change the place of your call to pdf.EnablePrinter(Licensee, ActivationCode)

Please call EnablePrinter() right after your call to DriverInit and right before your call tmpPrnDoc = New PrintDocument

This should help.
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

I will move this post to the PDF Converter forum because the product used to convert documents to PDF is the PDF Converter and not the PDF Creator.
Post Reply