Error with DefaultFileSys.OpenFile  SOLVED

PDF-XChange Editor SDK for Developers

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

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
prime clinical systems
User
Posts: 211
Joined: Sun Aug 05, 2012 5:20 pm

Error with DefaultFileSys.OpenFile

Post by prime clinical systems »

Error opening stamps collection:
Hi this is my code.. I have my custom stamps file, in the regular stamps folder, and they work via the UI just fine:
C:\Users\Administrator\AppData\Roaming\Tracker Software\PDFXEditor\3.0\Stamps\MyStamps.pdf (attached if you need it)
Trying to add a specific stamp from that file to a newly created Stamp annotation..
Dim nStamp As Long
Dim StampData As IPXC_AnnotData_Stamp
nStamp = Me.p_pxsInst.StrToAtom("Stamp")
Set Annot = Page.InsertNewAnnot(nStamp, RECT)
If Not Annot Is Nothing Then
Dim Myname As pdfxeditctl.IAFS_Name
Dim MyFile As pdfxeditctl.IAFS_File
Dim StampFolder As String
StampFolder = Me.PDF.Inst.GetStdFolder(PXV_StdFolder_Stamps, True, True)
Set Myname = Me.p_fsInst.DefaultFileSys.StringToName(StampFolder & "MyStamps.pdf")
Dim nOpenFlags As Long
nOpenFlags = pdfxeditctl.AFS_OpenFileFlags.AFS_OpenFile_Read 'note tried many combinations
Set MyFile = Me.p_fsInst.DefaultFileSys.OpenFile(Myname, nOpenFlags) 'This line errors out
run-time error '-2080440288 (83ff0020)': Method 'OpenFile' of object 'IAFS_FileSys' failed... hresult cannot be used in VB6
Dim StampMan As IPXC_StampsManager
Set StampMan = Me.p_pxcInst.StampsManager
Dim StampCol As IPXC_StampsCollection
Set StampCol = StampMan.LoadCollection(MyFile)
Set StampData = Annot.data
'also, is this the correct way to specify the StampName?
Call StampData.SetStampName(StampCol.Item(0).Title)
Annot.data = StampData
nID = Me.PDF.Inst.Str2ID("op.annot.addNew", False)
Set Op = Me.PDF.Inst.CreateOp(nID)
Set Input1 = Op.Params.Root("Input")
Input1.Add().v = Annot
Op.Do
Set StampData = Nothing
Set Op = Nothing
Set Input1 = Nothing
Set Annot = Nothing
End If

thanks,
CE
Attachments
MyStamps.pdf
(6.76 KiB) Downloaded 74 times
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Error with DefaultFileSys.OpenFile

Post by Sasha - Tracker Dev Team »

Hello Clifford,

If you would translate this error by using the method mentioned in the forum rules, then you would have this result:
Capture6.PNG
Capture6.PNG (57.35 KiB) Viewed 1468 times
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
prime clinical systems
User
Posts: 211
Joined: Sun Aug 05, 2012 5:20 pm

Re: Error with DefaultFileSys.OpenFile

Post by prime clinical systems »

As I mentioned in my post HRESULT is NOT supported in VB6, unless this is a sample external program to translate error codes that I could download? and no, the file is not opened by any other project, but the fact the file is used in my project then that is why it can't be loaded again? So what is the best way to get the stamp from the stamps collection and use it in SetStampName method?

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

Re: Error with DefaultFileSys.OpenFile  SOLVED

Post by Sasha - Tracker Dev Team »

Hello Clifford,

This code works for me:

Code: Select all

//Loading stamp collection from file
IAFS_Inst afsInst = (IAFS_Inst)pdfCtl.Inst.GetExtension("AFS");
PDFXEdit.IAFS_Name name = afsInst.DefaultFileSys.StringToName(@"D:\SDK problems\MyStamps.pdf");
int openFileFlags = (int)(PDFXEdit.AFS_OpenFileFlags.AFS_OpenFile_Read | PDFXEdit.AFS_OpenFileFlags.AFS_OpenFile_ShareRead);
PDFXEdit.IAFS_File destFile = fsInst.DefaultFileSys.OpenFile(name, openFileFlags);
IPXC_StampsCollection sc = pxcInst.StampsManager.LoadCollection(destFile);
//Creating stamp annotation
IPXC_Page page = pdfCtl.Doc.CoreDoc.Pages[0];
PDFXEdit.IPXS_Inst pSInt = (PDFXEdit.IPXS_Inst)pdfCtl.Inst.GetExtension("PXS");
uint nStamp = pSInt.StrToAtom("Stamp");
IPXC_StampInfo si = sc[0];
double nHeight = 0;
double nWidth = 0;
si.GetSize(out nWidth, out nHeight);
PDFXEdit.PXC_Rect rc;
rc.left = 0;
rc.right = nWidth;
rc.top = page.get_Box(PXC_BoxType.PBox_PageBox).top;
rc.bottom = rc.top - nHeight;
PDFXEdit.IPXC_Annotation annot = page.InsertNewAnnot(nStamp, ref rc, 0);
IPXC_AnnotData_Stamp stampData = (IPXC_AnnotData_Stamp)annot.Data;
stampData.SetStampName(si.ID);
annot.Data = stampData;
int nID = pdfCtl.Inst.Str2ID("op.annots.addNew", false);
PDFXEdit.IOperation pOp = pdfCtl.Inst.CreateOp(nID);
PDFXEdit.ICabNode input = pOp.Params.Root["Input"];
input.Add().v = annot;
pOp.Do();
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply