Skip to content

Instantly share code, notes, and snippets.

View aspose-com-gists's full-sized avatar

Aspose.com Gists aspose-com-gists

View GitHub Profile
@aspose-com-gists
aspose-com-gists / pdf_optimize_same_quality.cs
Created September 7, 2026 11:22
Compress or Optimize PDF with Same Quality in C#
using System;
using System.IO;
using Aspose.Pdf;
using Aspose.Pdf.Optimization;
class Program
{
static void Main()
{
const string inputPdf = "input.pdf"; // PDF generated from XML
@aspose-com-gists
aspose-com-gists / excel_spreadsheet_creator.cs
Created September 5, 2026 11:05
Create MS Excel Spreadsheets Without MS Office in C#
using System;
using Aspose.Cells;
namespace AsposeCellsExample
{
class Program
{
static void Main(string[] args)
{
// Create a new workbook instance (default format is Xlsx)
@aspose-com-gists
aspose-com-gists / mhtml_to_pdf.java
Created August 7, 2026 07:25
MHTML to PDF Conversion Tutorial in Java
import com.aspose.html.HTMLDocument;
import com.aspose.html.converters.Converter;
import com.aspose.html.converters.PdfSaveOptions;
public class MhtmlToPdfConversion {
public static void main(String[] args) {
// Paths to the source MHTML file and the destination PDF file
String sourceMhtmlPath = "input.mhtml";
String destinationPdfPath = "output.pdf";
@aspose-com-gists
aspose-com-gists / add_barcode_to_pdf.java
Created August 5, 2026 19:52
Add Barcode to PDF in Java
import com.aspose.pdf.Document;
import com.aspose.pdf.Page;
import com.aspose.pdf.Barcode;
import com.aspose.pdf.BarcodeType;
import com.aspose.pdf.PlacementType;
public class AddBarcodeToPdf {
public static void main(String[] args) {
try {
// Load the existing PDF document
@aspose-com-gists
aspose-com-gists / pdf_barcode_insert.java
Created August 5, 2026 19:29
Add Barcode to PDF in Java
import com.aspose.pdf.*;
public class AddBarcodeToPdf {
public static void main(String[] args) {
// Load the existing PDF document
Document pdfDocument = new Document("input.pdf");
// Get the first page of the PDF
Page page = pdfDocument.getPages().get_Item(1);
@aspose-com-gists
aspose-com-gists / html_to_text.py
Created August 5, 2026 08:29
Convert HTML to TXT in Python
import os
import sys
import aspose.html as ah
import aspose.html.saving as ahs
def convert_html_to_txt(input_path: str, output_path: str, encoding: str = "utf-8") -> None:
"""
Converts an HTML file to a plain text (TXT) file using Aspose.HTML for Python via .NET.
"""
if not os.path.isfile(input_path):
@aspose-com-gists
aspose-com-gists / html_editor.py
Created August 5, 2026 07:04
Create Read and Edit HTML in Python
import os
import sys
from aspose.html import HtmlDocument, HtmlLoadOptions, HtmlSaveOptions, HtmlLoadOptions
def create_html(output_path: str):
# Create a new empty HTML document
doc = HtmlDocument()
try:
# Build <html><head><title>...</title></head><body>...</body></html>
html = doc.create_element("html")
@aspose-com-gists
aspose-com-gists / markdown_to_docx.py
Created July 23, 2026 18:12
MD to DOCX Conversion in Python
import markdown
from aspose.html import HtmlDocument, SaveFormat
# Path to the source Markdown file
markdown_path = "sample.md"
# Path for the generated DOCX file
docx_path = "output.docx"
# Step 1: Read Markdown content
with open(markdown_path, "r", encoding="utf-8") as md_file:
@aspose-com-gists
aspose-com-gists / pdf_to_txt_aspose.py
Created July 22, 2026 08:17
Convert PDF to TXT in Python
import aspose.pdf as ap
def convert_pdf_to_txt(input_path: str, output_path: str):
# Load the PDF document
document = ap.Document(input_path)
# Create a TextAbsorber to extract text
absorber = ap.TextAbsorber()
document.pages.accept(absorber)
@aspose-com-gists
aspose-com-gists / pdf_to_docx_aspose.py
Created July 20, 2026 08:49
Convert PDF to DOCX in Python
import aspose.pdf as ap
# Load the source PDF document
pdf_document = ap.Document("input.pdf")
# Optional: Set conversion options (e.g., preserve formatting)
save_options = ap.DocSaveOptions()
save_options.preserve_form_fields = True
save_options.preserve_text = True