Problem reading this document (135)

If you are a VFP developer and have any questions about using our products from VFP here is the place to post them.
Post Reply
jhhaidar
Posts: 3
Joined: Mon Oct 24 2005
Location: Little Rock
Contact:

Problem reading this document (135)

Post by jhhaidar »

we have a VFP application that is generating a PDF file from VFP report.
first the default printer is set to PDF Converter 2.05 See code Below:

if the following VFP REPORT FORM is executed once, then the PDF is readable

For example:
REPORT FORM c:\renewalreports\rpts\rptRenewals TO PRINT NOCONSOLE


but when it is Executed more than twice, then the PDF become unresdable and I will get the following error:

" There was a problem reading this document (135) "

When openning the PDF file.


is anyone familiar with the error above??



Thanks,
Jean Haidar
jhhaidar@sbcglobal.net


Here how I am creating the PDF Converter from a Method in a Form:


#DEFINE pdf_NoPrompt 1 && do not prompt for file name
#DEFINE pdf_UseFileName 2 && use file name set by SetDefaultFileName else use document name
#DEFINE pdf_Concatenate 4 && concatenate files, do not overwrite
#DEFINE pdf_DisableCompression 8 && disable page content compression
#DEFINE pdf_EmbedFonts 16 && embed fonts used in the input document
#DEFINE pdf_BroadcastMessages 32 && enable broadcasting of PDF events

LOCAL lcObjectName, lcDriverInit
WITH THISFORM
* .cOldError = ON("error") && Current on error routine
.cPrinterName = SET("Printer", 3) && Save the current VFP printer name.

* This class can be used stand alone or within an application using the app object

.oPDFPrinter = CREATEOBJECT("CDINTF.CDINTF")

.cObjectName = [THIS.oPDFPrinter]

lcObjectName = .cObjectName

* If CREATEOBJECT didn't work RETURN .f.
IF VARTYPE(&lcObjectName) <> "O"
RETURN .F.
ENDIF

* Set up our error handler, which will display LASTERRORMSG() from the PDF driver.
* ON ERROR DO .ErrHand()

* Initiate driver with name "PDF Compatible Printer Driver".
* ("PDF Compatible Printer Driver" will now appear in the list of printers.)
* lcDriverInit = lcObjectName + ".PDFDriverInit"
lcDriverInit = lcObjectName + ".DriverInit"

* &lcDriverInit('PDF Compatible Printer Driver')
&lcDriverInit('Amyuni PDF Converter')

.SetToPDFPrinter()

* set resolution to 1200 for the best quality
&lcObjectName..resolution = 1200

* update driver info with resolution info
&lcObjectName..SetDefaultConfig()

* Note: Message broadcasting should be enabled in order to insert bookmarks from VFP.
* But see the notes in the AddBookmark function below!
&lcObjectName..FileNameOptions = pdf_NoPrompt + pdf_UseFileName + pdf_BroadcastMessages + pdf_Concatenate

* Save the current Windows default printer so we can restore it later.
&lcObjectName..SetDefaultPrinter()

ENDWITH
RETURN .T.
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

What do you mean by executing the print command more than once?

- Are you trying to print to the same file before it is completely saved on disk?

- Are you trying to print to the file when it is opened?

- Are you removing the printer from the system and reinstalling it after each printout?

Please give me more information so i can help you.

Thanks.
Post Reply