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 / redact-image.java
Created October 3, 2024 08:50
Redact Images in Java | Redact JPG PNG BMP GIF TIFF Photos
final com.groupdocs.redaction.Redactor redactor = new com.groupdocs.redaction.Redactor(dataDir + "compare-annotations-pdf-java.jpg");
try
{
//Define the position on image
java.awt.Point samplePoint = new java.awt.Point(385, 485);
//Define the size of the area which need to be redacted
java.awt.Dimension sampleSize = new java.awt.Dimension(1793, 2069);
//Perform redaction
com.groupdocs.redaction.RedactorChangeLog result = redactor.apply(new com.groupdocs.redaction.redactions.ImageAreaRedaction(samplePoint,
new com.groupdocs.redaction.redactions.RegionReplacementOptions(java.awt.Color.BLUE, sampleSize)));
@farhan-raza
farhan-raza / convert-json-to-pdf.cs
Created May 24, 2024 10:12
Convert JSON to PDF in C#
// Create a Workbook object for storing JSON data
Aspose.Cells.Workbook JsonToPdf = new Aspose.Cells.Workbook();
// Access default worksheet
Aspose.Cells.Worksheet wsDefault = JsonToPdf.Worksheets[0];
// Read JSON data from file for saving to the selected worksheet
string jsonInputData = File.ReadAllText("input.json");
// Instantiate JsonLayoutOptions for handling JSON data
@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);