Last active
July 11, 2023 11:44
C# QR Code Generator | Generate QR Code with Logo in C# | QR Code Creator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// initialize api | |
var fileApi = new FileApi(configuration); | |
// create download file request | |
var downloadRequest = new DownloadFileRequest("csharp-testing/merged-file.pdf", myStorage); | |
// download file | |
Stream downloadResponse = fileApi.DownloadFile(downloadRequest); | |
// save file in working directory | |
using (var fileStream = System.IO.File.Create("H:\\groupdocs-cloud-data\\merged-file.pdf")) | |
{ | |
downloadResponse.Seek(0, SeekOrigin.Begin); | |
downloadResponse.CopyTo(fileStream); | |
} | |
Console.WriteLine("File downloaded successfully."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var configuration = new GroupDocs.Signature.Cloud.Sdk.Client.Configuration("xxxxxx-xxxxxx-xxxxxxx-xxxxxxxx", "xxxxxxxxxxxxxxxxxxxxxxxx"); | |
var apiInstance = new GroupDocs.Signature.Cloud.Sdk.Api.SignApi(configuration); | |
//set QR Code options | |
var signQRCodeOptions = new GroupDocs.Signature.Cloud.Sdk.Model.SignQRCodeOptions() | |
{ | |
BackgroundColor = new GroupDocs.Signature.Cloud.Sdk.Model.Color() { Web = "#fcfcfc" }, | |
Width = 100, | |
Height = 80, | |
HorizontalAlignment = GroupDocs.Signature.Cloud.Sdk.Model.SignQRCodeOptions.HorizontalAlignmentEnum.Right, | |
VerticalAlignment = GroupDocs.Signature.Cloud.Sdk.Model.SignQRCodeOptions.VerticalAlignmentEnum.Center, | |
Left = 10, | |
Top = 100, | |
LocationMeasureType = GroupDocs.Signature.Cloud.Sdk.Model.SignQRCodeOptions.LocationMeasureTypeEnum.Pixels, | |
Margin = new GroupDocs.Signature.Cloud.Sdk.Model.Padding { Left = 10, Right = 10, Bottom = 10, Top = 10 }, | |
MarginMeasureType = GroupDocs.Signature.Cloud.Sdk.Model.SignQRCodeOptions.MarginMeasureTypeEnum.Pixels, | |
LogoFilePath = "csharp-testing/logo.jpg" | |
}; | |
// specify settings for creating request | |
var settings = new SignSettings(); | |
settings.FileInfo = new GroupDocs.Signature.Cloud.Sdk.Model.FileInfo | |
{ | |
FilePath = "csharp-testing/sample.pdf" | |
}; | |
settings.Options.Add(signQRCodeOptions); | |
settings.SaveOptions.OutputFilePath = "csharp-testing/out_sample.pdf"; | |
// create signature making request | |
var request = new GroupDocs.Signature.Cloud.Sdk.Model.Requests.CreateSignaturesRequest() | |
{ | |
signSettings = settings | |
}; | |
var response = apiInstance.CreateSignatures(request); | |
Debug.Print("FleName: " + response.FileInfo.FilePath); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Get clientId & clientSecret from https://dashboard.groupdocs.cloud (free registration is required). | |
string clientId = "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; | |
string clientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; | |
string myStorage = "test-internal-storage"; | |
var configuration = new Configuration(clientId, clientSecret); | |
configuration.ApiBaseUrl = "https://api.groupdocs.cloud"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create necessary API instances | |
var storageApi = new StorageApi(configuration); | |
var fileApi = new FileApi(configuration); | |
var path = @"H:\groupdocs-cloud-data"; | |
var files = Directory.GetFiles(path, "*.pdf", SearchOption.AllDirectories); | |
foreach (var file in files) | |
{ | |
var relativeFilePath = file.Replace(path, string.Empty).Trim(Path.DirectorySeparatorChar); | |
var response = storageApi.ObjectExists(new ObjectExistsRequest(relativeFilePath, myStorage)); | |
if (response.Exists != null && !response.Exists.Value) | |
{ | |
var fileStream = File.Open(file, FileMode.Open); | |
fileApi.UploadFile(new UploadFileRequest(relativeFilePath, fileStream, myStorage)); | |
fileStream.Close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment