Skip to content

Instantly share code, notes, and snippets.

View reknih's full-sized avatar

Martin Haug reknih

View GitHub Profile
@reknih
reknih / xmp-api.typ
Created August 23, 2025 16:24
Possible API for adding custom XMP info to PDF files
// Expressing the Factur-X schema in Typst
#let factur-x-ns = pdf.xmp.namespace(
prefix: "fx",
urn: "urn:factur-x:pdfa:CrossIndustryDocument:invoice:1p0#",
)
#let factur-x = factur-x-ns.schema(
DocumentType: (
// The type can be str (Text), bool (Boolean), datetime (Date), int
@reknih
reknih / lib.rs
Created August 1, 2025 09:51
PDF 1.7 containment rules
/// Role the structure element fulfills in the document for PDF 1.7 and below.
///
/// These are the predefined standard roles in PDF 1.7 and below, matching the
/// `https://www.iso.org/pdf/ssn` namespace. The writer may write their own
/// roles and then provide a mapping with [`StructTreeRoot::role_map`], or, if
/// writing PDF 2.0, with [`Namespace::role_map_ns`]. PDF 1.4+.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum StructRole {
/// The whole document.
Document,
@reknih
reknih / lib.rs
Last active August 1, 2025 10:42
PDF 2.0 containment rules
use std::num::NonZeroU16;
/// PDF 2.0 roles the structure element fulfills in the document.
///
/// These are the predefined standard roles in PDF 2.0, matching the
/// `https://www.iso.org/pdf2/ssn` namespace. The writer may write their own
/// types and then provide a mapping using [`Namespace::role_map_ns`]. PDF 2.0+.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum StructRole2 {
/// The whole document.
@reknih
reknih / din-letter.typ
Created March 26, 2023 10:20
A DIN letter template like the one we use at Typst
/*
DIN Letter template
Save this file in your project. Use it like this
in your project file:
#import "template.typ": *
#show: letter.with(
sender: [
@reknih
reknih / testKnapsack.java
Created July 3, 2017 14:32 — forked from keremistan/testKnapsack.java
These test cases might help you to understand the homework better and you might become aware of some cases that you might have forgotten in your implementation!
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.LinkedList;
import java.util.Random;
public class testKnapsack {
private Knapsack knapsackGlo;