Setting Printer.Option Save.ShowSaveDialog - Powerbuilder

PDF-XChange Drivers API (only) V4/V5
This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-XChange Printer Drivers SDK (only) - VERSION 4 & 5 - Please use the PDF-Tools SDK Forum for Library DLL assistance.

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Post Reply
kdoane
User
Posts: 9
Joined: Thu May 08, 2014 8:37 pm

Setting Printer.Option Save.ShowSaveDialog - Powerbuilder

Post by kdoane »

Hi,

I am using Sybase Powerbuilder 12.5 and I am having issues setting the option properties.

I am calling ApplyOptions(0) after attempting to set the properties.

The issue is that PB can not access the objects using the code like below.

PDFPrinter.Option("Save.ShowSaveDialog") = "Overwrite"

I am having no problems getting the basic PDF printing to work so at least I know the product does work with PB.

I tried a few different ways like
PDFPrinter.Option.Save.ShowSaveDialog = 0
PDFPrinter.Option.Save("ShowSaveDialog", 0)

I do get some errors back about the Incorrect number of subscripts accessing the property Option when I code it like this..

PDFPrinter.Option.Save[3]

If I try like this code below, it does not error but it also does not change the setting either.
PDFPrinter.Option.Save("ShowSaveDialog", 0)

Is there a way I can find out what the structure or array looks like for the Option call so maybe I can set it using that information or are there any calls that return an object from the Option call and I may be able to use that.

Here is what the code basically looks like.

oleobject PDFPFactory
oleobject PDFPrinter

ll_rc = PDFPFactory.ConnectToNewObject("PXCComLib5.CPXCControlEx")

PDFPrinter = PDFPFactory.Printer("", "PDF-XChange 2014 CallBack", "<YOUR REG CODE>", "<YOUR DEV CODE>")
ls_pname = PDFPrinter.Name()
PDFPrinter.SetAsDefaultPrinter()


Thanks
Karl
kdoane
User
Posts: 9
Joined: Thu May 08, 2014 8:37 pm

Re: Setting Printer.Option Save.ShowSaveDialog - Powerbuilde

Post by kdoane »

I thought I would add some additional information that may help.

Looking through various posts and the help documents, I noticed there are some function calls that are used in either C# or C++.
They are put_option or set_option, what DLL are those available in to call?

If I can use those, I should be able to accomplish what I need.

In PB this is a common way to use a function in a dll.
FUNCTION int GetModuleFileNameA( ulong hinstModule, REF string lpszPath, ulong cchPath) LIBRARY "kernel32.dll"
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3549
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: Setting Printer.Option Save.ShowSaveDialog - Powerbuilde

Post by Ivan - Tracker Software »

It is not a direct DLL function calls.
Printer object is a COM object and as far as I see, Powerbuilder can works with COM (http://infocenter.sybase.com/help/index ... ICFIDB.htm)
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
kdoane
User
Posts: 9
Joined: Thu May 08, 2014 8:37 pm

Re: Setting Printer.Option Save.ShowSaveDialog - Powerbuilde

Post by kdoane »

What file is the Com/ActiveX object located in because PB is not picking it up as a registered ActiveX object in it list?

Is this an auto registering object?

Sorry for the vague questions, there are not many examples for Powerbuilder that shows you how to do this especially if the IDE tool does not recognize them.

I should be able to do something like this... ole_object.object.put_Option("Save.ShowSaveDialog", "No") then hopefully.

I will keep looking because this is still not working yet.

Thank you
Karl
User avatar
John - Tracker Supp
Site Admin
Posts: 5219
Joined: Tue Jun 29, 2004 10:34 am
Location: United Kingdom
Contact:

Re: Setting Printer.Option Save.ShowSaveDialog - Powerbuilde

Post by John - Tracker Supp »

Hi Karl,

might help you to take a look here ...

https://help.pdf-xchange.com/DEV/de ... lex_object
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3549
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: Setting Printer.Option Save.ShowSaveDialog - Powerbuilde

Post by Ivan - Tracker Software »

the "Printer" object is not ActiveX control which you can put on your form in Powerbuilder, it is windowless object.
But you still should be able to use Printer.put_Option("Save.ShowSaveDialog", "No") if it is the correct syntax for the Powerbuilder
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
kdoane
User
Posts: 9
Joined: Thu May 08, 2014 8:37 pm

Re: Setting Printer.Option Save.ShowSaveDialog - Powerbuilde

Post by kdoane »

Hi,

That syntax should work because it looks like from the help documents that the Printer object is a reference to an object within the ActiveX object.

Here is the script that works as far as printing the datawindow to a pdf document.

The issue I have is trying to use the Options. I have tried multiple ways and even creating an OLEObject and trying to reference the option settings but that also did not work.

I am trying to find a replacement for Adobe and I have tried a couple other products but each one so far has not quite been able to do what we need it to do.

try

//This code will make a connection to the ActiveX object and make it available for use.
//0 as a return code is success.
ll_rc = PDFPFactory.ConnectToNewObject("PXCComLib5.CPXCControlEx")

//Create a printer and get reference to it.
PDFPrinter = PDFPFactory.Printer("", "PDF-XChange 2014 CallBack", "<YOUR REG CODE>", "<YOUR DEV CODE>")

//Get the name of the printer to check the name
ls_pname = PDFPrinter.Name()

//Switch this printer to be the default.
PDFPrinter.SetAsDefaultPrinter()

//Attempt to set the dialog to not show
//This does not cause error but does not do anything.
PDFPrinter.Option("Save.ShowSaveDialog", 0)

//This causes an error.
//Error Message - Name not found calling external object function put_option....
// I get this when the function does not exist in the object or if I did not spell it correct.
PDFPrinter.put_Option("Save.ShowSaveDialog", "No")


//If I did not have the code above, the rest of this code works and creates the PDF for me.
//The save dialog option does still show.

PDFPrinter.Option("Saver.ShowProgress", 0)
PDFPrinter.ApplyOptions(0)
//Sends the contents of the screen to Printer
adw_object.print()

PDFPrinter.RestoreDefaultPrinter()

catch ( OLERuntimeError oleError)
messagebox("PDF Error", oleError.getmessage()
finally
destroy PDFPrinter
destroy PDFPFactory
end try
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3549
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: Setting Printer.Option Save.ShowSaveDialog - Powerbuilde

Post by Ivan - Tracker Software »

Can you please try to add some delay after adw_object.print() and before PDFPrinter.RestoreDefaultPrinter() ?

I suspect that the printer object is released before any real printing starts.
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
kdoane
User
Posts: 9
Joined: Thu May 08, 2014 8:37 pm

Re: Setting Printer.Option Save.ShowSaveDialog - Powerbuilde

Post by kdoane »

Thank you for you help. I will give that a try and get back to you on the results.
User avatar
Will - Tracker Supp
Site Admin
Posts: 6815
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK
Contact:

Re: Setting Printer.Option Save.ShowSaveDialog - Powerbuilde

Post by Will - Tracker Supp »

:D
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
kdoane
User
Posts: 9
Joined: Thu May 08, 2014 8:37 pm

Re: Setting Printer.Option Save.ShowSaveDialog - Powerbuilde

Post by kdoane »

Hi,

Thank you for all your help in getting this to work.

I finally figured it out and it was a weird Powerbuilder feature that I forget about when changing default printers.
If you change the default printer through another process outside of PB code, it does not guarantee that PB will recognize the change. Your have to use PB's own internal PrinterGetPrinter() and PrinterSetPrinter(ls_printername).

It does not look like many people developing applications in Powerbuilder are using this product but here is the basic code that I used to get it working. This does not have all the error checking you would need but it gives you the general idea for as a sample.

oleobject PDFPFactory
oleobject PDFPrinter
long ll_rc
string ls_printername
string ls_old_printername

PDFPFactory = create oleobject

try

ll_rc = PDFPFactory.ConnectToNewObject("PXCComLib5.CPXCControlEx")
PDFPrinter = PDFPFactory.Printer("", "PDF-XChange 2014 CallBack", "<YOUR REG CODE>", "<YOUR DEV CODE>")
ls_printername = PDFPrinter.Name()
ls_old_printername = PrintGetPrinter()
PDFPrinter.SetAsDefaultPrinter()

//Have to set the printer using this because
//PB is set to the prior default printer.
ll_rc = PrintSetPrinter (ls_printername)

PDFPrinter.ResetDefaults()
PDFPrinter.Option("Save.Path", "C:\pb")
PDFPrinter.Option("Save.File", 'Testing_file_' + string(now(), 'hh:mm:ss'))
PDFPrinter.Option("Save.ShowSaveDialog", FALSE)
PDFPrinter.Option("Save.WhenExists", "Overwrite")
PDFPrinter.Option("Save.RunApp", FALSE)
PDFPrinter.Option("Fonts.EmbedAll", TRUE)
PDFPrinter.Option("Saver.ShowProgress", FALSE)
PDFPrinter.ApplyOptions(0)

ll_rc = adw_object.print()

PDFPrinter.RestoreDefaultPrinter()

//Set default printer in PB back to
//previous default printer
ll_rc = PrintSetPrinter (ls_old_printername)
catch ( OLERuntimeError err)
//Add message here to report error and add entry to error log table
catch( ...Any other error/exception...)
finally
If isvalid(PDFPrinter) then
destroy(PDFPrinter)
End If
If isvalid(PDFPFactory) then
destroy(PDFPFactory)
End If
destroy
end try
User avatar
John - Tracker Supp
Site Admin
Posts: 5219
Joined: Tue Jun 29, 2004 10:34 am
Location: United Kingdom
Contact:

Re: Setting Printer.Option Save.ShowSaveDialog - Powerbuilde

Post by John - Tracker Supp »

Pleased you got there and thanks for sharing the code, I am sure there are others it will help :)
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com
Post Reply