1. NAVEEN KUNDAL
  2. PowerBuilder
  3. Thursday, 26 April 2018 19:41 PM UTC

How we can set the Data Export property of more than Three Hundred DataWindow(s) in our huge application to  NativePDF!  method instead of  modifying each DataWindow individually ?

We are using  IPMIS2K.INI  as configuration file in our application.

We are not using PB.INI.

I am trying to use this the help which is provided in PowerBuilder Help but could not resolve the problem.

 

 

Kim Berghall Accepted Answer Pending Moderation
  1. Friday, 27 April 2018 20:43 PM UTC
  2. PowerBuilder
  3. # 1

If you use a framework with inheritance like PFC you can change it easily. We made our system database configurable so you can change the PDF method.

Also, with build 1769 you no longer need to do the paper sizes.

Here is our code. placed in of_setpdfmethod PFC u_dw and then just one line code in the dw ancestor dw creator event. 

string ls_method_cfg,ls_method_old,ls_method_new,ls_modify='',ls_rc
string ls_useprintspec,ls_imageformat
 
if not isvalid(this) then return 0
 
ls_method_cfg = gnv_sisu.of_getpdfmethod()  //either hardcode or make configurable
 
ls_method_old = lower(this.Describe('DataWindow.Export.PDF.Method'))
if ls_method_old = '' then return 0 //dw object doesn't exists so exit
 
//no change
if ls_method_cfg = ls_method_old and ls_method_cfg <> 'nativepdf!' then
return no_action
end if
 
choose case ls_method_cfg
case 'nativepdf!'
ls_method_new = '2'
case 'distill!'
ls_method_new = '0'
case else
ls_method_new = '1'
end choose
 
//messagebox ("",ls_method_cfg+','+ls_method_old+','+ls_method_new)
if ls_method_cfg <> ls_method_old then
   ls_modify = 'DataWindow.Export.PDF.Method='+ls_method_new
end if
 
//Change it to distill! or xslfop!
if ls_method_new = '0' or ls_method_new = '1' then
ls_rc = this.Modify(ls_modify)
// MessageBox('DataWindow Modify','Modify command: '+ls_modify+'~r~n~r~nResult: "'+ls_rc+'"')
   return SUCCESS
end if
 
//Remaining code can only be used when PDF method is NativePDF.
 
//Always ensure images are in or are converted to JPG format (ImageFormat='1').
ls_imageformat  = lower(this.describe('DataWindow.Export.PDF.NativePDF.ImageFormat'))
if ls_imageformat <> '1' then
   ls_modify = lefttrim(ls_modify+' '+"DataWindow.Export.PDF.NativePDF.ImageFormat='1'")
end if
 
//Always use the paper size and print orientation from the DW Object's print specifications.
ls_useprintspec = lower(this.describe('DataWindow.Export.PDF.NativePDF.UsePrintSpec'))
if ls_useprintspec <> 'yes' then
ls_modify = lefttrim(ls_modify+' '+"DataWindow.Export.PDF.NativePDF.UsePrintSpec='yes'")
end if
if ls_modify > '' then
   ls_rc = this.Modify(ls_modify)
end if
 
Return SUCCESS

 

 

Comment
There are no comments made yet.
Shenn Sellers Accepted Answer Pending Moderation
  1. Friday, 27 April 2018 16:49 PM UTC
  2. PowerBuilder
  3. # 2

You can add this code to change the DW's...

aDW.Modify("DataWindow.Export.PDF.Method = NativePDF! DataWindow.Export.PDF.NativePDF.CustomSize = '" + ls_size &
+ "' DataWindow.Export.PDF.NativePDF.customorientation='0' DataWindow.Export.PDF.NativePDF.ImageFormat = '1' " &
+ "DataWindow.Export.PDF.NativePDF.PDFStandard = '0'")  
 
Change the settings per your requirements.  I actually use the following function that I call before saving a DW as a PDF.
 
global type f_nativepdf_dwset from function_object
end type
 
forward prototypes
global subroutine f_nativepdf_dwset (ref datawindow adw)
end prototypes
 
global subroutine f_nativepdf_dwset (ref datawindow adw);int li_version
string ls_size
ContextInformation lcx_key
 
//Get PB Version
GetContextService ( "ContextInformation", lcx_key)
lcx_key.GetMajorVersion(li_version)
 
//Only works for PB 2017 and above
if (li_version >= 17) then
 
//Gets the Paper size
ls_size = aDW.describe("DataWindow.Print.Paper.Size")
 
//Determines what size to use
choose case (ls_size)
case '0', '1', '2'
ls_size = '5'  //8.5 X 11
case '5'
ls_size = '6' //legal
case '3', '4' // 17" x 11"
ls_size = '6' //legal
case '8'
ls_size = '3' //A3
case '9', '10' //9 – A4 210 x 297 mm
ls_size = '4' //a4
case else
ls_size = '5'  //8.5 X 11 
end choose
 
//Customorientation of 0 means use DW setting
aDW.Modify("DataWindow.Export.PDF.Method = NativePDF! DataWindow.Export.PDF.NativePDF.CustomSize = '" + ls_size &
+ "' DataWindow.Export.PDF.NativePDF.customorientation='0' DataWindow.Export.PDF.NativePDF.ImageFormat = '1' " &
+ "DataWindow.Export.PDF.NativePDF.PDFStandard = '0'")  
 
end if
end subroutine

So my code is...

//Creates the PDF
f_NativePDF_DWSet(dw_report)
li_ret = dw_report.SaveAs(ls_filename, PDF!, true)

Comment
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.