summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-04 23:57:01 -0300
committerGabriel Schneider <[email protected]>2026-11-05 01:02:08 -0300
commit96cabca7ebe287692ebdff0dba6bb2897eba9d3e (patch)
treefc74379958b5d6763966e4bc7c65e6a08e9ff4d5
parentb4863573f775c73ca4e9aa233af2f6e5113c06b3 (diff)
downloadpardes-96cabca7ebe287692ebdff0dba6bb2897eba9d3e.tar.gz
pardes-96cabca7ebe287692ebdff0dba6bb2897eba9d3e.zip
pdf: the test PDFs are files under test/pdf-fixtures, byte for byte what the generators wrote, where pdf.zig wrote each object by object (139 lines fewer there): testFixture reads one, the two outlines sized by the bridge's limits stay generated, and the sections bench embeds its outline
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
-rw-r--r--src/ninep/ctl.zig4
-rw-r--r--src/pdf.zig195
-rw-r--r--src/tui/tui.zig4
-rw-r--r--test/mode.zig2
-rw-r--r--test/pdf-fixtures/links.pdf55
-rw-r--r--test/pdf-fixtures/offset-rotated.pdf29
-rw-r--r--test/pdf-fixtures/outline.pdf54
-rw-r--r--test/pdf-fixtures/rotated-link-empty-uri.pdf25
-rw-r--r--test/pdf-fixtures/rotated-link-javascript.pdf25
-rw-r--r--test/pdf-fixtures/rotated-link-missing-dest.pdf25
-rw-r--r--test/pdf-fixtures/rotated-link.pdf25
-rw-r--r--test/pdf-fixtures/tall.pdf211
-rw-r--r--test/pdf.zig18
-rw-r--r--test/pdf_sections_bench.zig3
14 files changed, 487 insertions, 188 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index 7c566f23..a1504acb 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -2173,7 +2173,7 @@ test "a truncated PDF fails its look with its path and why" {
defer p.deinit();
var tmp = testing.tmpDir(.{});
defer tmp.cleanup();
- const bytes = try @import("mupdf").makeLinksTestPdf(testing.allocator);
+ const bytes = try @import("mupdf").testFixture(testing.allocator, "links.pdf");
defer testing.allocator.free(bytes);
try tmp.dir.writeFile(testing.io, .{ .sub_path = "cut.pdf", .data = bytes[0..40] });
var dir_buf: [4096]u8 = undefined;
@@ -2190,7 +2190,7 @@ test "a PDF's body reads its page's text layer, and takes no write" {
defer p.deinit();
var tmp = testing.tmpDir(.{});
defer tmp.cleanup();
- const bytes = try @import("mupdf").makeLinksTestPdf(testing.allocator);
+ const bytes = try @import("mupdf").testFixture(testing.allocator, "links.pdf");
defer testing.allocator.free(bytes);
try tmp.dir.writeFile(testing.io, .{ .sub_path = "doc.pdf", .data = bytes });
var dir_buf: [4096]u8 = undefined;
diff --git a/src/pdf.zig b/src/pdf.zig
index a68bf48a..7cfb86d5 100644
--- a/src/pdf.zig
+++ b/src/pdf.zig
@@ -1252,6 +1252,18 @@ fn openTestFile(path: []const u8) !Document {
return Document.openBytes(bytes);
}
+/// TEST-ONLY (here and in the core's tests, which run in the repository's
+/// root): one of test/pdf-fixtures' PDFs, whole. `outline.pdf`, an outline
+/// of every kind (a branch with neither title nor destination over a UTF-16
+/// child, an empty title, an external link); `offset-rotated.pdf`, one page
+/// with an offset CropBox and /Rotate 90 and no outline; `links.pdf`,
+/// external, internal, same-URI and link-only annotations; `tall.pdf`, one
+/// `tall_test_page` labelled every 100 pt; `rotated-link*.pdf`, a link on
+/// the rotated page by URI, empty URI, JavaScript, a missing destination.
+pub fn testFixture(gpa: std.mem.Allocator, comptime name: []const u8) ![]u8 {
+ return std.Io.Dir.cwd().readFileAlloc(std.testing.io, "test/pdf-fixtures/" ++ name, gpa, .unlimited);
+}
+
fn allocateGeneratedPdf(
gpa: std.mem.Allocator,
offsets: []usize,
@@ -1281,144 +1293,11 @@ fn finishGeneratedPdf(bytes: *std.Io.Writer, offsets: []const usize) !void {
);
}
-fn emitOffsetRotatedPdf(bytes: *std.Io.Writer, offsets: []usize, stream: []const u8) !void {
- try bytes.writeAll("%PDF-1.4\n%\xE2\xE3\xCF\xD3\n");
- try beginPdfObject(bytes, offsets, 1);
- try bytes.writeAll("<< /Type /Catalog /Pages 2 0 R >>\nendobj\n");
- try beginPdfObject(bytes, offsets, 2);
- try bytes.writeAll("<< /Type /Pages /Count 1 /Kids [3 0 R] >>\nendobj\n");
- try beginPdfObject(bytes, offsets, 3);
- try bytes.writeAll("<< /Type /Page /Parent 2 0 R /MediaBox [100 200 300 400] " ++
- "/CropBox [120 220 280 370] /Rotate 90 /Resources << >> " ++
- "/Contents 4 0 R >>\nendobj\n");
- try beginPdfObject(bytes, offsets, 4);
- try bytes.print("<< /Length {d} >>\nstream\n{s}endstream\nendobj\n", .{ stream.len, stream });
- try finishGeneratedPdf(bytes, offsets);
-}
-
-/// TEST-ONLY (here and in the core's tests): pages, no outline tree.
-pub fn makeNoOutlineTestPdf(gpa: std.mem.Allocator) ![]u8 {
- const stream = "q 1 0 0 rg 120 220 160 150 re f Q\n";
- var offsets: [5]usize = undefined;
- return allocateGeneratedPdf(gpa, &offsets, stream, emitOffsetRotatedPdf);
-}
-
-fn emitOutlinePdf(bytes: *std.Io.Writer, offsets: []usize, _: void) !void {
- try bytes.writeAll("%PDF-1.7\n%\xE2\xE3\xCF\xD3\n");
- try beginPdfObject(bytes, offsets, 1);
- try bytes.writeAll("<< /Type /Catalog /Pages 2 0 R /Outlines 7 0 R /PageMode /UseOutlines >>\nendobj\n");
- try beginPdfObject(bytes, offsets, 2);
- try bytes.writeAll("<< /Type /Pages /Count 3 /Kids [3 0 R 4 0 R 5 0 R] >>\nendobj\n");
- for (3..6) |page| {
- try beginPdfObject(bytes, offsets, page);
- try bytes.writeAll("<< /Type /Page /Parent 2 0 R /MediaBox [0 0 200 300] /Resources << >> >>\nendobj\n");
- }
- try beginPdfObject(bytes, offsets, 6);
- try bytes.writeAll("<< >>\nendobj\n");
- try beginPdfObject(bytes, offsets, 7);
- try bytes.writeAll("<< /Type /Outlines /First 8 0 R /Last 11 0 R /Count 4 >>\nendobj\n");
- // Destinationless branch with a deliberately missing /Title.
- try beginPdfObject(bytes, offsets, 8);
- try bytes.writeAll("<< /Parent 7 0 R /First 9 0 R /Last 9 0 R /Next 10 0 R /Count 1 >>\nendobj\n");
- // UTF-16BE "Café 子", with bold/italic + color metadata.
- try beginPdfObject(bytes, offsets, 9);
- try bytes.writeAll("<< /Title <FEFF00430061006600E900205B50> /Parent 8 0 R " ++
- "/Dest [4 0 R /XYZ 12 34 null] /F 3 /C [0.2 0.4 0.6] >>\nendobj\n");
- // A present empty title and a destination with only one usable axis.
- try beginPdfObject(bytes, offsets, 10);
- try bytes.writeAll("<< /Title () /Parent 7 0 R /Prev 8 0 R /Next 11 0 R " ++
- "/Dest [5 0 R /FitH 70] >>\nendobj\n");
- try beginPdfObject(bytes, offsets, 11);
- try bytes.writeAll("<< /Title (External) /Parent 7 0 R /Prev 10 0 R " ++
- "/A << /S /URI /URI (https://example.com/manual) >> >>\nendobj\n");
- try finishGeneratedPdf(bytes, offsets);
-}
-
-/// TEST-ONLY (here and in the core's tests): an outline of every kind.
-pub fn makeOutlineTestPdf(gpa: std.mem.Allocator) ![]u8 {
- var offsets: [12]usize = undefined;
- return allocateGeneratedPdf(gpa, &offsets, {}, emitOutlinePdf);
-}
-
-fn emitLinksPdf(bytes: *std.Io.Writer, offsets: []usize, _: void) !void {
- const stream = "BT /F1 6 Tf 20 240 Td (target.txt) Tj ET\n" ++
- "BT /F1 6 Tf 20 120 Td (https://example.com/same) Tj ET\n" ++
- "BT /F1 6 Tf 20 60 Td (label) Tj ET\n";
- try bytes.writeAll("%PDF-1.7\n%\xE2\xE3\xCF\xD3\n");
- try beginPdfObject(bytes, offsets, 1);
- try bytes.writeAll("<< /Type /Catalog /Pages 2 0 R >>\nendobj\n");
- try beginPdfObject(bytes, offsets, 2);
- try bytes.writeAll("<< /Type /Pages /Count 2 /Kids [3 0 R 4 0 R] >>\nendobj\n");
- try beginPdfObject(bytes, offsets, 3);
- try bytes.writeAll("<< /Type /Page /Parent 2 0 R /MediaBox [0 0 200 300] /Resources << /Font << /F1 5 0 R >> >> /Contents 6 0 R /Annots [7 0 R 8 0 R 9 0 R 10 0 R] >>\nendobj\n");
- try beginPdfObject(bytes, offsets, 4);
- try bytes.writeAll("<< /Type /Page /Parent 2 0 R /MediaBox [0 0 200 300] /Resources << >> >>\nendobj\n");
- try beginPdfObject(bytes, offsets, 5);
- try bytes.writeAll("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>\nendobj\n");
- try beginPdfObject(bytes, offsets, 6);
- try bytes.print("<< /Length {d} >>\nstream\n{s}endstream\nendobj\n", .{ stream.len, stream });
- try beginPdfObject(bytes, offsets, 7);
- try bytes.writeAll("<< /Type /Annot /Subtype /Link /Rect [20 230 120 260] /Border [0 0 0] /A << /S /URI /URI (https://example.com/embedded) >> >>\nendobj\n");
- try beginPdfObject(bytes, offsets, 8);
- try bytes.writeAll("<< /Type /Annot /Subtype /Link /Rect [20 170 120 200] /Border [0 0 0] /Dest [4 0 R /XYZ 12 34 null] >>\nendobj\n");
- try beginPdfObject(bytes, offsets, 9);
- try bytes.writeAll("<< /Type /Annot /Subtype /Link /Rect [20 110 190 140] /Border [0 0 0] /A << /S /URI /URI (https://example.com/same) >> >>\nendobj\n");
- try beginPdfObject(bytes, offsets, 10);
- try bytes.writeAll("<< /Type /Annot /Subtype /Link /Rect [20 50 120 80] /Border [0 0 0] /A << /S /URI /URI (https://example.com/only) >> >>\nendobj\n");
- try finishGeneratedPdf(bytes, offsets);
-}
-
-/// TEST-ONLY: external, blank internal, identical-label URI, and link-only URI.
-pub fn makeLinksTestPdf(gpa: std.mem.Allocator) ![]u8 {
- var offsets: [11]usize = undefined;
- return allocateGeneratedPdf(gpa, &offsets, {}, emitLinksPdf);
-}
-
/// The tall test page: 600 x 9000 pt, fifteen A4 pages' height on one.
pub const tall_test_page: PageSize = .{ .width = 600, .height = 9000 };
-fn emitTallPdf(bytes: *std.Io.Writer, offsets: []usize, _: void) !void {
- // A labelled row every 100 pt, each with a slanting rule, so a band
- // edge or a seam between chunks cuts through text and through lines.
- var storage: [16 * 1024]u8 = undefined;
- var stream: std.Io.Writer = .fixed(&storage);
- var row: usize = 0;
- while (row * 100 + 160 < 9000) : (row += 1) {
- const y = 9000 - 60 - row * 100;
- stream.print(
- "BT /F1 28 Tf 40 {d} Td (Row {d}) Tj ET\n0.2 0.3 0.9 RG 3 w 20 {d} m 580 {d} l S\n",
- .{ y, row, y - 20, y - 80 },
- ) catch return error.GeneratedPdfTooLarge;
- }
- stream.writeAll("BT /F1 28 Tf 40 40 Td (bottommost) Tj ET\n") catch return error.GeneratedPdfTooLarge;
- const content = stream.buffered();
- try bytes.writeAll("%PDF-1.7\n%\xE2\xE3\xCF\xD3\n");
- try beginPdfObject(bytes, offsets, 1);
- try bytes.writeAll("<< /Type /Catalog /Pages 2 0 R >>\nendobj\n");
- try beginPdfObject(bytes, offsets, 2);
- try bytes.writeAll("<< /Type /Pages /Count 1 /Kids [3 0 R] >>\nendobj\n");
- try beginPdfObject(bytes, offsets, 3);
- try bytes.writeAll("<< /Type /Page /Parent 2 0 R /MediaBox [0 0 600 9000] /Resources << /Font << /F1 5 0 R >> >> /Contents 4 0 R >>\nendobj\n");
- try beginPdfObject(bytes, offsets, 4);
- try bytes.print("<< /Length {d} >>\nstream\n", .{content.len});
- try bytes.writeAll(content);
- try bytes.writeAll("endstream\nendobj\n");
- try beginPdfObject(bytes, offsets, 5);
- try bytes.writeAll("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>\nendobj\n");
- try finishGeneratedPdf(bytes, offsets);
-}
-
-/// TEST-ONLY: one page fifteen times as tall as it is wide (`tall_test_page`),
-/// "Row N" every 100 pt from the top and "bottommost" at its foot.
-pub fn makeTallTestPdf(gpa: std.mem.Allocator) ![]u8 {
- var offsets: [6]usize = undefined;
- return allocateGeneratedPdf(gpa, &offsets, {}, emitTallPdf);
-}
-
test "a tall page rasterizes at the size it is shown, however many max_dimensions tall" {
- const bytes = try makeTallTestPdf(std.testing.allocator);
- defer std.testing.allocator.free(bytes);
- var document = try Document.openBytes(bytes);
+ var document = try openTestFile("test/pdf-fixtures/tall.pdf");
defer document.deinit();
const size = try document.pageSize(0);
try std.testing.expectEqual(tall_test_page.width, size.width);
@@ -1466,9 +1345,7 @@ test "PDF links own URIs across page eviction and preserve internal coordinates"
const gpa = std.testing.allocator;
start(gpa);
defer stop();
- const fixture = try makeLinksTestPdf(gpa);
- defer gpa.free(fixture);
- var document = try Document.openBytes(fixture);
+ var document = try openTestFile("test/pdf-fixtures/links.pdf");
defer document.deinit();
var external = (try document.linkAt(gpa, 0, .{ .x = 0.3, .y = 0.18 })) orelse return error.NoLink;
defer external.deinit(gpa);
@@ -1501,34 +1378,16 @@ test "PDF links own URIs across page eviction and preserve internal coordinates"
try std.testing.expect(try document.linkAt(gpa, 0, .{ .x = 0.99, .y = 0.99 }) == null);
}
-fn emitRotatedLinkPdf(bytes: *std.Io.Writer, offsets: []usize, action: []const u8) !void {
- try bytes.writeAll("%PDF-1.7\n");
- try beginPdfObject(bytes, offsets, 1);
- try bytes.writeAll("<< /Type /Catalog /Pages 2 0 R >>\nendobj\n");
- try beginPdfObject(bytes, offsets, 2);
- try bytes.writeAll("<< /Type /Pages /Count 1 /Kids [3 0 R] >>\nendobj\n");
- try beginPdfObject(bytes, offsets, 3);
- try bytes.writeAll("<< /Type /Page /Parent 2 0 R /MediaBox [100 200 300 400] /CropBox [120 220 280 370] /Rotate 90 /Resources << >> /Annots [4 0 R] >>\nendobj\n");
- try beginPdfObject(bytes, offsets, 4);
- try bytes.print("<< /Type /Annot /Subtype /Link /Rect [120 220 160 270] /Border [0 0 0] {s} >>\nendobj\n", .{action});
- try finishGeneratedPdf(bytes, offsets);
-}
-
test "PDF links normalize cropped rotated annotations and ignore unsupported actions" {
const gpa = std.testing.allocator;
start(gpa);
defer stop();
- const actions = [_][]const u8{
- "/A << /S /URI /URI (https://example.com/rotated) >>",
- "/A << /S /URI /URI () >>",
- "/A << /S /JavaScript /JS (ignored) >>",
- "/Dest /missing_destination",
- };
- for (actions, 0..) |action, index| {
- var offsets: [5]usize = undefined;
- const fixture = try allocateGeneratedPdf(gpa, &offsets, action, emitRotatedLinkPdf);
- defer gpa.free(fixture);
- var document = try Document.openBytes(fixture);
+ // The page's link's action: a URI, an empty URI, JavaScript, a
+ // destination that is not there.
+ const fixtures = [_][]const u8{ "rotated-link.pdf", "rotated-link-empty-uri.pdf", "rotated-link-javascript.pdf", "rotated-link-missing-dest.pdf" };
+ for (fixtures, 0..) |name, index| {
+ var path: [64]u8 = undefined;
+ var document = try openTestFile(try std.fmt.bufPrint(&path, "test/pdf-fixtures/{s}", .{name}));
defer document.deinit();
var found = try document.linkAt(gpa, 0, .{ .x = 0.1, .y = 0.1 });
defer if (found) |*item| item.deinit(gpa);
@@ -1621,10 +1480,7 @@ fn makeWideOutlinePdf(gpa: std.mem.Allocator, items: usize) ![]u8 {
}
test "PDF outline is a stable owned DFS view with native destinations" {
- const fixture = try makeOutlineTestPdf(std.testing.allocator);
- defer std.testing.allocator.free(fixture);
-
- var document = try Document.openBytes(fixture);
+ var document = try openTestFile("test/pdf-fixtures/outline.pdf");
defer document.deinit();
try std.testing.expectEqual(@as(usize, 3), document.pages);
for (0..2) |fail_index| {
@@ -1702,9 +1558,7 @@ test "PDF outline accepts manual-sized trees and rejects item overflow atomicall
}
test "PDF outline absence and hostile depth are atomic and repeatable" {
- const plain_fixture = try makeNoOutlineTestPdf(std.testing.allocator);
- defer std.testing.allocator.free(plain_fixture);
- var plain_document = try Document.openBytes(plain_fixture);
+ var plain_document = try openTestFile("test/pdf-fixtures/offset-rotated.pdf");
defer plain_document.deinit();
var absent = try plain_document.outline(std.testing.allocator);
defer absent.deinit(std.testing.allocator);
@@ -1943,10 +1797,7 @@ test "highlighted render changes pixels while plain render stays stable" {
}
test "offset crop and rotation keep normalized highlights pixel-aligned" {
- const fixture = try makeNoOutlineTestPdf(std.testing.allocator);
- defer std.testing.allocator.free(fixture);
-
- var document = try Document.openBytes(fixture);
+ var document = try openTestFile("test/pdf-fixtures/offset-rotated.pdf");
defer document.deinit();
const plain = try document.render(std.testing.allocator, 0, .{}, &.{});
defer std.testing.allocator.free(plain.rgba);
diff --git a/src/tui/tui.zig b/src/tui/tui.zig
index 0230e7a9..a8f32c98 100644
--- a/src/tui/tui.zig
+++ b/src/tui/tui.zig
@@ -1135,9 +1135,9 @@ test "host watch closes initial race and reloads rename-over PDF while idle" {
const gpa = std.testing.allocator;
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
- const original = try pardes.pdf.makeOutlineTestPdf(gpa);
+ const original = try pardes.pdf.testFixture(gpa, "outline.pdf");
defer gpa.free(original);
- const replacement = try pardes.pdf.makeNoOutlineTestPdf(gpa);
+ const replacement = try pardes.pdf.testFixture(gpa, "offset-rotated.pdf");
defer gpa.free(replacement);
try tmp.dir.writeFile(io, .{ .sub_path = "live.pdf", .data = original });
try tmp.dir.writeFile(io, .{ .sub_path = "initial.pdf", .data = replacement });
diff --git a/test/mode.zig b/test/mode.zig
index 40a23fc4..cb618a98 100644
--- a/test/mode.zig
+++ b/test/mode.zig
@@ -101,7 +101,7 @@ test "Mode leaves image and PDF document modes unchanged" {
if (comptime panes.Pdf.enabled) {
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
- const bytes = try panes.Pdf.pdf.makeLinksTestPdf(std.testing.allocator);
+ const bytes = try panes.Pdf.pdf.testFixture(std.testing.allocator, "links.pdf");
defer std.testing.allocator.free(bytes);
try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "mode.pdf", .data = bytes });
var buffer: [4096]u8 = undefined;
diff --git a/test/pdf-fixtures/links.pdf b/test/pdf-fixtures/links.pdf
new file mode 100644
index 00000000..bc9aa255
--- /dev/null
+++ b/test/pdf-fixtures/links.pdf
@@ -0,0 +1,55 @@
+%PDF-1.7
+%����
+1 0 obj
+<< /Type /Catalog /Pages 2 0 R >>
+endobj
+2 0 obj
+<< /Type /Pages /Count 2 /Kids [3 0 R 4 0 R] >>
+endobj
+3 0 obj
+<< /Type /Page /Parent 2 0 R /MediaBox [0 0 200 300] /Resources << /Font << /F1 5 0 R >> >> /Contents 6 0 R /Annots [7 0 R 8 0 R 9 0 R 10 0 R] >>
+endobj
+4 0 obj
+<< /Type /Page /Parent 2 0 R /MediaBox [0 0 200 300] /Resources << >> >>
+endobj
+5 0 obj
+<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>
+endobj
+6 0 obj
+<< /Length 131 >>
+stream
+BT /F1 6 Tf 20 240 Td (target.txt) Tj ET
+BT /F1 6 Tf 20 120 Td (https://example.com/same) Tj ET
+BT /F1 6 Tf 20 60 Td (label) Tj ET
+endstream
+endobj
+7 0 obj
+<< /Type /Annot /Subtype /Link /Rect [20 230 120 260] /Border [0 0 0] /A << /S /URI /URI (https://example.com/embedded) >> >>
+endobj
+8 0 obj
+<< /Type /Annot /Subtype /Link /Rect [20 170 120 200] /Border [0 0 0] /Dest [4 0 R /XYZ 12 34 null] >>
+endobj
+9 0 obj
+<< /Type /Annot /Subtype /Link /Rect [20 110 190 140] /Border [0 0 0] /A << /S /URI /URI (https://example.com/same) >> >>
+endobj
+10 0 obj
+<< /Type /Annot /Subtype /Link /Rect [20 50 120 80] /Border [0 0 0] /A << /S /URI /URI (https://example.com/only) >> >>
+endobj
+xref
+0 11
+0000000000 65535 f
+0000000015 00000 n
+0000000064 00000 n
+0000000127 00000 n
+0000000288 00000 n
+0000000376 00000 n
+0000000446 00000 n
+0000000627 00000 n
+0000000768 00000 n
+0000000886 00000 n
+0000001023 00000 n
+trailer
+<< /Size 11 /Root 1 0 R >>
+startxref
+1159
+%%EOF
diff --git a/test/pdf-fixtures/offset-rotated.pdf b/test/pdf-fixtures/offset-rotated.pdf
new file mode 100644
index 00000000..74fb6800
--- /dev/null
+++ b/test/pdf-fixtures/offset-rotated.pdf
@@ -0,0 +1,29 @@
+%PDF-1.4
+%����
+1 0 obj
+<< /Type /Catalog /Pages 2 0 R >>
+endobj
+2 0 obj
+<< /Type /Pages /Count 1 /Kids [3 0 R] >>
+endobj
+3 0 obj
+<< /Type /Page /Parent 2 0 R /MediaBox [100 200 300 400] /CropBox [120 220 280 370] /Rotate 90 /Resources << >> /Contents 4 0 R >>
+endobj
+4 0 obj
+<< /Length 34 >>
+stream
+q 1 0 0 rg 120 220 160 150 re f Q
+endstream
+endobj
+xref
+0 5
+0000000000 65535 f
+0000000015 00000 n
+0000000064 00000 n
+0000000121 00000 n
+0000000267 00000 n
+trailer
+<< /Size 5 /Root 1 0 R >>
+startxref
+350
+%%EOF
diff --git a/test/pdf-fixtures/outline.pdf b/test/pdf-fixtures/outline.pdf
new file mode 100644
index 00000000..b0864599
--- /dev/null
+++ b/test/pdf-fixtures/outline.pdf
@@ -0,0 +1,54 @@
+%PDF-1.7
+%����
+1 0 obj
+<< /Type /Catalog /Pages 2 0 R /Outlines 7 0 R /PageMode /UseOutlines >>
+endobj
+2 0 obj
+<< /Type /Pages /Count 3 /Kids [3 0 R 4 0 R 5 0 R] >>
+endobj
+3 0 obj
+<< /Type /Page /Parent 2 0 R /MediaBox [0 0 200 300] /Resources << >> >>
+endobj
+4 0 obj
+<< /Type /Page /Parent 2 0 R /MediaBox [0 0 200 300] /Resources << >> >>
+endobj
+5 0 obj
+<< /Type /Page /Parent 2 0 R /MediaBox [0 0 200 300] /Resources << >> >>
+endobj
+6 0 obj
+<< >>
+endobj
+7 0 obj
+<< /Type /Outlines /First 8 0 R /Last 11 0 R /Count 4 >>
+endobj
+8 0 obj
+<< /Parent 7 0 R /First 9 0 R /Last 9 0 R /Next 10 0 R /Count 1 >>
+endobj
+9 0 obj
+<< /Title <FEFF00430061006600E900205B50> /Parent 8 0 R /Dest [4 0 R /XYZ 12 34 null] /F 3 /C [0.2 0.4 0.6] >>
+endobj
+10 0 obj
+<< /Title () /Parent 7 0 R /Prev 8 0 R /Next 11 0 R /Dest [5 0 R /FitH 70] >>
+endobj
+11 0 obj
+<< /Title (External) /Parent 7 0 R /Prev 10 0 R /A << /S /URI /URI (https://example.com/manual) >> >>
+endobj
+xref
+0 12
+0000000000 65535 f
+0000000015 00000 n
+0000000103 00000 n
+0000000172 00000 n
+0000000260 00000 n
+0000000348 00000 n
+0000000436 00000 n
+0000000457 00000 n
+0000000529 00000 n
+0000000611 00000 n
+0000000736 00000 n
+0000000830 00000 n
+trailer
+<< /Size 12 /Root 1 0 R >>
+startxref
+948
+%%EOF
diff --git a/test/pdf-fixtures/rotated-link-empty-uri.pdf b/test/pdf-fixtures/rotated-link-empty-uri.pdf
new file mode 100644
index 00000000..278f2348
--- /dev/null
+++ b/test/pdf-fixtures/rotated-link-empty-uri.pdf
@@ -0,0 +1,25 @@
+%PDF-1.7
+1 0 obj
+<< /Type /Catalog /Pages 2 0 R >>
+endobj
+2 0 obj
+<< /Type /Pages /Count 1 /Kids [3 0 R] >>
+endobj
+3 0 obj
+<< /Type /Page /Parent 2 0 R /MediaBox [100 200 300 400] /CropBox [120 220 280 370] /Rotate 90 /Resources << >> /Annots [4 0 R] >>
+endobj
+4 0 obj
+<< /Type /Annot /Subtype /Link /Rect [120 220 160 270] /Border [0 0 0] /A << /S /URI /URI () >> >>
+endobj
+xref
+0 5
+0000000000 65535 f
+0000000009 00000 n
+0000000058 00000 n
+0000000115 00000 n
+0000000261 00000 n
+trailer
+<< /Size 5 /Root 1 0 R >>
+startxref
+375
+%%EOF
diff --git a/test/pdf-fixtures/rotated-link-javascript.pdf b/test/pdf-fixtures/rotated-link-javascript.pdf
new file mode 100644
index 00000000..e835e06b
--- /dev/null
+++ b/test/pdf-fixtures/rotated-link-javascript.pdf
@@ -0,0 +1,25 @@
+%PDF-1.7
+1 0 obj
+<< /Type /Catalog /Pages 2 0 R >>
+endobj
+2 0 obj
+<< /Type /Pages /Count 1 /Kids [3 0 R] >>
+endobj
+3 0 obj
+<< /Type /Page /Parent 2 0 R /MediaBox [100 200 300 400] /CropBox [120 220 280 370] /Rotate 90 /Resources << >> /Annots [4 0 R] >>
+endobj
+4 0 obj
+<< /Type /Annot /Subtype /Link /Rect [120 220 160 270] /Border [0 0 0] /A << /S /JavaScript /JS (ignored) >> >>
+endobj
+xref
+0 5
+0000000000 65535 f
+0000000009 00000 n
+0000000058 00000 n
+0000000115 00000 n
+0000000261 00000 n
+trailer
+<< /Size 5 /Root 1 0 R >>
+startxref
+388
+%%EOF
diff --git a/test/pdf-fixtures/rotated-link-missing-dest.pdf b/test/pdf-fixtures/rotated-link-missing-dest.pdf
new file mode 100644
index 00000000..42d7ccec
--- /dev/null
+++ b/test/pdf-fixtures/rotated-link-missing-dest.pdf
@@ -0,0 +1,25 @@
+%PDF-1.7
+1 0 obj
+<< /Type /Catalog /Pages 2 0 R >>
+endobj
+2 0 obj
+<< /Type /Pages /Count 1 /Kids [3 0 R] >>
+endobj
+3 0 obj
+<< /Type /Page /Parent 2 0 R /MediaBox [100 200 300 400] /CropBox [120 220 280 370] /Rotate 90 /Resources << >> /Annots [4 0 R] >>
+endobj
+4 0 obj
+<< /Type /Annot /Subtype /Link /Rect [120 220 160 270] /Border [0 0 0] /Dest /missing_destination >>
+endobj
+xref
+0 5
+0000000000 65535 f
+0000000009 00000 n
+0000000058 00000 n
+0000000115 00000 n
+0000000261 00000 n
+trailer
+<< /Size 5 /Root 1 0 R >>
+startxref
+377
+%%EOF
diff --git a/test/pdf-fixtures/rotated-link.pdf b/test/pdf-fixtures/rotated-link.pdf
new file mode 100644
index 00000000..47a8b3eb
--- /dev/null
+++ b/test/pdf-fixtures/rotated-link.pdf
@@ -0,0 +1,25 @@
+%PDF-1.7
+1 0 obj
+<< /Type /Catalog /Pages 2 0 R >>
+endobj
+2 0 obj
+<< /Type /Pages /Count 1 /Kids [3 0 R] >>
+endobj
+3 0 obj
+<< /Type /Page /Parent 2 0 R /MediaBox [100 200 300 400] /CropBox [120 220 280 370] /Rotate 90 /Resources << >> /Annots [4 0 R] >>
+endobj
+4 0 obj
+<< /Type /Annot /Subtype /Link /Rect [120 220 160 270] /Border [0 0 0] /A << /S /URI /URI (https://example.com/rotated) >> >>
+endobj
+xref
+0 5
+0000000000 65535 f
+0000000009 00000 n
+0000000058 00000 n
+0000000115 00000 n
+0000000261 00000 n
+trailer
+<< /Size 5 /Root 1 0 R >>
+startxref
+402
+%%EOF
diff --git a/test/pdf-fixtures/tall.pdf b/test/pdf-fixtures/tall.pdf
new file mode 100644
index 00000000..e330ac10
--- /dev/null
+++ b/test/pdf-fixtures/tall.pdf
@@ -0,0 +1,211 @@
+%PDF-1.7
+%����
+1 0 obj
+<< /Type /Catalog /Pages 2 0 R >>
+endobj
+2 0 obj
+<< /Type /Pages /Count 1 /Kids [3 0 R] >>
+endobj
+3 0 obj
+<< /Type /Page /Parent 2 0 R /MediaBox [0 0 600 9000] /Resources << /Font << /F1 5 0 R >> >> /Contents 4 0 R >>
+endobj
+4 0 obj
+<< /Length 7211 >>
+stream
+BT /F1 28 Tf 40 8940 Td (Row 0) Tj ET
+0.2 0.3 0.9 RG 3 w 20 8920 m 580 8860 l S
+BT /F1 28 Tf 40 8840 Td (Row 1) Tj ET
+0.2 0.3 0.9 RG 3 w 20 8820 m 580 8760 l S
+BT /F1 28 Tf 40 8740 Td (Row 2) Tj ET
+0.2 0.3 0.9 RG 3 w 20 8720 m 580 8660 l S
+BT /F1 28 Tf 40 8640 Td (Row 3) Tj ET
+0.2 0.3 0.9 RG 3 w 20 8620 m 580 8560 l S
+BT /F1 28 Tf 40 8540 Td (Row 4) Tj ET
+0.2 0.3 0.9 RG 3 w 20 8520 m 580 8460 l S
+BT /F1 28 Tf 40 8440 Td (Row 5) Tj ET
+0.2 0.3 0.9 RG 3 w 20 8420 m 580 8360 l S
+BT /F1 28 Tf 40 8340 Td (Row 6) Tj ET
+0.2 0.3 0.9 RG 3 w 20 8320 m 580 8260 l S
+BT /F1 28 Tf 40 8240 Td (Row 7) Tj ET
+0.2 0.3 0.9 RG 3 w 20 8220 m 580 8160 l S
+BT /F1 28 Tf 40 8140 Td (Row 8) Tj ET
+0.2 0.3 0.9 RG 3 w 20 8120 m 580 8060 l S
+BT /F1 28 Tf 40 8040 Td (Row 9) Tj ET
+0.2 0.3 0.9 RG 3 w 20 8020 m 580 7960 l S
+BT /F1 28 Tf 40 7940 Td (Row 10) Tj ET
+0.2 0.3 0.9 RG 3 w 20 7920 m 580 7860 l S
+BT /F1 28 Tf 40 7840 Td (Row 11) Tj ET
+0.2 0.3 0.9 RG 3 w 20 7820 m 580 7760 l S
+BT /F1 28 Tf 40 7740 Td (Row 12) Tj ET
+0.2 0.3 0.9 RG 3 w 20 7720 m 580 7660 l S
+BT /F1 28 Tf 40 7640 Td (Row 13) Tj ET
+0.2 0.3 0.9 RG 3 w 20 7620 m 580 7560 l S
+BT /F1 28 Tf 40 7540 Td (Row 14) Tj ET
+0.2 0.3 0.9 RG 3 w 20 7520 m 580 7460 l S
+BT /F1 28 Tf 40 7440 Td (Row 15) Tj ET
+0.2 0.3 0.9 RG 3 w 20 7420 m 580 7360 l S
+BT /F1 28 Tf 40 7340 Td (Row 16) Tj ET
+0.2 0.3 0.9 RG 3 w 20 7320 m 580 7260 l S
+BT /F1 28 Tf 40 7240 Td (Row 17) Tj ET
+0.2 0.3 0.9 RG 3 w 20 7220 m 580 7160 l S
+BT /F1 28 Tf 40 7140 Td (Row 18) Tj ET
+0.2 0.3 0.9 RG 3 w 20 7120 m 580 7060 l S
+BT /F1 28 Tf 40 7040 Td (Row 19) Tj ET
+0.2 0.3 0.9 RG 3 w 20 7020 m 580 6960 l S
+BT /F1 28 Tf 40 6940 Td (Row 20) Tj ET
+0.2 0.3 0.9 RG 3 w 20 6920 m 580 6860 l S
+BT /F1 28 Tf 40 6840 Td (Row 21) Tj ET
+0.2 0.3 0.9 RG 3 w 20 6820 m 580 6760 l S
+BT /F1 28 Tf 40 6740 Td (Row 22) Tj ET
+0.2 0.3 0.9 RG 3 w 20 6720 m 580 6660 l S
+BT /F1 28 Tf 40 6640 Td (Row 23) Tj ET
+0.2 0.3 0.9 RG 3 w 20 6620 m 580 6560 l S
+BT /F1 28 Tf 40 6540 Td (Row 24) Tj ET
+0.2 0.3 0.9 RG 3 w 20 6520 m 580 6460 l S
+BT /F1 28 Tf 40 6440 Td (Row 25) Tj ET
+0.2 0.3 0.9 RG 3 w 20 6420 m 580 6360 l S
+BT /F1 28 Tf 40 6340 Td (Row 26) Tj ET
+0.2 0.3 0.9 RG 3 w 20 6320 m 580 6260 l S
+BT /F1 28 Tf 40 6240 Td (Row 27) Tj ET
+0.2 0.3 0.9 RG 3 w 20 6220 m 580 6160 l S
+BT /F1 28 Tf 40 6140 Td (Row 28) Tj ET
+0.2 0.3 0.9 RG 3 w 20 6120 m 580 6060 l S
+BT /F1 28 Tf 40 6040 Td (Row 29) Tj ET
+0.2 0.3 0.9 RG 3 w 20 6020 m 580 5960 l S
+BT /F1 28 Tf 40 5940 Td (Row 30) Tj ET
+0.2 0.3 0.9 RG 3 w 20 5920 m 580 5860 l S
+BT /F1 28 Tf 40 5840 Td (Row 31) Tj ET
+0.2 0.3 0.9 RG 3 w 20 5820 m 580 5760 l S
+BT /F1 28 Tf 40 5740 Td (Row 32) Tj ET
+0.2 0.3 0.9 RG 3 w 20 5720 m 580 5660 l S
+BT /F1 28 Tf 40 5640 Td (Row 33) Tj ET
+0.2 0.3 0.9 RG 3 w 20 5620 m 580 5560 l S
+BT /F1 28 Tf 40 5540 Td (Row 34) Tj ET
+0.2 0.3 0.9 RG 3 w 20 5520 m 580 5460 l S
+BT /F1 28 Tf 40 5440 Td (Row 35) Tj ET
+0.2 0.3 0.9 RG 3 w 20 5420 m 580 5360 l S
+BT /F1 28 Tf 40 5340 Td (Row 36) Tj ET
+0.2 0.3 0.9 RG 3 w 20 5320 m 580 5260 l S
+BT /F1 28 Tf 40 5240 Td (Row 37) Tj ET
+0.2 0.3 0.9 RG 3 w 20 5220 m 580 5160 l S
+BT /F1 28 Tf 40 5140 Td (Row 38) Tj ET
+0.2 0.3 0.9 RG 3 w 20 5120 m 580 5060 l S
+BT /F1 28 Tf 40 5040 Td (Row 39) Tj ET
+0.2 0.3 0.9 RG 3 w 20 5020 m 580 4960 l S
+BT /F1 28 Tf 40 4940 Td (Row 40) Tj ET
+0.2 0.3 0.9 RG 3 w 20 4920 m 580 4860 l S
+BT /F1 28 Tf 40 4840 Td (Row 41) Tj ET
+0.2 0.3 0.9 RG 3 w 20 4820 m 580 4760 l S
+BT /F1 28 Tf 40 4740 Td (Row 42) Tj ET
+0.2 0.3 0.9 RG 3 w 20 4720 m 580 4660 l S
+BT /F1 28 Tf 40 4640 Td (Row 43) Tj ET
+0.2 0.3 0.9 RG 3 w 20 4620 m 580 4560 l S
+BT /F1 28 Tf 40 4540 Td (Row 44) Tj ET
+0.2 0.3 0.9 RG 3 w 20 4520 m 580 4460 l S
+BT /F1 28 Tf 40 4440 Td (Row 45) Tj ET
+0.2 0.3 0.9 RG 3 w 20 4420 m 580 4360 l S
+BT /F1 28 Tf 40 4340 Td (Row 46) Tj ET
+0.2 0.3 0.9 RG 3 w 20 4320 m 580 4260 l S
+BT /F1 28 Tf 40 4240 Td (Row 47) Tj ET
+0.2 0.3 0.9 RG 3 w 20 4220 m 580 4160 l S
+BT /F1 28 Tf 40 4140 Td (Row 48) Tj ET
+0.2 0.3 0.9 RG 3 w 20 4120 m 580 4060 l S
+BT /F1 28 Tf 40 4040 Td (Row 49) Tj ET
+0.2 0.3 0.9 RG 3 w 20 4020 m 580 3960 l S
+BT /F1 28 Tf 40 3940 Td (Row 50) Tj ET
+0.2 0.3 0.9 RG 3 w 20 3920 m 580 3860 l S
+BT /F1 28 Tf 40 3840 Td (Row 51) Tj ET
+0.2 0.3 0.9 RG 3 w 20 3820 m 580 3760 l S
+BT /F1 28 Tf 40 3740 Td (Row 52) Tj ET
+0.2 0.3 0.9 RG 3 w 20 3720 m 580 3660 l S
+BT /F1 28 Tf 40 3640 Td (Row 53) Tj ET
+0.2 0.3 0.9 RG 3 w 20 3620 m 580 3560 l S
+BT /F1 28 Tf 40 3540 Td (Row 54) Tj ET
+0.2 0.3 0.9 RG 3 w 20 3520 m 580 3460 l S
+BT /F1 28 Tf 40 3440 Td (Row 55) Tj ET
+0.2 0.3 0.9 RG 3 w 20 3420 m 580 3360 l S
+BT /F1 28 Tf 40 3340 Td (Row 56) Tj ET
+0.2 0.3 0.9 RG 3 w 20 3320 m 580 3260 l S
+BT /F1 28 Tf 40 3240 Td (Row 57) Tj ET
+0.2 0.3 0.9 RG 3 w 20 3220 m 580 3160 l S
+BT /F1 28 Tf 40 3140 Td (Row 58) Tj ET
+0.2 0.3 0.9 RG 3 w 20 3120 m 580 3060 l S
+BT /F1 28 Tf 40 3040 Td (Row 59) Tj ET
+0.2 0.3 0.9 RG 3 w 20 3020 m 580 2960 l S
+BT /F1 28 Tf 40 2940 Td (Row 60) Tj ET
+0.2 0.3 0.9 RG 3 w 20 2920 m 580 2860 l S
+BT /F1 28 Tf 40 2840 Td (Row 61) Tj ET
+0.2 0.3 0.9 RG 3 w 20 2820 m 580 2760 l S
+BT /F1 28 Tf 40 2740 Td (Row 62) Tj ET
+0.2 0.3 0.9 RG 3 w 20 2720 m 580 2660 l S
+BT /F1 28 Tf 40 2640 Td (Row 63) Tj ET
+0.2 0.3 0.9 RG 3 w 20 2620 m 580 2560 l S
+BT /F1 28 Tf 40 2540 Td (Row 64) Tj ET
+0.2 0.3 0.9 RG 3 w 20 2520 m 580 2460 l S
+BT /F1 28 Tf 40 2440 Td (Row 65) Tj ET
+0.2 0.3 0.9 RG 3 w 20 2420 m 580 2360 l S
+BT /F1 28 Tf 40 2340 Td (Row 66) Tj ET
+0.2 0.3 0.9 RG 3 w 20 2320 m 580 2260 l S
+BT /F1 28 Tf 40 2240 Td (Row 67) Tj ET
+0.2 0.3 0.9 RG 3 w 20 2220 m 580 2160 l S
+BT /F1 28 Tf 40 2140 Td (Row 68) Tj ET
+0.2 0.3 0.9 RG 3 w 20 2120 m 580 2060 l S
+BT /F1 28 Tf 40 2040 Td (Row 69) Tj ET
+0.2 0.3 0.9 RG 3 w 20 2020 m 580 1960 l S
+BT /F1 28 Tf 40 1940 Td (Row 70) Tj ET
+0.2 0.3 0.9 RG 3 w 20 1920 m 580 1860 l S
+BT /F1 28 Tf 40 1840 Td (Row 71) Tj ET
+0.2 0.3 0.9 RG 3 w 20 1820 m 580 1760 l S
+BT /F1 28 Tf 40 1740 Td (Row 72) Tj ET
+0.2 0.3 0.9 RG 3 w 20 1720 m 580 1660 l S
+BT /F1 28 Tf 40 1640 Td (Row 73) Tj ET
+0.2 0.3 0.9 RG 3 w 20 1620 m 580 1560 l S
+BT /F1 28 Tf 40 1540 Td (Row 74) Tj ET
+0.2 0.3 0.9 RG 3 w 20 1520 m 580 1460 l S
+BT /F1 28 Tf 40 1440 Td (Row 75) Tj ET
+0.2 0.3 0.9 RG 3 w 20 1420 m 580 1360 l S
+BT /F1 28 Tf 40 1340 Td (Row 76) Tj ET
+0.2 0.3 0.9 RG 3 w 20 1320 m 580 1260 l S
+BT /F1 28 Tf 40 1240 Td (Row 77) Tj ET
+0.2 0.3 0.9 RG 3 w 20 1220 m 580 1160 l S
+BT /F1 28 Tf 40 1140 Td (Row 78) Tj ET
+0.2 0.3 0.9 RG 3 w 20 1120 m 580 1060 l S
+BT /F1 28 Tf 40 1040 Td (Row 79) Tj ET
+0.2 0.3 0.9 RG 3 w 20 1020 m 580 960 l S
+BT /F1 28 Tf 40 940 Td (Row 80) Tj ET
+0.2 0.3 0.9 RG 3 w 20 920 m 580 860 l S
+BT /F1 28 Tf 40 840 Td (Row 81) Tj ET
+0.2 0.3 0.9 RG 3 w 20 820 m 580 760 l S
+BT /F1 28 Tf 40 740 Td (Row 82) Tj ET
+0.2 0.3 0.9 RG 3 w 20 720 m 580 660 l S
+BT /F1 28 Tf 40 640 Td (Row 83) Tj ET
+0.2 0.3 0.9 RG 3 w 20 620 m 580 560 l S
+BT /F1 28 Tf 40 540 Td (Row 84) Tj ET
+0.2 0.3 0.9 RG 3 w 20 520 m 580 460 l S
+BT /F1 28 Tf 40 440 Td (Row 85) Tj ET
+0.2 0.3 0.9 RG 3 w 20 420 m 580 360 l S
+BT /F1 28 Tf 40 340 Td (Row 86) Tj ET
+0.2 0.3 0.9 RG 3 w 20 320 m 580 260 l S
+BT /F1 28 Tf 40 240 Td (Row 87) Tj ET
+0.2 0.3 0.9 RG 3 w 20 220 m 580 160 l S
+BT /F1 28 Tf 40 140 Td (Row 88) Tj ET
+0.2 0.3 0.9 RG 3 w 20 120 m 580 60 l S
+BT /F1 28 Tf 40 40 Td (bottommost) Tj ET
+endstream
+endobj
+5 0 obj
+<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>
+endobj
+xref
+0 6
+0000000000 65535 f
+0000000015 00000 n
+0000000064 00000 n
+0000000121 00000 n
+0000000248 00000 n
+0000007510 00000 n
+trailer
+<< /Size 6 /Root 1 0 R >>
+startxref
+7580
+%%EOF
diff --git a/test/pdf.zig b/test/pdf.zig
index 1bbfa59c..9e183224 100644
--- a/test/pdf.zig
+++ b/test/pdf.zig
@@ -36,7 +36,7 @@ const PdfLinkTests = struct {
const Cell = struct { col: u16, row: u16 };
fn init(tmp: std.testing.TmpDir) !*Pardes {
- const bytes = try pdf_impl.makeLinksTestPdf(std.testing.allocator);
+ const bytes = try pdf_impl.testFixture(std.testing.allocator, "links.pdf");
defer std.testing.allocator.free(bytes);
try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "links.pdf", .data = bytes });
try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "target.txt", .data = "chosen file\n" });
@@ -228,9 +228,9 @@ test "explicit OS PDF opens and reloads keep their namespace path" {
const gpa = std.testing.allocator;
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
- const original = try pdf_impl.makeOutlineTestPdf(gpa);
+ const original = try pdf_impl.testFixture(gpa, "outline.pdf");
defer gpa.free(original);
- const replacement = try pdf_impl.makeNoOutlineTestPdf(gpa);
+ const replacement = try pdf_impl.testFixture(gpa, "offset-rotated.pdf");
defer gpa.free(replacement);
try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "live.pdf", .data = original });
var directory_buffer: [4096]u8 = undefined;
@@ -283,7 +283,7 @@ test "PdfSections Look follows the exact owning PDF, not an equal path" {
const gpa = std.testing.allocator;
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
- const fixture = try pdf_impl.makeOutlineTestPdf(gpa);
+ const fixture = try pdf_impl.testFixture(gpa, "outline.pdf");
defer gpa.free(fixture);
try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "outline.pdf", .data = fixture });
var path_buf: [256]u8 = undefined;
@@ -345,9 +345,9 @@ test "watched PDF reload replaces MuPDF state and preserves the reading view" {
const gpa = std.testing.allocator;
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
- const original = try pdf_impl.makeOutlineTestPdf(gpa);
+ const original = try pdf_impl.testFixture(gpa, "outline.pdf");
defer gpa.free(original);
- const replacement = try pdf_impl.makeNoOutlineTestPdf(gpa);
+ const replacement = try pdf_impl.testFixture(gpa, "offset-rotated.pdf");
defer gpa.free(replacement);
try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "live.pdf", .data = original });
var path_buf: [256]u8 = undefined;
@@ -986,7 +986,7 @@ test "a tall page is drawn at the display's resolution, in bands that are the wh
const gpa = std.testing.allocator;
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
- const bytes = try pdf_impl.makeTallTestPdf(gpa);
+ const bytes = try pdf_impl.testFixture(gpa, "tall.pdf");
defer gpa.free(bytes);
try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "tall.pdf", .data = bytes });
var dir_buf: [4096]u8 = undefined;
@@ -2005,7 +2005,7 @@ test "Esc back into a PDF keeps the offset within its page" {
const gpa = std.testing.allocator;
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
- const fixture = try pdf_impl.makeOutlineTestPdf(gpa);
+ const fixture = try pdf_impl.testFixture(gpa, "outline.pdf");
defer gpa.free(fixture);
try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "outline.pdf", .data = fixture });
var path_buf: [256]u8 = undefined;
@@ -2074,7 +2074,7 @@ test "a PDF's fit and tint, and Collapse, read in its ctl and come back from a D
const gpa = std.testing.allocator;
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
- const fixture = try pdf_impl.makeOutlineTestPdf(gpa);
+ const fixture = try pdf_impl.testFixture(gpa, "outline.pdf");
defer gpa.free(fixture);
try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "outline.pdf", .data = fixture });
var path_buf: [256]u8 = undefined;
diff --git a/test/pdf_sections_bench.zig b/test/pdf_sections_bench.zig
index 2796910c..b793bd0c 100644
--- a/test/pdf_sections_bench.zig
+++ b/test/pdf_sections_bench.zig
@@ -65,8 +65,7 @@ pub fn main(init: std.process.Init) !void {
const args = try init.minimal.args.toSlice(init.arena.allocator());
const config = parseArgs(args);
- const fixture = try pdf.makeOutlineTestPdf(gpa);
- defer gpa.free(fixture);
+ const fixture = @embedFile("pdf-fixtures/outline.pdf");
var path_buf: [256]u8 = undefined;
const path = try std.fmt.bufPrint(&path_buf, "/tmp/pardes-pdf-sections-bench-{d}.pdf", .{libc.getpid()});
try writeFile(path, fixture);