Skip to content
Closed
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
6 changes: 6 additions & 0 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project>
<PropertyGroup Condition="'$(IsTestProject)' != 'true'">
<IsTrimmable Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">true</IsTrimmable>
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">true</IsAotCompatible>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Content;
using DocumentLayoutAnalysis;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Xml;
Expand Down Expand Up @@ -94,6 +95,9 @@ private AltoXmlTextExporter(IWordExtractor wordExtractor, IPageSegmenter pageSeg
/// </summary>
/// <param name="document">The document to extract page layouts from.</param>
/// <param name="includePaths">Draw PdfPaths present in the page.</param>
#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Members from AltoDocument may be trimmed if not referenced directly")]
#endif
public string Get(PdfDocument document, bool includePaths = false)
{
var altoDocument = CreateAltoDocument("unknown");
Expand All @@ -105,13 +109,19 @@ public string Get(PdfDocument document, bool includePaths = false)
/// Get the Alto (XML) string of the page layout. Excludes <see cref="T:UglyToad.PdfPig.Geometry.PdfSubpath" />s.
/// </summary>
/// <param name="page">The page to export the XML layout for.</param>
#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Members from PageXmlDocument may be trimmed if not referenced directly")]
#endif
public string Get(Page page) => Get(page, false);

/// <summary>
/// Get the Alto (XML) string of the page layout.
/// </summary>
/// <param name="page">The page to export the XML layout for.</param>
/// <param name="includePaths">Whether the output should include the PdfPaths present in the page.</param>
#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Members from AltoDocument may be trimmed if not referenced directly")]
#endif
public string Get(Page page, bool includePaths)
{
var document = CreateAltoDocument("unknown");
Expand Down Expand Up @@ -355,6 +365,9 @@ private AltoDocument.AltoDescription GetAltoDescription(string fileName)
};
}

#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Members from AltoDocument may be trimmed if not referenced directly")]
#endif
private string Serialize(AltoDocument altoDocument)
{
var serializer = new XmlSerializer(typeof(AltoDocument));
Expand All @@ -377,6 +390,9 @@ private string Serialize(AltoDocument altoDocument)
/// <summary>
/// Deserialize an <see cref="AltoDocument"/> from a given Alto format XML document.
/// </summary>
#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Members from AltoDocument may be trimmed if not referenced directly")]
#endif
public static AltoDocument Deserialize(string xmlPath)
{
var serializer = new XmlSerializer(typeof(AltoDocument));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using ReadingOrderDetector;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Xml;
using System.Xml.Serialization;
Expand Down Expand Up @@ -105,6 +106,9 @@ public string Get(PdfDocument document, bool includePaths = false)
/// Get the PAGE-XML (XML) string of the pages layout. Excludes PdfPaths.
/// </summary>
/// <param name="page"></param>
#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Members from PageXmlDocument may be trimmed if not referenced directly")]
#endif
public string Get(Page page)
{
return Get(page, false);
Expand All @@ -115,6 +119,9 @@ public string Get(Page page)
/// </summary>
/// <param name="page"></param>
/// <param name="includePaths">Draw PdfPaths present in the page.</param>
#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Members from PageXmlDocument may be trimmed if not referenced directly")]
#endif
public string Get(Page page, bool includePaths)
{
PageXmlData data = new PageXmlData();
Expand Down Expand Up @@ -373,6 +380,9 @@ private PageXmlDocument.PageXmlGlyph ToPageXmlGlyph(Letter letter, PageXmlData d
};
}

#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Members from PageXmlDocument may be trimmed if not referenced directly")]
#endif
private string Serialize(PageXmlDocument pageXmlDocument)
{
XmlSerializer serializer = new XmlSerializer(typeof(PageXmlDocument));
Expand All @@ -395,6 +405,9 @@ private string Serialize(PageXmlDocument pageXmlDocument)
/// <summary>
/// Deserialize an <see cref="PageXmlDocument"/> from a given PAGE format XML document.
/// </summary>
#if NET6_0_OR_GREATER
[RequiresUnreferencedCode("Members from PageXmlDocument may be trimmed if not referenced directly")]
#endif
public static PageXmlDocument Deserialize(string xmlPath)
{
XmlSerializer serializer = new XmlSerializer(typeof(PageXmlDocument));
Expand Down
1 change: 1 addition & 0 deletions src/UglyToad.PdfPig.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C55738D2-3165-4D03-9CE2-10A2E2EEC465}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
Directory.Build.targets = Directory.Build.targets
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UglyToad.PdfPig.Fonts", "UglyToad.PdfPig.Fonts\UglyToad.PdfPig.Fonts.csproj", "{BBC8F94C-6E94-43FF-AB2E-47FF3C2B999F}"
Expand Down