1. Olivier PAVLIN
  2. SnapDevelop
  3. Monday, 30 March 2020 17:25 PM UTC

In our process to migrate our PB solution to web Api we are facing a problem about datawindows export to PDF.

In fact it is a real important feature of our current solution, let our user beeing able to get some PDF reports on db datas and for this we use the Datawindow.Export.PDF function.

So my question is how can we provide the same PDF generation service from our web Api ?

Regards.

Donald Clayton Accepted Answer Pending Moderation
  1. Monday, 20 April 2020 15:05 PM UTC
  2. SnapDevelop
  3. # 1

I agree with Mike S. the best approach is to run a PB thread in a web service API using the ISAPI filters in TopWizWeb to run the report and return a pdf or any other format.  The ISAPI filter can be invoked as part of the call to the web service:

https://www.topwizprogramming.com/topwizweb.html

 Intertech has had great success working with TopWizWeb to add "legacy" PB features to Web API projects such as SaveAs(), HTMLGenerate(), PDF generation, etc.

 

Don Clayton

Intertech Consulting, Inc.

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 15 April 2020 19:05 PM UTC
  2. SnapDevelop
  3. # 2

Hi Armeen;

    FYI: The key part of my implementation is the overall design / approach. This will work using the older .Net Web Service or via the new C# Web API feature in PB2019 and higher. The key for the WS is to run a native PB App EXE that produces the PDF file. It then locates the final PDF file result on its IIS web server's "landing pad". The return code (OK / Fail) plus the URL to the landing pad file is then returned to the client where the Client App can then consume it via an standard FTP and/pr HTTP request.

;-)

Regards ... Chris

Comment
  1. Armeen Mazda @Appeon
  2. Wednesday, 15 April 2020 19:25 PM UTC
The example you provided was based on old implementation so it could mislead people. Hope you will get around to updating your stuff as that feature has been obsolete for long time now.
  1. Helpful
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 15 April 2020 16:11 PM UTC
  2. SnapDevelop
  3. # 3

I wouldn't waste the time on the solution Chris recommended.  That feature is discontinued and replaced by REST APIs.  We discontinued it because it turned out to have a flawed design that would cause it to not scale and not thread safe.  So we had to rebuild it from the ground up.

You can consider Mike's suggestion, but keep in mind that what he mentioned is a third-party product not supported by Appeon and the PBVM runtime was never designed to run concurrent users on a server.  PDF generation is very heavy process so if done concurrently I really don't know if this will work well.

It is on our product roadmap to support exporting to PDF for the .NET DataStore, but unfortunately we don't have a firm schedule yet so I cannot comment about when.  But I can say it definitely would not be in PowerBuilder 2019 R3.

So the only thing I can suggest that is very little work and supported by Appeon is to return the data from the REST API to the DataWindow control in your app and then have your client-side app do the SaveAs to PDF.

 

Comment
  1. Ricardo Jasso
  2. Wednesday, 15 April 2020 18:38 PM UTC
Migrating to a middle tier is not exent of the need to redesign certain aspects of the application. Maybe, the datawindow is receiving all the data and then grouping and displaying just aggregate information. This should be done server side. Traditional client/server application design commonly rests upon the notion that transfer speed is infinite, specially with 1Gbps ethernet cards now available. Cloud applications on the contrary should be designed with low transfer speeds in mind.
  1. Helpful
  1. mike S
  2. Wednesday, 15 April 2020 19:09 PM UTC
regardless of deployment method, if the objective is to display summary data, then use the database to summarize it for you. not the middle tier, not the client.
  1. Helpful
  1. Ricardo Jasso
  2. Wednesday, 15 April 2020 19:50 PM UTC
Yes you are right. It should be done at the database. My point is, if the data is already summarized, why would it take longer to transmit using a compressed JSON string vs as part of a PDF binary file? One reason is that each format has its own overhead but how much different are they?
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 30 March 2020 18:51 PM UTC
  2. SnapDevelop
  3. # 4

Hi Olivier;

   FYI: This is how I currently do this from PB, Web & Mobile Apps ...

http://chrispollach.blogspot.com/2017/10/pdf.html

The above article describes a feature I built in PB 2017Rx but it still runs nicely in PB 2019 Rx as well.

Food for thought.

Regards ... Chris

Comment
  1. Olivier PAVLIN
  2. Wednesday, 15 April 2020 08:50 AM UTC
Hi Chris,

I'm trying to run your project but im stuck when deploying web service. I followed the word file for installation, I deployed the PDF_WebService project, the PDF_Create application works, but when i try to run the PDF_Display application and click the display PDF button I got an error :



2020/04/15 10:39:21 - ************ START of Application - 'PDF Display' ************

2020/04/15 10:39:21 - The application was built using the STD-Foundation classes and has now been started successfully!

2020/04/15 10:39:21 - This STD Foundation Classes version 2017.3.0.83 released on 2017-10-16, is optimized for the PB environment.

2020/04/15 10:39:21 - PDF Display - Build: 002, Version: Release 1.0.0.1, Date: June 24, 2015

2020/04/15 10:39:21 - The application is running under native MS-Windows!

2020/04/15 10:39:21 - The PowerBuilder run time version found was: 17.2.0.1858

2020/04/15 10:39:21 - The PowerBuilder run-time version (17.2.0.1858)does NOT match the expected version (17.0.0.1681)Continue (not recommended)?

2020/04/15 10:39:23 - The application user has requested that the application continue!

2020/04/15 10:39:23 - The application is running on a real device!

2020/04/15 10:39:23 - The ID of this PC is: INS5770-60KNXR2

2020/04/15 10:39:23 - User 'opavlin' is currently logged on to this computer!

2020/04/15 10:39:23 - The 'PDF Display' application is running in 32 bit mode!

2020/04/15 10:39:23 - The MS-Windows operating system version found was: 10.0.0.18362 - Platform: 2

2020/04/15 10:39:23 - O/S Command Line: <empty>

2020/04/15 10:39:25 - **** START of Diagnostics for DC/DS error, as follows... ****

2020/04/15 10:39:25 - WS Error on 'io_ds'

2020/04/15 10:39:25 - WS Error DWO: 'dw_pdf_create_webservice

2020/04/15 10:39:25 - WS Error Operation: Connect

2020/04/15 10:39:25 - WS Row No: 0

2020/04/15 10:39:25 - WS Method: of_create_pdf

2020/04/15 10:39:25 - WS Error:

2020/04/15 10:39:25 - WS Info: http://localhost/pdf/nc_pdf_view.asmx?WSDL

2020/04/15 10:39:25 - **** END of Diagnostics for DC/DS error! ****

2020/04/15 10:39:26 - **** START of Diagnostics for System Error! ****

2020/04/15 10:39:26 - Error Number ...... 6

2020/04/15 10:39:26 - Error Line .......... 10

2020/04/15 10:39:26 - Error Object ....... cb_display

2020/04/15 10:39:26 - Error Event ........ clicked

2020/04/15 10:39:26 - Error Message .... Invalid DataWindow row/column specified at line 10 in clicked event of object cb_display of wn_pdf_controller_e.

2020/04/15 10:39:26 - **** END of Diagnostics for System Error! ****

2020/04/15 10:39:27 - User has elected to continue after a System Error!

2020/04/15 10:39:29 - DC 'dw_log_viewer_e' - Retrieval performance: 63 ms used for 31 row(s) of data received.

2020/04/15 10:39:29 - DC 'dw_log_viewer_e' - Memory utilization: 82 112 bytes used for 31 row(s) of data received.

2020/04/15 10:42:05 - The application completed normally! Total time active: 164 172 ms

2020/04/15 10:42:05 - ************ END of Application - 'PDF Display' ************



And if I try to access http://localhost/pdf/nc_pdf_view.asmx in my browser I got this 404.3 error (IIS and Asp.Net are installed on my machine :



HTTP Error 404.3 - Not Found

The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.



Most likely causes:

It is possible that a handler mapping is missing. By default, the static file handler processes all content.

The feature you are trying to use may not be installed.

The appropriate MIME map is not enabled for the Web site or application. (Warning: Do not create a MIME map for content that users should not download, such as .ASPX pages or .config files.)

If ASP.NET is not installed.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Wednesday, 15 April 2020 18:59 PM UTC
Hi Olivier;

Looks like the log from trying to run the native PB App EXE ... correct? If so, it could be because it's INI file is pointing to a DB instance that you has not been installed on your PC.

Feel free to contact me through the SourceForge website so that I can walk you through this process. Also, make sure that you read through the documentation carefully to recreate this scenario.

Regards ... Chris

  1. Helpful
  1. Olivier PAVLIN
  2. Wednesday, 22 April 2020 11:11 AM UTC
Ok I had some windows features not installed on my machine to run IIS properly. Now the test page of the web-service shows up correctly on my browser (http://localhost/pdf/nc_pdf_view.asmx), I tryed to modify the Application.ini to match my database but it looks like the error comes when connecting to the web-service :



2020/04/21 13:52:13 - **** START of Diagnostics for DC/DS error, as follows... ****

2020/04/21 13:52:13 - WS Error on 'io_ds'

2020/04/21 13:52:13 - WS Error DWO: 'dw_pdf_create_webservice

2020/04/21 13:52:13 - WS Error Operation: Connect

2020/04/21 13:52:13 - WS Row No: 0

2020/04/21 13:52:13 - WS Method: of_create_pdf

2020/04/21 13:52:13 - WS Error:

2020/04/21 13:52:13 - WS Info: http://localhost/pdf/nc_pdf_view.asmx?WSDL

2020/04/21 13:52:13 - **** END of Diagnostics for DC/DS error! ****

2020/04/21 13:52:15 - **** START of Diagnostics for System Error! ****

2020/04/21 13:52:15 - Error Number ...... 6

2020/04/21 13:52:15 - Error Line .......... 10

2020/04/21 13:52:15 - Error Object ....... cb_display

2020/04/21 13:52:15 - Error Event ........ clicked

2020/04/21 13:52:15 - Error Message .... Invalid DataWindow row/column specified at line 10 in clicked event of object cb_display of wn_pdf_controller_e.

2020/04/21 13:52:15 - **** END of Diagnostics for System Error! ****
  1. Helpful
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Monday, 30 March 2020 18:13 PM UTC
  2. SnapDevelop
  3. # 5

you can run PB in a web service api to run the report and return a pdf or any other format:

https://www.topwizprogramming.com/topwizweb.html

 

Whats great about this is you can create a full rest api using PB.  If you decide to move it to C# when the PDF stuff is added to snapdev, then you just rebuild the service.  No changing any of the rest clients

 

 

 

Comment
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Monday, 30 March 2020 17:33 PM UTC
  2. SnapDevelop
  3. # 6

The easiest way to do this is have a DataWindow control in your PowerBuilder application call the REST Web API using the RESTClient object, then do a DataWindow.SaveAs to PDF.

In the future we plan to add the SaveAs to PDF feature to the .NET DataStore on the server side, but we don't have any potential dates right now that I could mention.

Comment
  1. Ricardo Jasso
  2. Wednesday, 15 April 2020 16:51 PM UTC
Not only it is the easiest way but the correct way, for now. Adding SaveAs to PDF features to the .NET DataStore is not aligned to the separation of concerns goal expressed at the last Elevate conference. Not that it should not be done at the server side but it should be done at a separate layer different than the business layer.
  1. Helpful
  1. Armeen Mazda @Appeon
  2. Wednesday, 15 April 2020 18:40 PM UTC
Hi Ricardo, This is very good point. We will carefully consider this when it comes time to design it.
  1. Helpful
  1. Olivier PAVLIN
  2. Monday, 20 April 2020 12:45 PM UTC
Well the whole point of going web API is to provide services for cross plateforms and mobility solution, so as far as i'm concern I am going to make this server side PDF generation to work even if it's an old not a scalable and non permanent solution.
  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.