Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
7
Erster Beitrag:
vor 5 Jahren, 4 Monaten
Letzter Beitrag:
vor 5 Jahren, 4 Monaten
Beteiligte Autoren:
Piet van Zanten, Paulo Oliveira, Clarion Ghost, Steven Sitas

Displaying a PDF file in a NewBrowser

Startbeitrag von Clarion Ghost am 24.07.2012 08:00

Hi,

I have this code running. The on line help shows NewBrowser as being an option as a 'Target'. (Current Browser being the default.) The examples shown aren't helping me to understand what I have to do.

How do I adapt the following code to display in a separate window?

// Create a unique file name
File is string = fDataDir()+"\"+DateSys()+TimeSys()+".pdf"

// Print the report in a PDF file
iDestination(iPDF, File)

// Generate the report
iPrintReport(RPT_Occupier_Statement,RPTStartDate,RPTFinishDate,OccupantNumber,RPT_OB,RPT_CB)

// Display the report in PDF format
FileDisplay(File,"application/pdf")

// Delete the file
fDelete(File)

Many Thanks

Antworten:

If you use filedisplay in browser code you can change the target to NewBrowser but in this case you have to create to file in the fWebDir and use the url instead of the file name.

for the filedisplay in the server code you can use the changetarget function.

don't forget that the sintax of filedisplay is diferent in browser/server code.

http://doc.windev.com/en-US/?3058005&name=changetarget-function
http://doc.windev.com/en-US/?3012005&name=filedisplay-function

von Paulo Oliveira - am 24.07.2012 09:26
Hi Ian,

If you specify a third parameter for FileDisplay "Filename for backup" then the user will get a popup to choose whether to display the file in the PDF reader or download it. This parameter will contain only the name of the file, not the path.

Regards,
Piet

von Piet van Zanten - am 24.07.2012 09:41
Hi,

I am far from understanding how to make this work? This prints the pdf in the current browser. Do I modify fWebDir() to get the result I am looking for?

// Create a unique file name
File is string = fDataDir()+"\"+DateSys()+TimeSys()+".pdf"

// Print the report in a PDF file
iDestination(iPDF, File)

// Generate the report
iPrintReport(RPT_Occupier_Reconciliation,RPTStartDate,RPTFinishDate,OccupantNumber)

// Display the report in PDF format

File = fWebDir() + File //"/MyFile.pdf"

FileDisplay(File, "application/pdf")

// Delete the file
fDelete(File)

Many Thanks

von Clarion Ghost - am 24.07.2012 11:50
no, you can't just change from fDataDir to fWebDir at that point.
File is string = fWebDir()+"\"+DateSys()+TimeSys()+".pdf"

To use filedisplay in browser code you need to create the file in one directory accessed thru http.
The code you are presenting is server code, in this case changetarget can help you.

Check the help for filedisplay function to see the sintax for server/browser code.

von Paulo Oliveira - am 24.07.2012 12:01
Hi Ian,

Adding a third parameter does not seem so hard to understand, but to be more specific, just change:
FileDisplay(File, "application/pdf")
to
FileDisplay(File, "application/pdf",DateSys()+TimeSys()+".pdf)

The third parameter is the name that is used by default if the user chooses to download the file.

Regards,
Piet

von Piet van Zanten - am 24.07.2012 12:07
Hi Ian,
Here is the code I use to generate PDF files (from Reports) and then show them on the CURRENT FRAME (Window)
//////////////////////////////////////////////////////////////////////////////
gsMyGuiD is string
gsTempFile is string

// Get a unique GuiD to construct the name of my temporary file
gsMyGuiD=GetGUID()

// Now construct the actual name of the temporary file
gsTempFile= fDataDir() + "\"+ gsMyGuiD+".pdf"

// send the next report to a pdf file with the name of gstempfile
iDestination(iPDF, gsTempFile)

// this is only needed if you have a query in your report – so initialize the query
iInitReportQuery(RPT_Payroll,p_EmpSeq,p_PeriodSeq)

// Print the report
iPrintReport(RPT_Payroll)

// Now Display the pdf in your CURRENT FRAME/Browser Window
FileDisplay(gsTempFile,"application/pdf")

// Delete the file
fDelete(gsTempFile)
////////////////////////////////////////////////////////////////////

So If you would like to display the PDF in another Browser Window, you need to CHANGE the following code:
FileDisplay(gsTempFile,"application/pdf")

Take a look at the FileDisplay in your help: http://doc.windev.com/en-US/?3012005&name=filedisplay-function
Just pass to FileDisplay the parameter NewBrowse .


Steven Sitas

von Steven Sitas - am 25.07.2012 11:23
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.