Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
GroupDocsGists / ExtractWavMetadata.cs
Last active Mar 6, 2021
Extract Metadata and RIFF INFO of WAV files in C#
View ExtractWavMetadata.cs
// Extract Metadata of WAV files in C#
using (Metadata metadata = new Metadata("audio.wav"))
{
var root = metadata.GetRootPackage<WavRootPackage>();
Console.WriteLine("Bits per Sample: " + root.WavPackage.BitsPerSample); // Bits per Sample
Console.WriteLine("Block Align: " + root.WavPackage.BlockAlign); // Bock Align
Console.WriteLine("Byte Rate: " + root.WavPackage.ByteRate); // Byte Rate
Console.WriteLine("Number of Channels: " + root.WavPackage.NumberOfChannels); // Number of Channels
Console.WriteLine("Audio Format: " + root.WavPackage.AudioFormat); // Audio Format
Console.WriteLine("Sample Rate: " + root.WavPackage.SampleRate); // Sample Rate
@GroupDocsGists
GroupDocsGists / RenderApngWithPlayPause.cs
Created Mar 1, 2021
Render APNG and GIF Animations to HTML Web Pages with Play and Pause Option in .NET
View RenderApngWithPlayPause.cs
// Render APNG To HTML with Play and Pause Option
using (Viewer viewer = new Viewer("animation.apng"))
{
HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources("Web-Page-with-APNG.html");
viewer.View(options);
}
@GroupDocsGists
GroupDocsGists / ExtractImagesFromEBooks.cs
Created Feb 25, 2021
Extract Images from eBooks in C# using .NET Parsing API - (EPUB, FB2, CHM)
View ExtractImagesFromEBooks.cs
// Parse eBooks to Extract Images from EPUB, FB2, CHM file and save to disk in C#
using (Parser parser = new Parser("ebook.epub"))
{
// Extract images from the eBook
IEnumerable<PageImageArea> images = parser.GetImages();
ImageOptions options = new ImageOptions(ImageFormat.Jpeg);
int imageNumber = 0;
// Iterate over extracted images
foreach (PageImageArea image in images)
{
@GroupDocsGists
GroupDocsGists / ChangeQRCodeAppearance.java
Created Feb 22, 2021
Add QR Code to PDF, Excel, PPT, Word Documents, and Images in Java
View ChangeQRCodeAppearance.java
// Change Appearance of QR code in Java
// Setting background color, forecolor, transparency, etc.
Background background = new Background();
background.setColor(Color.BLACK);
background.setTransparency(0.5);
options.setBackground(background);
options.setForeColor(Color.WHITE);
@GroupDocsGists
GroupDocsGists / ConvertConsecutiveSlidesToPDF.java
Last active Feb 18, 2021
Convert Convert Presentations to PDF in Java | PPT, PPTX, ODP, etc
View ConvertConsecutiveSlidesToPDF.java
// Convert consecutive slides of presentation to PDF in Java
Converter converter = new Converter("presentation.pptx");
PdfConvertOptions options = new PdfConvertOptions();
options.setPageNumber(2);
options.setPagesCount(3);
converter.convert("PptConsecutiveSlidesToPDF.pdf", options);
@GroupDocsGists
GroupDocsGists / GeneratePdfReportFromJSON.java
Last active Feb 13, 2021
Generate PDF Report from JSON data using Template in Java
View GeneratePdfReportFromJSON.java
// Generate PDF Report from JSON data using TXT template in Java with GroupDocs.Assembly API
// Define datasource, template, and output report files.
String jsonFilePath = "dataPath/ManagerData.json";
String templateFilePath = "templatePath/template.txt";
String reportFilePath = "reportsPath/reportFromJSON.pdf";
// Instantiate JSON data source
JsonDataSource datasource= new JsonDataSource(jsonFilePath);
DataSourceInfo dataSourceInfo = new DataSourceInfo(datasource,"managers");
// Generate Report
DocumentAssembler assembler = new DocumentAssembler();
@GroupDocsGists
GroupDocsGists / CreateTemplateForInvoice.java
Last active Jan 27, 2021
Extract Data from Invoices or Receipts in Java
View CreateTemplateForInvoice.java
// Create Template to Parse Data from Invoice using Java
// First create Template Items
TemplateItem[] templateItems = new TemplateItem[]
{
new TemplateField(new TemplateFixedPosition(new Rectangle(new Point(35, 135), new Size(100, 10))), "FromCompany"),
new TemplateField(new TemplateFixedPosition(new Rectangle(new Point(35, 150), new Size(100, 35))), "FromAddress"),
new TemplateField(new TemplateFixedPosition(new Rectangle(new Point(35, 190), new Size(150, 2))), "FromEmail"),
new TemplateField(new TemplateFixedPosition(new Rectangle(new Point(35, 250), new Size(100, 2))), "ToCompany"),
new TemplateField(new TemplateFixedPosition(new Rectangle(new Point(35, 260), new Size(100, 15))), "ToAddress"),
new TemplateField(new TemplateFixedPosition(new Rectangle(new Point(35, 290), new Size(150, 2))), "ToEmail"),
@GroupDocsGists
GroupDocsGists / ConvertWebPToJPG.java
Created Jan 20, 2021
Convert WebP to JPG, PNG, GIF, TIFF, or PDF in Java
View ConvertWebPToJPG.java
// Convert WebP to JPG in Java using GroupDocs.Conversion API
Converter converter = new Converter("filePath/WebPImage.webp");
ImageConvertOptions options = new ImageConvertOptions();
options.setFormat(ImageFileType.Jpg);
converter.convert("path/WebPToJPG.jpg", options);
@GroupDocsGists
GroupDocsGists / CompareImages.cs
Last active Jan 12, 2021
Compare Images to Highlight Differences
View CompareImages.cs
// Compare JPG, PNG, GIF, BMP image formats using .NET Image Comparison API in C#
using (Comparer comparer = new Comparer("filepath/soureImage.jpg"))
{
CompareOptions options = new CompareOptions();
options.GenerateSummaryPage = false; // To get the difference summary, set it 'true'
comparer.Add("filepath/targetImage.jpg");
comparer.Compare("filepath/comparisonResultImage.jpg", options);
}
@GroupDocsGists
GroupDocsGists / RemoveSpecificMetadataProperties.cs
Last active Jan 12, 2021
Remove Specific Metadata Properties from Documents and Images
View RemoveSpecificMetadataProperties.cs
// Remove the metadata properties from documents and images that satisfies the customized filter using C#
using (Metadata metadata = new Metadata("filePath/document.docx"))
{
// Remove all the properties that:
// contains the name of the document author OR
// it refers to the last editor OR
// the property value is a string AND equal to the given string "GroupDocs"
var affected = metadata.RemoveProperties(
p => p.Tags.Contains(Tags.Person.Creator) ||
p.Tags.Contains(Tags.Person.Editor) ||