Adding an Image to a PDF using PowerBuilder 2019

PDF-XChange Editor SDK for Developers

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

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
greg.rusak@mustimuhw.solutions
User
Posts: 31
Joined: Thu Sep 20, 2018 12:45 am

Adding an Image to a PDF using PowerBuilder 2019

Post by greg.rusak@mustimuhw.solutions » Tue Sep 03, 2019 6:48 pm

Hello,

We have a business requirement to dynamically add our client's company logo image to the top left hand side of each page of a PDF report.

We understand that the Tracker engineers are not fluent in the PowerBuilder 2019 development tool by Appeon, but we're hoping you will be able to help us translate your C# example of AddImageToFirstPage (https://sdkhelp.tracker-software.com/vi ... t_addImage) to PowerBuilder PowerScript code.

Here is the C# example:

Code: Select all

private void AddImageToFirstPage(PDFXEdit.IPXV_Document Doc, PDFXEdit.PXV_Inst Inst)
{
    if (Doc == null)
        return;
    int nID = Inst.Str2ID("op.document.addImage", false);
    PDFXEdit.IOperation Op = Inst.CreateOp(nID);
    PDFXEdit.ICabNode input = Op.Params.Root["Input"];
    input.v = Doc;
    PDFXEdit.ICabNode options = Op.Params.Root["Options"];
    options["Page"].v = 0;  //First page
    options["Pos.top"].v = 400;
    options["Pos.left"].v = 50;
    options["Pos.right"].v = 400;
    options["Pos.bottom"].v = 50;
    options["AlignMode"].v = 1 | 4; //Horizontal and vertical center
    options["AsStamp"].v = false; //Inserting as a part of the content
    PDFXEdit.IAFS_Inst fsInst = (PDFXEdit.IAFS_Inst)Inst.GetExtension("AFS");
    PDFXEdit.IAFS_Name destPath = fsInst.DefaultFileSys.StringToName("D:\\TestImage.png"); //Converting string to name
    options["Src"].v = destPath;
    Op.Do();
}
And this is what we've done so far in our PowerBuilder application to replicate the same functionality as the above C# code:

Code: Select all

ole_pdf.Object.SetLicKey(ls_key)
lole_Inst = ole_pdf.Object.Inst
lole_Icab = lole_Inst.CreateOpenDocParams()
ole_pdf.Object.OpenDocFromPath( ls_filename, lole_Icab)
ll_nID = lole_Inst.Str2ID("op.document.addImage", false)
lole_operation = lole_Inst.CreateOp(ll_nID);
lole_icab = lole_operation.Params
lole_ICabNode_Input = lole_icab.Root("Input")
lole_Doc = ole_pdf.Object.Doc
lole_ICabNode_Input.v = lole_Doc
lole_ICabNode_Options = lole_icab.Root("Options")
…
…
lole_fsinst = lole_inst.GetExtension("AFS")
…
…
So as you can see, we are having an issue converting the "Options" table to a PowerBuilder construct starting with

Code: Select all

options["Page"].v = 0;  //First page
What can we try in PowerBuilder to reference the Options table and to translate it to PowerBuilder PowerScript?

Alternatively, if there is another way to add an image file from disk to the top left hand corner of each page of the PDF document, please let us know as that might be easier to translate into PowerBuilder code.

Thanks in advance for your help with this and all the previous changes you've made to your product so that we can use it in our PowerBuilder applications.

Warm Regards,

Greg

User avatar
Sasha - Tracker Dev Team
User
Posts: 4937
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Adding an Image to a PDF using PowerBuilder 2019

Post by Sasha - Tracker Dev Team » Wed Sep 04, 2019 7:03 am

Hello Greg,

Well, I advice using the operation as it's an optimal way of interaction with the Editor SDK.
There are several more ways of setting the ICabNode, for example:

Code: Select all

options.SetInt("Page", 0);
Or getting the "Page" ICabNode and setting it's value directly:

Code: Select all

ICabNode pageNode = options["Page"];
pageNode.Int = 0;
Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

greg.rusak@mustimuhw.solutions
User
Posts: 31
Joined: Thu Sep 20, 2018 12:45 am

Re: Adding an Image to a PDF using PowerBuilder 2019

Post by greg.rusak@mustimuhw.solutions » Wed Nov 13, 2019 7:31 pm

Hello Alex,

We're just getting back to this again and thank you for your assistance and patience.

It appears we are experiencing the same issue with the ICabNode Interface as we reported in this post:
viewtopic.php?f=66&t=31870&p=132456#p132456

In this case, out of all the Methods and Properties of that interface, the ONLY ones we seems to be able to get a handle of are the following:

lole_ICabNode_Options = lole_icab.Root("Options")
lb_valid = lole_ICabNode_Options.Valid
ll_count_ICabNode = lole_ICabNode_Options.Count
la_any_type = lole_ICabNode_Options.Type
lole_ICabNode_Options.Clear()


whereas if we try:

lole_ICabNode_Options.SetInt("Page", 0)

or any of the other methods, we get a NULL pointer exception error.

Do you think this is the same issue as we reported before, or is there something else we're missing in this case?

Again, your attention to this is greatly appreciated.

Regards,

Greg

User avatar
Sasha - Tracker Dev Team
User
Posts: 4937
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Adding an Image to a PDF using PowerBuilder 2019

Post by Sasha - Tracker Dev Team » Thu Nov 14, 2019 8:02 am

Hello Greg,

Forwarded this to Roman, probably he can tell more.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

greg.rusak@mustimuhw.solutions
User
Posts: 31
Joined: Thu Sep 20, 2018 12:45 am

Re: Adding an Image to a PDF using PowerBuilder 2019

Post by greg.rusak@mustimuhw.solutions » Mon Dec 02, 2019 6:49 pm

Hello Alex,

Just checking in to see where Roman got to on this and if there's anything you can do to help us out?

Kind Regards,

Greg

User avatar
Sasha - Tracker Dev Team
User
Posts: 4937
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Adding an Image to a PDF using PowerBuilder 2019

Post by Sasha - Tracker Dev Team » Tue Dec 03, 2019 10:22 am

Hello Greg,

Forwarded this one to Roman.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

User avatar
Roman - Tracker Supp
Site Admin
Posts: 275
Joined: Sun Nov 21, 2004 3:19 pm

Re: Adding an Image to a PDF using PowerBuilder 2019

Post by Roman - Tracker Supp » Wed Dec 04, 2019 12:40 am

Hello Greg,
The issue has been resolved in the upcoming build of the Editor.
Tracker Software Products

Please ZIP any files uploaded to this forum or they will not be posted !
You may also use a RAR or 7Z archive format

greg.rusak@mustimuhw.solutions
User
Posts: 31
Joined: Thu Sep 20, 2018 12:45 am

Re: Adding an Image to a PDF using PowerBuilder 2019

Post by greg.rusak@mustimuhw.solutions » Wed Dec 04, 2019 12:45 am

Roman,

Wow! Thanks for that. Do you have an approximate ETA on the next build and the build number I should expect this in.

Very much appreciated. Looking forward to it.

Regards,

Greg

User avatar
Sasha - Tracker Dev Team
User
Posts: 4937
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Adding an Image to a PDF using PowerBuilder 2019

Post by Sasha - Tracker Dev Team » Wed Dec 04, 2019 8:11 am

Hello Greg,

If all goes well, we are planning to release at the end of this year.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

greg.rusak@mustimuhw.solutions
User
Posts: 31
Joined: Thu Sep 20, 2018 12:45 am

Re: Adding an Image to a PDF using PowerBuilder 2019

Post by greg.rusak@mustimuhw.solutions » Thu Jan 16, 2020 2:46 am

Hello Alex,

We've again made some progress with this, but we've come across another case that may be the same issue as you have previously addressed for us.

We can now reference all of the following Methods and Properties without getting a NULL pointer exception:

lole_ICabNode_Options.SetInt("Page", 0)
lole_ICabNode_Options.SetInt("Pos.top", 400)
lole_ICabNode_Options.SetInt("Pos.right", 400)
lole_ICabNode_Options.SetInt("Pos.bottom", 50)
lole_ICabNode_Options.SetInt("AlignMode", 1)
lole_ICabNode_Options.SetInt("AsStamp", false)


We can now also get a valid handle to the IAFS_Inst Instance and the IAFS_filesys Instance:

lole_IAFS_Inst = lole_inst.GetExtension("AFS")
lole_IAFS_filesys = lole_IAFS_Inst.DefaultFileSys


But we can only reference 2 Properties of the IAFS_filesys Instance:

lole_IAFS_filesys.Name
lole_IAFS_filesys.LocalTempFolder


And trying to reference any other Methods or Properties like the following, returns a null pointer exception:

lole_IAFS_filesys.DispName
lole_IAFS_Name = lole_IAFS_filesys.StringToName("C:\\audio.png"); //Converting string to name


Do you think this is the same issue as we reported before, or is there something else we're missing in this case?

Again, your attention to this is greatly appreciated.

Regards,

Greg

User avatar
Roman - Tracker Supp
Site Admin
Posts: 275
Joined: Sun Nov 21, 2004 3:19 pm

Re: Adding an Image to a PDF using PowerBuilder 2019

Post by Roman - Tracker Supp » Thu Jan 16, 2020 3:04 am

Hello Greg,
We will take a look if it is possible to further advance the IDispatch simulator capabilities to cover more SDK interfaces and IAFS_Filesys in particular.
But as we stated from the beginning this simulator is a sort of trade-off to enable late binding client to access at least some of the properties/methods of the interfaces that are inherently incompatible with OLE Automation.
So this feature will never cover all the SDK interfaces - there will always be interfaces/properties you will be unable to use from PowerBuilder using late binding.

You might want to consider a helper module written in a language that supports native (IUnknown-based COM interfaces) and implements the functionality related to the subset of our SDK interfaces you cannot directly access from PowerBuilder.
Tracker Software Products

Please ZIP any files uploaded to this forum or they will not be posted !
You may also use a RAR or 7Z archive format

Post Reply