Skip to content

Instantly share code, notes, and snippets.

View farhan-raza's full-sized avatar

Farhan Raza farhan-raza

View GitHub Profile
@farhan-raza
farhan-raza / convert-word-docx-to-jpg-image.cs
Created March 1, 2024 13:55
Convert Word Document DOC DOCX to JPG PNG Image in C# .NET
// Load the input Word document
Aspose.Words.Document doc = new Aspose.Words.Document("Words.docx");
// Initialize an object of ImageSaveOptions class
Aspose.Words.Saving.ImageSaveOptions options = new Aspose.Words.Saving.ImageSaveOptions(Aspose.Words.SaveFormat.Jpeg);
// Set the "PageSet" to "0" to convert only the first page of a document.
options.PageSet = new Aspose.Words.Saving.PageSet(0);
// Set the image's brightness and contrast.
@farhan-raza
farhan-raza / image-to-visio.cs
Created August 4, 2023 17:29
Convert Image to Visio Online | JPG PNG BMP TIFF to Visio in C# .NET or Java
// Create a new diagram
Diagram diagram = new Diagram();
// Get page object by index
Page page0 = diagram.Pages[0];
// Set pinX, pinY, width and height
double pinX = 1, pinY = 1, width = 4, hieght = 5;
// Import Bitmap image as Visio shape
@farhan-raza
farhan-raza / Convert-KML-to-SHP.cs
Created November 29, 2022 18:31
Convert KML to SHP Programmatically in C# .NET | KML to SHP converter
// Specify conversion settings.
Aspose.Gis.ConversionOptions options = null;
// This options assigns Wgs84 to the destination layer.
if (Aspose.Gis.Drivers.Shapefile.SupportsSpatialReferenceSystem(Aspose.Gis.SpatialReferencing.SpatialReferenceSystem.Wgs84))
{
options = new Aspose.Gis.ConversionOptions()
{
DestinationSpatialReferenceSystem = Aspose.Gis.SpatialReferencing.SpatialReferenceSystem.Wgs84,
};
@farhan-raza
farhan-raza / Convert-SHP-to-SVG.cs
Created November 29, 2022 18:31
Shapefile to SVG | Convert SHP to SVG in C# .NET
// Create a map
using (var map = new Aspose.Gis.Rendering.Map(800, 400))
{
// Use the specified SRS
map.SpatialReferenceSystem = Aspose.Gis.SpatialReferencing.SpatialReferenceSystem.Wgs84;
// Use the specified style to draw lines
// We also have styles for points, lines, and surfaces.
var symbolizer = new Aspose.Gis.Rendering.Symbolizers.SimpleLine() { Width = Aspose.Gis.Rendering.Measurement.Pixels(2) };
// Open a layer and add to the map
@farhan-raza
farhan-raza / Generate-Aztec-Barcode-Error-Correction.java
Created September 21, 2022 20:19
Generate Aztec Barcode 2D Programmatically in Java
// Initialize BarcodeGenerator class object
BarcodeGenerator gen = new BarcodeGenerator(EncodeTypes.AZTEC, "Åspóse.Barcóde© is used to generate & recognize barcodes");
// Set size value in pixels
gen.getParameters().getBarcode().getXDimension().setPixels(2);
// Set symbol mode full range
gen.getParameters().getBarcode().getAztec().setAztecSymbolMode(AztecSymbolMode.FULL_RANGE);
// Set error correction capacity to 50%
@farhan-raza
farhan-raza / Generate-Aztec-Barcode-Error-Correction.cs
Created September 21, 2022 20:19
Generate Aztec Barcode 2D Programmatically in C#
// Initialize BarcodeGenerator class object
BarcodeGenerator gen = new BarcodeGenerator(EncodeTypes.Aztec, "Åspóse.Barcóde© is used to generate & recognize barcodes");
// Set size value in pixels
gen.Parameters.Barcode.XDimension.Pixels = 4;
// Set symbol mode FullRange
gen.Parameters.Barcode.Aztec.AztecSymbolMode = AztecSymbolMode.FullRange;
// Set error correction capacity to 50%
@farhan-raza
farhan-raza / Web page to PDF Encryption.java
Last active June 10, 2022 13:03
Save webpage as PDF in Java | Print web page to PDF
// Load input HTML file from URL
HTMLDocument document = new HTMLDocument("https://www.aspose.com/");
// Initialize PdfSaveOptions class object and set the encryption properties
PdfSaveOptions options = new PdfSaveOptions();
options.setEncryption(new PdfEncryptionInfo("user", "owner", PdfPermissions.PrintDocument, PdfEncryptionAlgorithm.RC4_128));
// Save output PDF file with encryption
Converter.convertHTML(document, options, "URLtoPDF_encrypted.pdf");
@farhan-raza
farhan-raza / Web page to PDF Encryption.cs
Last active June 10, 2022 13:03
Save webpage as PDF in C# | C# print web page to PDF
// Load input HTML from URL
HTMLDocument document = new HTMLDocument("https://www.aspose.com");
// Initialize PdfPermissions class object to allow printing and form filling in the PDF document
PdfPermissions permissions = PdfPermissions.PrintDocument | PdfPermissions.FillForm;
// Initialize PdfSaveOptions class object and set the encryption properties
PdfSaveOptions options = new PdfSaveOptions();
options.Encryption = new PdfEncryptionInfo("user", "owner", permissions, Encryption.PdfEncryptionAlgorithm.RC4_128);
@farhan-raza
farhan-raza / Add_Image_Watermark.cs
Created January 9, 2021 21:35
Insert or Delete Text/Image Watermark in PDF File using C#
// Load input PDF document
Document pdfDocument = new Document(dataDir + "Input.pdf");
// Access any page of the input PDF
Page testpage = pdfDocument.Pages[1];
// Create image stamp
ImageStamp imageStamp = new ImageStamp(dataDir + "aspose-logo.png");
imageStamp.Background = true;
imageStamp.Height = 300;
@farhan-raza
farhan-raza / SetLicense.cs
Last active January 7, 2021 00:26
Install or Apply License for Aspose.Total API
// Set license for all APIs one by one
Aspose.Words.License WordsLicense = new Aspose.Words.License();
WordsLicense.SetLicense(@"D:\Test\Aspose.Total.Product.Family.lic");
// Comment the code if you do not want to set license for any of the API
//Aspose.Pdf.License PdfLicense = new Aspose.Pdf.License();
//PdfLicense.SetLicense(@"D:\Test\Aspose.Total.Product.Family.lic");
Aspose.Cells.License CellsLicense = new Aspose.Cells.License();
CellsLicense.SetLicense(@"D:\Test\Aspose.Total.Product.Family.lic");