I have an ASP web page printing a word document using the PDF Converter. It was working fine for awhile, but now I get a zero-byte PDF file.
Any possible explanations?
----------------------
PDF File has zero (0) bytes
I found the problem.
the WordApplication.PrintOut function was printing in background mode and I closed the application with WordApplication.Quit(noSaveOption). Apparently the application was quitting before the Print was Queuing or something.
Anyway, when I change the PrintOut function to not print in background mode it worked fine.
Thanks for the response.
the WordApplication.PrintOut function was printing in background mode and I closed the application with WordApplication.Quit(noSaveOption). Apparently the application was quitting before the Print was Queuing or something.
Anyway, when I change the PrintOut function to not print in background mode it worked fine.
Thanks for the response.
Sample of my ASP VBScript code
This is the code that is working for me.
Hope it helps some of your users of your PDF Converter.
-----------------------------------------------------------------
[size=9]
<html>
<head>
<title>page 1</title>
</head>
<%
'------------------------------------------------------------------
' This is an example of using the Amyuni PDF Converter
' in ASP server side code written using VBScript
'
' This is provided with no support, as-is. Use it at your own
' risk.
'
' This example opens a MS Word Template file (e.g. temp.dot)
' Substitutes a value in the template (textSubstitute)
' Prints the Word file to a PDF file using Amyuni PDF Converter
' and Exits without saving the file.
'------------------------------------------------------------------
'------------------------------------------------------------------
' here we go...initialize some things.
'------------------------------------------------------------------
filename = "myFile"
WordTemplfile = "W2PDFs/temp.dot"
PDFfile = "W2PDFs/" & EID & ".pdf"
textSubstitute = "1111111111"
'------------------------------------------------------------------
' open MSword to do the print
'------------------------------------------------------------------
Const wdAlertsNone = 0
Const wdAlertsAll = -1
Set MSWord = Server.CreateObject( "Word.Application" )
TempPrinter = MSWord.ActivePrinter
MSWord.ActivePrinter = "Amyuni PDF Converter"
MSWord.Visible = False
MSWord.DisplayAlerts = wdAlertsNone
'------------------------------------------------------------------
' Open the template file (WordTemplfile = temp.dot)
'------------------------------------------------------------------
'
Dim MSDoc
Set MSDoc = MSWord.documents.add(Server.MapPath(WordTemplfile))
'------------------------------------------------------------------
' substitute the new value
'------------------------------------------------------------------
' position the insertion point to the beginning of the file
MSDoc.Range(0,0).select()
' find the string to replace and select it
strFind = "<<Find This...>>"
With MSWord.Selection.Find
.ClearFormatting()
.Text = strFind
.Execute
End With
' replace the old (selected) text with the new text
MSWord.Selection.text = textSubstitute
'------------------------------------------------------------------
' print it to PDF
' use the Amyuni driver to print the W2 to PDF
'------------------------------------------------------------------
Const SendToCreator = &H2000000
Const LinearizeForWeb = &H8000
Const NoPrompt = &H1
Const UseFileName = &H2
Set CDINTF = Server.CreateObject("CDINTFEX.CDINTFEX")
CDINTF.DriverInit( "Amyuni PDF Converter" )
CDINTF.FileNameOptionsEx = NoPrompt + UseFileName + LinearizeForWeb + SendToCreator
CDINTF.DefaultFileName = Server.MapPath(PDFfile)
CDINTF.SetDefaultPrinter
CDINTF.EnablePrinter "Your License Company Name, Inc.", _
"Your License Code - E.G.8348373HDKDI3673T3FB3873YTDV237B3..."
'------------------------------------------------------------------
' print the Word file
'------------------------------------------------------------------
Const wdDoNotSaveChanges = 0
MSDoc.PrintOut False, False, 0, Server.MapPath(PDFfile), "", "", 0, 1, "", 0, True, False
MSWord.ActivePrinter = TempPrinter
MSWord.Quit(wdDoNotSaveChanges)
set MSWord = nothing
CDINTF.DriverEnd
set CDINTF = Nothing
%>
<body>
Your HTML here...
</body>
</html>
[/size]
Hope it helps some of your users of your PDF Converter.
-----------------------------------------------------------------
[size=9]
<html>
<head>
<title>page 1</title>
</head>
<%
'------------------------------------------------------------------
' This is an example of using the Amyuni PDF Converter
' in ASP server side code written using VBScript
'
' This is provided with no support, as-is. Use it at your own
' risk.
'
' This example opens a MS Word Template file (e.g. temp.dot)
' Substitutes a value in the template (textSubstitute)
' Prints the Word file to a PDF file using Amyuni PDF Converter
' and Exits without saving the file.
'------------------------------------------------------------------
'------------------------------------------------------------------
' here we go...initialize some things.
'------------------------------------------------------------------
filename = "myFile"
WordTemplfile = "W2PDFs/temp.dot"
PDFfile = "W2PDFs/" & EID & ".pdf"
textSubstitute = "1111111111"
'------------------------------------------------------------------
' open MSword to do the print
'------------------------------------------------------------------
Const wdAlertsNone = 0
Const wdAlertsAll = -1
Set MSWord = Server.CreateObject( "Word.Application" )
TempPrinter = MSWord.ActivePrinter
MSWord.ActivePrinter = "Amyuni PDF Converter"
MSWord.Visible = False
MSWord.DisplayAlerts = wdAlertsNone
'------------------------------------------------------------------
' Open the template file (WordTemplfile = temp.dot)
'------------------------------------------------------------------
'
Dim MSDoc
Set MSDoc = MSWord.documents.add(Server.MapPath(WordTemplfile))
'------------------------------------------------------------------
' substitute the new value
'------------------------------------------------------------------
' position the insertion point to the beginning of the file
MSDoc.Range(0,0).select()
' find the string to replace and select it
strFind = "<<Find This...>>"
With MSWord.Selection.Find
.ClearFormatting()
.Text = strFind
.Execute
End With
' replace the old (selected) text with the new text
MSWord.Selection.text = textSubstitute
'------------------------------------------------------------------
' print it to PDF
' use the Amyuni driver to print the W2 to PDF
'------------------------------------------------------------------
Const SendToCreator = &H2000000
Const LinearizeForWeb = &H8000
Const NoPrompt = &H1
Const UseFileName = &H2
Set CDINTF = Server.CreateObject("CDINTFEX.CDINTFEX")
CDINTF.DriverInit( "Amyuni PDF Converter" )
CDINTF.FileNameOptionsEx = NoPrompt + UseFileName + LinearizeForWeb + SendToCreator
CDINTF.DefaultFileName = Server.MapPath(PDFfile)
CDINTF.SetDefaultPrinter
CDINTF.EnablePrinter "Your License Company Name, Inc.", _
"Your License Code - E.G.8348373HDKDI3673T3FB3873YTDV237B3..."
'------------------------------------------------------------------
' print the Word file
'------------------------------------------------------------------
Const wdDoNotSaveChanges = 0
MSDoc.PrintOut False, False, 0, Server.MapPath(PDFfile), "", "", 0, 1, "", 0, True, False
MSWord.ActivePrinter = TempPrinter
MSWord.Quit(wdDoNotSaveChanges)
set MSWord = nothing
CDINTF.DriverEnd
set CDINTF = Nothing
%>
<body>
Your HTML here...
</body>
</html>
[/size]