Skip to content

Commit 4c8b4e7

Browse files
committed
Prepare structure for work on QuestPDF renderer
1 parent d350adf commit 4c8b4e7

File tree

8 files changed

+973
-1
lines changed

8 files changed

+973
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ You can refer to the project [Wiki](https://github.com/manfromarce/DocSharp/wiki
3838

3939
### Roadmap
4040

41+
- Implement reverse RTF to DOCX conversion (⌛ started)
42+
- Implement DOCX renderer using QuestPDF (⌛ started)
4143
- Support more elements and attributes, and fix issues on edge cases
4244
- Reduce code duplication, cleanup
4345
- Async functions/progress callback (some tasks such as downloading images referenced in Markdown may take some time)
4446
- Improve support for right-to-left and complex script languages
45-
- Reverse RTF to DOCX conversion
4647

4748
### Credits
4849

samples/WpfApp1/WpfApp1.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<ProjectReference Include="..\..\src\DocSharp.Docx\DocSharp.Docx.csproj" />
2323
<ProjectReference Include="..\..\src\DocSharp.ImageSharp\DocSharp.ImageSharp.csproj" />
2424
<ProjectReference Include="..\..\src\DocSharp.Markdown\DocSharp.Markdown.csproj" />
25+
<ProjectReference Include="..\..\src\DocSharp.Renderer\DocSharp.Renderer.csproj" />
2526
<ProjectReference Include="..\..\src\DocSharp.SystemDrawing\DocSharp.SystemDrawing.csproj" />
2627
</ItemGroup>
2728

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net8.0;net9.0;net10.0;net462</TargetFrameworks>
5+
<ImplicitUsings>disable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
<LangVersion>latest</LangVersion>
8+
</PropertyGroup>
9+
10+
<!-- NuGet package -->
11+
<PropertyGroup>
12+
<AssemblyName>DocSharp.Renderer</AssemblyName>
13+
<AssemblyTitle>DocSharp.Renderer</AssemblyTitle>
14+
<PackageId>DocSharp.Renderer</PackageId>
15+
<Title>DocSharp.Renderer</Title>
16+
<Description>.NET library for converting documents. The DocSharp.Renderer package provides DOCX to PDF / XPS / SVG / images conversion using QuestPDF.</Description>
17+
<PackageTags>docx pdf svg jpg png xps convert converter renderer openxml office word</PackageTags>
18+
</PropertyGroup>
19+
20+
<ItemGroup>
21+
<PackageReference Include="QuestPDF" Version="2025.12.0" />
22+
</ItemGroup>
23+
24+
<ItemGroup>
25+
<ProjectReference Include="..\DocSharp.Docx\DocSharp.Docx.csproj" />
26+
</ItemGroup>
27+
28+
</Project>
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Xml.Linq;
6+
using DocSharp.Docx;
7+
using DocumentFormat.OpenXml;
8+
using DocumentFormat.OpenXml.Packaging;
9+
using DocumentFormat.OpenXml.Wordprocessing;
10+
using QuestPDF.Fluent;
11+
using QuestPDF.Infrastructure;
12+
using Document = QuestPDF.Fluent.Document;
13+
14+
namespace DocSharp.Renderer;
15+
16+
internal class DocxRenderer : DocxEnumerator<QuestPDF.Fluent.Document>, IDocumentRenderer<QuestPDF.Fluent.Document>
17+
{
18+
/// <summary>
19+
/// Render a DOCX document to a QuestPDF document.
20+
/// </summary>
21+
/// <param name="inputDocument">The input WordprocessingDocument instance.</param>
22+
/// <returns></returns>
23+
public QuestPDF.Fluent.Document Render(WordprocessingDocument inputDocument)
24+
{
25+
var outputDoc = QuestPDF.Fluent.Document.Create((_) =>
26+
{
27+
28+
});
29+
throw new NotImplementedException();
30+
}
31+
32+
/// <summary>
33+
/// Render a DOCX document to a QuestPDF document.
34+
/// </summary>
35+
/// <param name="inputStream">The input DOCX stream.</param>
36+
public QuestPDF.Fluent.Document Render(Stream inputStream)
37+
{
38+
using var docx = WordprocessingDocument.Open(inputStream, false);
39+
return Render(docx);
40+
}
41+
42+
/// <summary>
43+
/// Render a Flat OPC (Open XML) document to a QuestPDF document.
44+
/// </summary>
45+
/// <param name="flatOpc">The Flat OPC XDocument.</param>
46+
public QuestPDF.Fluent.Document Render(XDocument flatOpc)
47+
{
48+
using (var docx = WordprocessingDocument.FromFlatOpcDocument(flatOpc))
49+
return Render(docx);
50+
}
51+
52+
internal override void ProcessAnnotationReference(AnnotationReferenceMark annotationRef, Document sb)
53+
{
54+
}
55+
56+
internal override void ProcessBookmarkEnd(BookmarkEnd bookmarkEnd, Document sb)
57+
{
58+
}
59+
60+
internal override void ProcessBookmarkStart(BookmarkStart bookmarkStart, Document sb)
61+
{
62+
}
63+
64+
internal override void ProcessBreak(Break @break, Document sb)
65+
{
66+
}
67+
68+
internal override void ProcessCommentEnd(CommentRangeEnd commentEnd, Document sb)
69+
{
70+
}
71+
72+
internal override void ProcessCommentReference(CommentReference commentRef, Document sb)
73+
{
74+
}
75+
76+
internal override void ProcessCommentStart(CommentRangeStart commentStart, Document sb)
77+
{
78+
}
79+
80+
internal override void ProcessDocumentBackground(DocumentBackground background, Document sb)
81+
{
82+
}
83+
84+
internal override void ProcessDrawing(Drawing picture, Document sb)
85+
{
86+
}
87+
88+
internal override void ProcessFieldChar(FieldChar field, Document sb)
89+
{
90+
}
91+
92+
internal override void ProcessFieldCode(FieldCode field, Document sb)
93+
{
94+
}
95+
96+
internal override void ProcessMathElement(OpenXmlElement element, Document sb)
97+
{
98+
}
99+
100+
internal override void ProcessPageNumber(PageNumber pageNumber, Document sb)
101+
{
102+
}
103+
104+
internal override void ProcessPositionalTab(PositionalTab posTab, Document sb)
105+
{
106+
}
107+
108+
internal override void ProcessSymbolChar(SymbolChar symbolChar, Document sb)
109+
{
110+
}
111+
112+
internal override void ProcessText(Text text, Document sb)
113+
{
114+
}
115+
116+
internal override void ProcessVml(OpenXmlElement picture, Document sb)
117+
{
118+
}
119+
120+
internal override void EnsureSpace(Document sb)
121+
{
122+
}
123+
}

0 commit comments

Comments
 (0)