I need some support to solve an issue of exporting report in PDF format.
I'm developing a web application, using Javascript, IIS (VBScript) and SQL Server.
The report part is working fine, for preview (using viewer) our direct printing (no displaying of viewer, directly go the printer).
I want to add a 3rd option, where user can directly export the report in PDF format without the need of displaying the viewver first, like the direct print.
I have used the sample provided, for some test, but no file is generated. After debuging, I can see that data are well passed to the saveAs method.
After some investigation on the net, it seems that it's coming from the web server. The solution i found was to change MIME type of the PDF file on IIS, from "application/pdf" to "application/octet-stream".
I did it on both IIS on source code, but nothing ... Still not working ...
This is a part of the code doing the export, after an AJAX call to query data on the SQL server (code is at 90% same as direct print which is working fine) :
Code: Select all
// Lancement du code d'appel AJAX à la fonction de recherche des infos
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200)
{
// réception des données en provenance de la fonction select
donnees = JSON.parse(this.responseText);
// Lancement de l'export
// sélection de la langue francaise
Stimulsoft.Base.Localization.StiLocalization.setLocalizationFile("xml/reports_fr.xml", true);
dataSet = new Stimulsoft.System.Data.DataSet(keep.vue);
report = new Stimulsoft.Report.StiReport();
dataSet.readJson(donnees);
report.load(RenvoieEtat(num_report));
report.dictionary.databases.clear();
report.dictionary.dataSources.clear();
report.regData(dataSet.dataSetName, dataSet.dataSetName, dataSet);
report.dictionary.synchronize();
report.renderAsync(function () {
// export du rapport
report.exportDocumentAsync(function (pdfData) {
// Nom du fichier
nom_fichier = report.reportAlias + ".pdf";
// Enregistrement des données dans un fichier PDF
Stimulsoft.System.StiObject.saveAs(pdfData, nom_fichier, "application/pdf");
}, Stimulsoft.Report.StiExportFormat.Pdf);
});
}
}
URL = "framework/ajax/select_print.asp"
if (parametres!=="")
URL = URL + "?" + parametres;
xmlhttp.open("GET", URL, true);
xmlhttp.send();
B.R