Skip to content

Instantly share code, notes, and snippets.

@conholdate-gists
conholdate-gists / Compress-CSV.cs
Created February 27, 2024 20:50
Compress CSV Online Free | Reduce File Size with CSV Compressor in C#
// Create Archive class object
var arch = new Archive();
// Specify file names and create entry
arch.CreateEntry(dataDir + "input.csv", dataDir + "Sample.csv");
// Save compressed ZIP archive containing CSV data
arch.Save(dataDir + "csv_archive.zip");
@conholdate-gists
conholdate-gists / Convert-RGB-to-CMYK.cs
Created February 22, 2024 21:40
Convert RGB to CMYK Color Space Online | C# RGB to CMYK Converter
// Parse RGB color
Aspose.Svg.Drawing.Color rgb = Aspose.Svg.Drawing.Color.FromRgb(150, 121, 199);
// Convert RGB to CMYK
var cmyk = rgb.Convert(Aspose.Svg.Drawing.ColorModel.Cmyk);
// Print the CMYK color
Console.WriteLine("CMYK: " + cmyk.ToString());
@conholdate-gists
conholdate-gists / DWG-to-PDF-advanced.java
Created February 20, 2024 22:38
Convert DWG to PDF in Java | CAD to PDF Converter in Java
// Load input DWG drawing
com.aspose.cad.Image image = com.aspose.cad.Image.load("sample.dwg");
// Create an instance of PdfOptions
com.aspose.cad.imageoptions.PdfOptions pdfOptions = new com.aspose.cad.imageoptions.PdfOptions();
// Create an instance of CadRasterizationOptions and set its various properties
com.aspose.cad.imageoptions.CadRasterizationOptions rasterizationOptions = new com.aspose.cad.imageoptions.CadRasterizationOptions();
@conholdate-gists
conholdate-gists / Convert-HTML-to-JPG-image.cs
Created February 15, 2024 22:13
Convert HTML to Image in C# | HTML Webpage to JPG JPEG PNG Picture Photo
// Initialize an HTML document from the file
using var document = new Aspose.Html.HTMLDocument("spring.html");
// Initialize ImageSaveOptions
var options = new Aspose.Html.Saving.ImageSaveOptions(Aspose.Html.Rendering.Image.ImageFormat.Jpeg);
// Convert HTML to JPG
Aspose.Html.Converters.Converter.ConvertHTML(document, options, "spring-output.jpg");
@conholdate-gists
conholdate-gists / Word-DOCX-Viewer.cs
Created February 14, 2024 10:15
Free Word Document Viewer Online | Open and View Word DOCX DOC
// Instantiate viewer
using (Viewer viewer = new Viewer("resume.docx"))
{
// Set output HTML options
HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources();
// Render DOCX to HTML with embedded resources
viewer.View(options);
}
@conholdate-gists
conholdate-gists / compress-PSD.cs
Created February 12, 2024 08:55
Compress PSD in C# | Reduce File Size with PSD Compressor
// Load a PSD file
Aspose.PSD.Image image = Aspose.PSD.Image.Load("sample.psd");
// Define the compression method
Aspose.PSD.ImageOptions.PsdOptions options = new Aspose.PSD.ImageOptions.PsdOptions();
options.CompressionMethod = Aspose.PSD.FileFormats.Psd.CompressionMethod.Raw;
// Save compressed PSD image
image.Save("compressed.psd" , options);
@conholdate-gists
conholdate-gists / Add-Page-Number-PDF-all.java
Created February 2, 2024 08:53
Add Page Numbers to PDF Document | Insert Page Numbers to PDF Pages
// Open document
Document pdfDocument = new Document(dataDir + "merged.pdf");
// Create page number stamp
com.aspose.pdf.PageNumberStamp pageNumberStamp = new com.aspose.pdf.PageNumberStamp();
// Whether the stamp is background
pageNumberStamp.setBackground(false);
pageNumberStamp.setFormat("Page # of " + pdfDocument.getPages().size());
pageNumberStamp.setBottomMargin (10);
@conholdate-gists
conholdate-gists / crop-image.cs
Created January 31, 2024 09:04
Crop Image Online for Free - Crop Image in C# or Java
// Load an image using the RasterImage class
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load("aspose_logo.jpg");
// Cache the image for better performance
if (!rasterImage.IsCached)
{
rasterImage.CacheData();
}
// Set the coordinates with the Rectangle class
@conholdate-gists
conholdate-gists / merge-word-documents-one.cs
Created January 24, 2024 09:16
Merge Word Documents into One using C# | Combine Word Documents into One PDF
// Load input Word documents
Aspose.Words.Document doc1 = new Aspose.Words.Document("Input.docx");
Aspose.Words.Document doc2 = new Aspose.Words.Document("Input1.docx");
// Merge Word DOCX documents
doc1.AppendDocument(doc2, Aspose.Words.ImportFormatMode.KeepSourceFormatting);
// Save merged document as DOCX file
doc1.Save("merged.docx", Aspose.Words.SaveFormat.Docx);
@conholdate-gists
conholdate-gists / image-to-text-ocr.java
Created January 19, 2024 19:56
Convert Image to Text with OCR in Java | Recognize Text in JPG PNG Image OCR
// Create instance of OCR API
com.aspose.ocr.AsposeOCR api = new com.aspose.ocr.AsposeOCR();
// Specify recognition settings
com.aspose.ocr.RecognitionSettings settings = new com.aspose.ocr.RecognitionSettings();
settings.setDetectAreasMode(com.aspose.ocr.DetectAreasMode.PHOTO);
settings.setUpscaleSmallFont(true);
// Set processing filters
com.aspose.ocr.PreprocessingFilter filters = new com.aspose.ocr.PreprocessingFilter();