1. Mariano Recuero
  2. PowerBuilder
  3. Wednesday, 18 April 2018 10:34 AM UTC

Hi,

I have created a webservice from PB 12.5 Classic.

Webservice got a function that receive some parameters, retrieve data from DB in a datastore and then save ds as a pdf file (in C:\temp\PDFs\) and then return name and path of file created.

From Asp.Net MVC i call webservice and then i receive path and name of new file.

Problem is that everything works fine but save ds as pdf file.

I got installed GS and a printer for creating PDF

Any idea about this error and solution?

This is the code in NVO (always return ERROR_-2):

dataStore ldst_report
string ls_dataobject, ls_filename, ls_path, ls_filenameguid
long ll_rows, ll_return

this.of_populatedbparm (as_server, as_database, as_user, as_password)

if not SQLCA.of_isconnected( ) Then 
    
    IF SQLCA.of_connect( ) = -1 Then             
        as_filename = "ERROR_-1 "
        Return
    end if
    
end if

ls_filenameguid = as_filename

as_filename = "ERROR_0"

ls_dataobject = as_report + "_" + as_language
ldst_report = CREATE dataStore
ldst_report.dataObject = ls_dataobject
ldst_report.SetTransObject(SQLCA)
ll_rows = ldst_report.Retrieve(al_centroid, as_sqlwhere, as_userid, as_rolename, as_applicationname, as_sqldateformat)
al_rows = ll_rows

if ll_rows > 0 Then
    
    ls_path = "C:\temp\PDFs\"
    ls_filename = ls_filenameguid + ".pdf"
    ls_path = ls_path + ls_filename
    
    ldst_report.Object.DataWindow.Export.PDF.Method = Distill!
    ldst_report.Object.DataWindow.Printer = "Sybase DataWindow PS"
    ldst_report.Object.DataWindow.Export.PDF.Distill.CustomPostScript="No"
    
    ll_return = ldst_report.SaveAs(ls_path, PDF!, TRUE)    
    as_filename = ls_filename
    if (ll_return <> 1) Then as_filename = "ERROR_-2 " + ls_path
    
End If

DESTROY ldst_report

SQLCA.of_disconnect( )

Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 18 April 2018 13:33 PM UTC
  2. PowerBuilder
  3. # 1

Hi Mariano;

      As a Web Service under IIS you do not have access to the PostScript printer under GhostScript. I solved this issue many years ago in my framework. You can read more about this from this blog article.

    Feel free to download the web service PDF example from here. Note that the PDF web service example uses GhostScript. However, this approach will also support the new NativePDF feature as well in PB 2017 as another alternative.

HTH
Regards ... Chris

Comment
  1. Chris Pollach @Appeon
  2. Monday, 25 June 2018 18:24 PM UTC
Hi Mariano;



  If you change the location of where the Web Service source code is ... you need to update the Controller and Interface classes in the "PDF_WebService.pbl;" library with the location that you are using in the PB IDE.







Also, make sure that you set debugging on in the WebService.INI file and then look for the WS's log file in the WS work area for more information.



HTH



Regards ... Chris

  1. Helpful
  1. Mariano Recuero
  2. Tuesday, 26 June 2018 15:15 PM UTC
Hi,



it's working right but PDF generation fails:



2018/06/26 17:07:52 - Start of PDF generation!

2018/06/26 17:07:52 - Run API => C:\Dev\PB12\STD_FC_PDF\Deploy\PDFCreate.exe C:\Dev\PB12\STD_FC_PDF\Deploy\CustomerList.pdf

2018/06/26 17:07:52 - PDF generation - RC: -1



¿exe got to be in the same directory than webservice?

  1. Helpful
  1. Chris Pollach @Appeon
  2. Tuesday, 26 June 2018 17:21 PM UTC
One positive step! ... You are almost there though!



First of all, make sure that the PDFCreate App works from the IDE. If necessary, recompile the EXE to make sure that it matches your build of Appeon PB. Then you can deploy it to a folder under IIS. Make sure that the folder you create under IIS (ie: c:\inetpub\wwwroot\pdf) has "everyone" (or at least IIS_IUSRS) privileges and that the new folder is not write protected.



Now make sure that you change the WebService.INI PDF section to match where you deployed the CreatePDF.exe, as follows:



[PDF]

EXE_Path=C:\inetpub\wwwroot\Reports\

EXE_Name=PDFCreate.exe

PDF_Path=C:\inetpub\wwwroot\Reports\

PDF_Name=CustomerList.pdf



Also when running the CreatePDF app, its built from the Integrated framework and will create a log in the same folder as the EXE. Make sure that you check this log as well for issues when this App is called from the WebService.



 



PS: Run the CreatePDF.exe from its installed folder and see if it works OK. There might be a GhostScript issue that needs attention first. Like properly installing the printer "Sybase DataWindow PS" printer from the GhostScript LIB folder, forgetting to add GS_DLL to the environment variables of the IIS server, etc.



HTH



Regards ... Chris

  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.