Skip to content

Instantly share code, notes, and snippets.

View conholdate-docs-gists's full-sized avatar

conholdate-docs-gists

View GitHub Profile
try (Comparer comparer = new Comparer(sourceFile)) {
comparer.add(targetFile1); // 1st.xlsx
comparer.add(targetFile2); // 2nd.xlsx
final Path resultPath = comparer.compare(resultFile);
}
using (Comparer comparer = new Comparer(File.OpenRead("source.docx")))
{
comparer.Add(File.OpenRead("target.docx"));
comparer.Compare(File.Create("result.docx"));
}
// Create an instance of Parser class
using (Parser parser = new Parser(Constants.SamplePdfWithBarcodes))
{
// Check if the file supports barcodes extraction
if (!parser.Features.Barcodes)
{
Console.WriteLine("The file doesn't support barcodes extraction.");
return;
}
// Create an instance of Parser class
using (Parser parser = new Parser(Constants.SamplePdfWithBarcodes))
{
// Check if the file supports barcodes extraction
if (!parser.Features.Barcodes)
{
Console.WriteLine("The file doesn't support barcodes extraction.");
return;
}
// Create an instance of Parser class
using (Parser parser = new Parser(filePath))
{
// Check if text extraction is supported
if (!parser.Features.Text)
{
Console.WriteLine("Text extraction isn't supported.");
return;
}
// Check if toc extraction is supported
// Create an instance of Parser class
using (Parser parser = new Parser(filePath))
{
// Extract attachments from the container
IEnumerable<ContainerItem> attachments = parser.GetContainer();
// Check if container extraction is supported
if (attachments == null)
{
Console.WriteLine("Container extraction isn't supported");
}
// Create an instance of Parser class
using (Parser parser = new Parser(filePath))
{
// Extract images
IEnumerable<PageImageArea> images = parser.GetImages();
// Check if images extraction is supported
if (images == null)
{
Console.WriteLine("Images extraction isn't supported");
return;
using(Parser parser = new Parser(filePath))
{
// Extract a text into the reader
using(TextReader reader = parser.GetText())
{
// Print a text from the document
// If text extraction isn't supported, a reader is null
Console.WriteLine(reader == null ? "Text extraction isn't supported" : reader.ReadToEnd());
}
}
public class VideoConnector : IVideoConnector
{
private readonly Dictionary<VideoFileType, Action<FFMpegArgumentOptions>> _optionsMap = new();
public VideoConnector()
{
_optionsMap.Add(VideoFileType.Avi, SetAviConvertOptions);
_optionsMap.Add(VideoFileType.Flv, SetFlvConvertOptions);
_optionsMap.Add(VideoFileType.Mkv, SetMkvConvertOptions);
_optionsMap.Add(VideoFileType.Mp4, SetMp4ConvertOptions);
_optionsMap.Add(VideoFileType.Wmv, SetWmvConvertOptions);
public class AudioConnector : IAudioConnector
{
private readonly Dictionary<AudioFileType, Action<FFMpegArgumentOptions>> _optionsMap = new Dictionary<AudioFileType, Action<FFMpegArgumentOptions>>();
public AudioConnector()
{
_optionsMap.Add(AudioFileType.Mp3, SetMp3ConvertOptions);
_optionsMap.Add(AudioFileType.Ogg, SetOggConvertOptions);
_optionsMap.Add(AudioFileType.Aac, SetAacConvertOptions);
_optionsMap.Add(AudioFileType.Ac3, SetAc3ConvertOptions);