Skip to content

Instantly share code, notes, and snippets.

View documentprocessing's full-sized avatar

Document Processing documentprocessing

View GitHub Profile
@documentprocessing
documentprocessing / read-metadata-information-using-hachoir-metadata-api.py
Created December 27, 2024 02:25
Read Metadata information using hachoir-metadata API for Python
from hachoir.parser import createParser
from hachoir.metadata import extractMetadata
# File to extract metadata from
file_path = "media_file.mp4"
# Create a parser for the file
parser = createParser(file_path)
if not parser:
print("Unable to parse file.")
@documentprocessing
documentprocessing / set-metadata-tags-for-document-in-python.py
Created December 20, 2024 18:11
Set Metadata Tags for a document in Python
from exiftool import ExifToolHelper
from datetime import datetime
with ExifToolHelper() as et:
now = datetime.strftime(datetime.now(), "%Y:%m:%d %H:%M:%S")
et.set_tags(
["rose.jpg", "skyblue.png"],
tags={"DateTimeOriginal": now},
params=["-P", "-overwrite_original"]
)
@documentprocessing
documentprocessing / read-document-metadata-in-python.py
Created December 20, 2024 14:17
Read Metadata information of a File with Python pyExifTool
import exiftool
files = ["2407.10671v3.pdf"]
with exiftool.ExifToolHelper() as et:
metadata = et.get_metadata(files)
for d in metadata:
for k, v in d.items():
print(f"Dict: {k} = {v}")
@documentprocessing
documentprocessing / insert-image-in-pptx-in-dotnet.cs
Created December 7, 2024 06:42
Add Image in a Slide in .NET
Presentation presentation = Presentation.Create("InsertImageInSlide.pptx");
// Create slide
Slide slide = new Slide();
// Add text shapes.
Image image1 = new Image("image.png");
// Set xAxis
image1.X = 180.0;
// Set yAxis
image1.Y = 128.0;
@documentprocessing
documentprocessing / insert-text-in-pptx-with-fileformat-dotnet.cs
Created December 7, 2024 06:06
Insert Text in PowerPoint Presentation PPTX file in .NET
// Create a new PowerPoint presentation at the specified file path
Presentation presentation = Presentation.Create("PowerPointPreesentation.pptx");
// Create a text shape for the title and set its properties
TextShape shape = new TextShape();
shape.Text = "Title: First Title From Fileformat.Dev";
shape.TextColor = "980078";
shape.FontFamily = "Arial";
// Create the slide and add the text shape to it
@documentprocessing
documentprocessing / create-pptx-with-file-format-slides-dotnet.cs
Created December 7, 2024 06:02
Create PowerPoint Presentation in .NET
// Create an object of the Presentation class.
Presentation presentation = Presentation.Create("blankPresentation.pptx");
//Perform necessary operations.
//...
// Call the Save method to save the PowerPoint file onto the disk.
presentation.Save();
@documentprocessing
documentprocessing / insert-text-in-xlsx-with-dotnet.cs
Created November 23, 2024 05:44
Insert Text in Excel XLSX using C#
Workbook workbook = new Workbook();
workbook.ApplyFontStyle("Arial", 14);
Worksheet worksheet = new Worksheet(workbook);
worksheet.insertValue("A10", 10, "some data", 0);
worksheet.saveDataToSheet(0);
workbook.Save("spreadsheet.xlsx");
@documentprocessing
documentprocessing / create-excel-xlsx-in-net.cs
Created November 23, 2024 05:41
Create Excel XLSX using FileFormat.Cells for .NET
// Create an object of the Workbook class.
Workbook workbook = new Workbook();
// Call the Save method to save the Excel file onto the disk.
workbook.Save("/spreadsheet.xlsx");
@documentprocessing
documentprocessing / read-eml-with-msgreader-api.cs
Created October 29, 2024 15:46
Read EML file using MSGReader API
var fileInfo = new FileInfo("d:\\testfile.eml");
var eml = MsgReader.Mime.Message.Load(fileInfo);
if (eml.Headers != null)
{
if (eml.Headers.To != null)
{
foreach (var recipient in eml.Headers.To)
{
var to = recipient.Address;
@documentprocessing
documentprocessing / read-outlook-msg-properties-with-msgreader.cs
Created October 29, 2024 15:41
Read Outlook MSG properties using MSGReader API
using (var msg = new MsgReader.Outlook.Storage.Message("testfile.msg"))
{
var from = msg.Sender;
var sentOn = msg.SentOn;
var recipientsTo = msg.GetEmailRecipients(MsgReader.Outlook.RecipientType.To, false, false);
var recipientsCc = msg.GetEmailRecipients(MsgReader.Outlook.RecipientType.Cc, false, false);
var subject = msg.Subject;
var htmlBody = msg.BodyHtml;
// etc...
}