PDF File has zero (0) bytes

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
dvreeland
Posts: 4
Joined: Tue Dec 07 2004

PDF File has zero (0) bytes

Post by dvreeland »

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?

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

Post by Joan »

Hello,

What are the changes you made before you application starts generating 0 bytes files?

Did you make any changes to your application or to the version of the PDF Converter you are using?

Also, if you try to open the 0 bytes files, will you be able to view the file properly?

Thanks.
dvreeland
Posts: 4
Joined: Tue Dec 07 2004

Post by dvreeland »

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.
dvreeland
Posts: 4
Joined: Tue Dec 07 2004

Sample of my ASP VBScript code

Post by dvreeland »

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]
Post Reply