Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VB to VFP code
Message
From
22/11/2017 14:08:46
 
 
To
17/11/2017 06:13:55
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01655632
Message ID:
01655767
Views:
71
Sir, I tried to use wwDotNetBridge, but was not successful as perhaps I have no knowledge about class, objects etc.
What i Know is little bit traditional type of coding in VFP.

Can you kindly Give a start up for few lines and the closing lines...

I tried this way, but got the error at initial Lines only.

I have kept the all the DLL's and Prg and all required files in the same Folder "D\All" as of Now for the ease of use.

This I Tried..
loBridge = newobject('wwDotNetBridge', 'wwDotNetBridge.prg', '', 'V4')
loBridge.LoadAssembly('SignLib.dll')
loClass = loBridge.CreateInstance('SignLib.Certificates')
loClass = loBridge.CreateInstance('SignLib.PDF')
PdfSignature ps = new PdfSignature('8en53822ynk');
//load the PDF document
ps.LoadPdfDocument("D:\All\Unsigned.PDF");
File.WriteAllBytes("d:\\All\Signed.pdf", ps.ApplyDigitalSignature());
This is the Sample Code in .NET Provided.
using SignLib.Certificates;
using SignLib.Pdf;
PdfSignature ps = new PdfSignature(serialNumber);
ps.SignaturePosition = SignaturePosition.TopLeft;
ps.SignaturePage = 1;
//automaticall load the digital signature certificate using email criteria
ps.DigitalSignatureCertificate = DigitalCertificate.LoadCertificate(false,
DigitalCertificateSearchCriteria.EmailE, "user@test.com", false);
//bypass the smart card PIN
DigitalCertificate.SmartCardPin = "123456";
ps.TimeStamping.ServerUrl = new Uri("http://ca.signfiles.com/TSAServer.aspx");
System.IO.DirectoryInfo di;
System.IO.FileInfo[] rgFiles;
//get the pdf files from the folder
di = new System.IO.DirectoryInfo("d:\\source_dir");
rgFiles = di.GetFiles("*.pdf");
foreach (FileInfo fi in rgFiles)
{
//for readonly files
fi.Attributes = FileAttributes.Normal;
//load the PDF document
ps.LoadPdfDocument(di.FullName + "\\" + fi.Name);
//digitally sign and save the PDF file
File.WriteAllBytes("d:\\output_dir\\" + fi.Name,
ps.ApplyDigitalSignature());
}
Thanks


>Hi Harsh,
>
>first step is to instantiate the classes, then the rest should be very similar.
>
>based on http://www.signfiles.com/manuals/SignatureLibraryUserManual.pdf, it's a .net software;
>then you need an adapter such as wwDotNetBridge (https://west-wind.com/wwDotnetBridge.aspx).
>
>>Hi All,
>>I need some help in converting a small VB code to VFP as I have no knowledge about VB. Anyone who is having idea kindly Guide.
>>Here is my Code in VB
>>
>>
>>using SignLib.Certificates;
>>using SignLib.Pdf;
>>PdfSignature ps = new PdfSignature("serial number");
>>//load the PDF document
>>ps.LoadPdfDocument("d:\\123.pdf");
>>ps.SignaturePage = 1;
>>//get the pdf page size
>>System.Drawing.Point page = ps.DocumentProperties.DocumentPageSize(1);
>>//set the rectangle width and height
>>int width = 80;
>>int height = 40;
>>ps.SignatureAdvancedPosition = new System.Drawing.Rectangle(page.X - width, page.Y
>>- height, width, height);
>>ps.SignaturePosition = SignaturePosition.TopRight;
>>ps.SigningReason = "I approve this document";
>>ps.SignaturePosition = SignaturePosition.TopLeft;
>>ps.SigningLocation = "Europe branch";
>>//Load the certificate from Microsoft Certificate Store without user intervention
>>ps.DigitalSignatureCertificate = DigitalCertificate.LoadCertificate(false,
>>DigitalCertificateSearchCriteria.EmailE, "email@email.com");
>>//The PIN dialog is now bypassed
>>DigitalCertificate.SmartCardPin = "123456";
>>//Set a Custom Digital Signature Text
>>ps.SignatureText ="Signed by:" + ps.DigitalSignatureCertificate.GetNameInfo(X509NameType.SimpleName,
>>false) + "\n Date:" + DateTime.Now.ToString("yyyy.MM.dd HH:mm") + "\n" + "Reason:" + ps.SigningReason;
>>ps.FontFile = "c:\\windows\\fonts\\arial.ttf";
>>ps.FontSize = 10;
>>//Set the Digital Signature Image
>>ps.SignatureImage = System.IO.File.ReadAllBytes("c:\\graphic.jpg");
>>//text on the right and image on the left
>>ps.SignatureImageType = SignatureImageType.ImageAndText;
>>//image as bakground and text on above
>>ps.SignatureImageType = SignatureImageType.ImageAsBackground;
>>//only image
>>ps.SignatureImageType = SignatureImageType.ImageWithNoText;
>>//write the signed file
>>File.WriteAllBytes("d:\\source[signed].pdf", ps.ApplyDigitalSignature());
>>
>>Thanks
Harsh
Previous
Reply
Map
View

Click here to load this message in the networking platform