Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Demo/Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

<ItemGroup>
<ProjectReference Include="..\MuPDF.NET\MuPDF.NET.csproj" />
<ProjectReference Include="..\MuPDF.NET4LLM\MuPDF.NET4LLM.csproj" />
</ItemGroup>

</Project>
464 changes: 427 additions & 37 deletions Demo/Program.cs

Large diffs are not rendered by default.

Binary file added Demo/TestDocuments/Magazine.pdf
Binary file not shown.
Binary file added Demo/TestDocuments/national-capitals.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion Demo/annotations-freetext2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static void Run(string[] args)

// the annotation text with HTML and styling syntax
string text = $@"<p style=""text-align:justify;margin-top:-25px;"">
PyMuPDF <span style=""color: red;"">འདི་ ཡིག་ཆ་བཀྲམ་སྤེལ་གྱི་དོན་ལུ་ པའི་ཐོན་ཐུམ་སྒྲིལ་དྲག་ཤོས་དང་མགྱོགས་ཤོས་ཅིག་ཨིན།</span>
MuPDF.NET <span style=""color: red;"">འདི་ ཡིག་ཆ་བཀྲམ་སྤེལ་གྱི་དོན་ལུ་ པའི་ཐོན་ཐུམ་སྒྲིལ་དྲག་ཤོས་དང་མགྱོགས་ཤོས་ཅིག་ཨིན།</span>
<span style=""color:blue;"">Here is some <b>bold</b> and <i>italic</i> text, followed by <b><i>bold-italic</i></b>. Text-based check boxes: {bullet}.</span>
</p>";

Expand Down
2 changes: 1 addition & 1 deletion MuPDF.NET.Test/AnnotTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public void TestRichText()
string bullet = "\u2610\u2611\u2612"; // Output: ☐☑☒;

string text = $@"<p style=""text-align:justify;margin-top:-25px;"">
PyMuPDF <span style=""color: red;"">འདི་ ཡིག་ཆ་བཀྲམ་སྤེལ་གྱི་དོན་ལུ་ པའི་ཐོན་ཐུམ་སྒྲིལ་དྲག་ཤོས་དང་མགྱོགས་ཤོས་ཅིག་ཨིན།</span>
MuPDF.NET <span style=""color: red;"">འདི་ ཡིག་ཆ་བཀྲམ་སྤེལ་གྱི་དོན་ལུ་ པའི་ཐོན་ཐུམ་སྒྲིལ་དྲག་ཤོས་དང་མགྱོགས་ཤོས་ཅིག་ཨིན།</span>
<span style=""color:blue;"">Here is some <b>bold</b> and <i>italic</i> text, followed by <b><i>bold-italic</i></b>. Text-based check boxes: {bullet}.</span>
</p>";

Expand Down
8 changes: 0 additions & 8 deletions MuPDF.NET.Test/GeneralTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -486,14 +486,6 @@ assert repr(ee) == expected, f'Expected {expected=} but got {repr(ee)=}.'
{
Console.WriteLine($"test_2548(): {Utils.MUPDF_WARNINGS_STORE[i]}");
}

// This checks that PyMuPDF 1.23.7 fixes this bug, and also that earlier
// versions with updated MuPDF also fix the bug.
//rebased = hasattr(pymupdf, 'mupdf')
//expected = 'format error: cycle in structure tree\nstructure tree broken, assume tree is missing'
//if rebased:
// assert wt == expected, f'expected:\n {expected!r}\nwt:\n {wt!r}\n'
//assert not e
}

[Test]
Expand Down
Binary file modified MuPDF.NET.Test/resources/test_1645_expected.pdf
Binary file not shown.
30 changes: 29 additions & 1 deletion MuPDF.NET.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36511.14
Expand All @@ -9,6 +9,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MuPDF.NET.Test", "MuPDF.NET
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo", "Demo\Demo.csproj", "{D1CCB24F-A868-F185-9228-8CC249247C79}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MuPDF.NET4LLM", "MuPDF.NET4LLM\MuPDF.NET4LLM.csproj", "{9EC37CFF-ACB3-4212-B6C3-0DAC013BADDA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MuPDF.NET4LLM.Test", "MuPDF.NET4LLM.Test\MuPDF.NET4LLM.Test.csproj", "{5498436C-E1C0-418D-9DA3-0460A3C15953}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -55,6 +59,30 @@ Global
{D1CCB24F-A868-F185-9228-8CC249247C79}.Release|x64.Build.0 = Release|x64
{D1CCB24F-A868-F185-9228-8CC249247C79}.Release|x86.ActiveCfg = Release|x86
{D1CCB24F-A868-F185-9228-8CC249247C79}.Release|x86.Build.0 = Release|x86
{9EC37CFF-ACB3-4212-B6C3-0DAC013BADDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9EC37CFF-ACB3-4212-B6C3-0DAC013BADDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9EC37CFF-ACB3-4212-B6C3-0DAC013BADDA}.Debug|x64.ActiveCfg = Debug|x64
{9EC37CFF-ACB3-4212-B6C3-0DAC013BADDA}.Debug|x64.Build.0 = Debug|x64
{9EC37CFF-ACB3-4212-B6C3-0DAC013BADDA}.Debug|x86.ActiveCfg = Debug|x86
{9EC37CFF-ACB3-4212-B6C3-0DAC013BADDA}.Debug|x86.Build.0 = Debug|x86
{9EC37CFF-ACB3-4212-B6C3-0DAC013BADDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9EC37CFF-ACB3-4212-B6C3-0DAC013BADDA}.Release|Any CPU.Build.0 = Release|Any CPU
{9EC37CFF-ACB3-4212-B6C3-0DAC013BADDA}.Release|x64.ActiveCfg = Release|x64
{9EC37CFF-ACB3-4212-B6C3-0DAC013BADDA}.Release|x64.Build.0 = Release|x64
{9EC37CFF-ACB3-4212-B6C3-0DAC013BADDA}.Release|x86.ActiveCfg = Release|x86
{9EC37CFF-ACB3-4212-B6C3-0DAC013BADDA}.Release|x86.Build.0 = Release|x86
{5498436C-E1C0-418D-9DA3-0460A3C15953}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5498436C-E1C0-418D-9DA3-0460A3C15953}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5498436C-E1C0-418D-9DA3-0460A3C15953}.Debug|x64.ActiveCfg = Debug|Any CPU
{5498436C-E1C0-418D-9DA3-0460A3C15953}.Debug|x64.Build.0 = Debug|Any CPU
{5498436C-E1C0-418D-9DA3-0460A3C15953}.Debug|x86.ActiveCfg = Debug|Any CPU
{5498436C-E1C0-418D-9DA3-0460A3C15953}.Debug|x86.Build.0 = Debug|Any CPU
{5498436C-E1C0-418D-9DA3-0460A3C15953}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5498436C-E1C0-418D-9DA3-0460A3C15953}.Release|Any CPU.Build.0 = Release|Any CPU
{5498436C-E1C0-418D-9DA3-0460A3C15953}.Release|x64.ActiveCfg = Release|Any CPU
{5498436C-E1C0-418D-9DA3-0460A3C15953}.Release|x64.Build.0 = Release|Any CPU
{5498436C-E1C0-418D-9DA3-0460A3C15953}.Release|x86.ActiveCfg = Release|Any CPU
{5498436C-E1C0-418D-9DA3-0460A3C15953}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
21 changes: 19 additions & 2 deletions MuPDF.NET/Document.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1685,7 +1685,7 @@ private void _DeletePage(int pno)
/// Create a table of contents.
/// </summary>
/// <param name="simple">a bool to control output.</param>
/// <returns>Returns a list, where each entry consists of outline level, title, page number and link destination (if simple = False). For details see PyMuPDF's documentation.</returns>
/// <returns>Returns a list, where each entry consists of outline level, title, page number and link destination (if simple = False). For details see MuPDF's documentation.</returns>
/// <exception cref="Exception"></exception>
public List<Toc> GetToc(bool simple = true)
{
Expand Down Expand Up @@ -5950,6 +5950,23 @@ public void Bake(bool annots = true, bool widgets = true)
pdf.Dispose();
}

public void Dispose()
{
if (IsClosed)
throw new Exception("document closed");

if (Outline != null)
{
Outline.Dispose();
Outline = null;
}
ResetPageRefs();
IsClosed = true;
GraftMaps = new Dictionary<int, GraftMap>();
_nativeDocument.Dispose();
_nativeDocument = null;
}

public void Close()
{
if (IsClosed)
Expand Down Expand Up @@ -6000,7 +6017,7 @@ public int AddOcg(
PdfObj useFor = ocg.pdf_dict_put_dict(new PdfObj("Usage"), 3);
PdfObj ciName = mupdf.mupdf.pdf_new_name("CreatorInfo");
PdfObj creInfo = useFor.pdf_dict_put_dict(ciName, 2);
creInfo.pdf_dict_put_text_string(new PdfObj("Creator"), "PyMuPDF");
creInfo.pdf_dict_put_text_string(new PdfObj("Creator"), "MuPDF");

if (!string.IsNullOrEmpty(usage))
creInfo.pdf_dict_put_name(new PdfObj("Subtype"), usage);
Expand Down
3 changes: 1 addition & 2 deletions MuPDF.NET/Page.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using mupdf;
using mupdf;
using SkiaSharp;
using System;
using System.Collections;
Expand All @@ -10,7 +10,6 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using static MuPDF.NET.Global;
using static System.Net.Mime.MediaTypeNames;

namespace MuPDF.NET
Expand Down
Loading