Skip to content

Commit f4479a7

Browse files
committed
v3.3.0
1 parent 3722f57 commit f4479a7

File tree

8 files changed

+85
-76
lines changed

8 files changed

+85
-76
lines changed

.vscode/launch.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@
1212
"program": "${workspaceFolder}/AzureDevOps.WikiPDFExport/bin/Debug/net5.0/win-x64/azuredevops-export-wiki.dll",
1313
"args": [
1414
"-v",
15-
"-p..\\AzureDevOps.WikiPDFExport.Test\\Tests\\Code",
15+
"-p..\\AzureDevOps.WikiPDFExport.Test\\Tests\\AzureDevOps.WikiPDFExport.wiki",
16+
"--attachments-path=..\\AzureDevOps.WikiPDFExport.Test\\Tests\\AzureDevOps.WikiPDFExport.wiki\\.attachments\\",
17+
//"-p..\\AzureDevOps.WikiPDFExport.Test\\Tests\\Code",
1618
// "-p..\\AzureDevOps.WikiPDFExport.Test\\Tests\\Azure-Platform-Design",
1719
// "-p..\\AzureDevOps.WikiPDFExport.Test\\Tests\\1k",
1820
// "-s..\\AzureDevOps.WikiPDFExport.Test\\Tests\\Test-Emoticon\\emoji.md",
19-
// "--attachments-path=..\\AzureDevOps.WikiPDFExport.Test\\Tests\\AzureDevOps.WikiPDFExport.wiki\\.attachments\\",
2021
"-h",
2122
"-b",
2223
// "-m",
23-
"--math",
24+
// "--math",
2425
//"--mathjax-path=MathJax.js",
2526
"--debug",
2627
// "--pathToHeading",
@@ -30,7 +31,7 @@
3031
"--footer-left=LEFT [subsection]",
3132
"--footer-center=CENTER [DATE]",
3233
"--footer-right=RIGHT page: [page] of [topage]",
33-
//"--css=devopswikistyle.css",
34+
"--css=devopswikistyle.css",
3435
"--open",
3536
//"--footer-hide-line"
3637
//"--footer-url=C:\\Git\\AzureDevOps.WikiPDFExport\\AzureDevOps.WikiPDFExport\\bin\\Debug\\netcoreapp3.1\\example-footer.html",
@@ -44,7 +45,7 @@
4445
//"--filter=tags:test,tags:license"
4546
// "-c"
4647
// "--organization=https://dev.azure.com/mmelcher",
47-
// "--pat=7dmhcnemllrx6rn2z5zoh35res6nnl5xnfkyzput3pueaoqrvwr" #add a q to the end. valid until August 2022.
48+
// "--pat=7dmhcnemllrx6rn2z5zoh35res6nnl5xnfkyzput3pueaoqrvwr" #add a 'q' to the end. valid until August 2022.
4849
],
4950
"cwd": "${workspaceFolder}/AzureDevOps.WikiPDFExport",
5051
"console": "internalConsole",

AzureDevOps.WikiPDFExport.Test/Tests/Code/Admin-Layout-and-Customization.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Smileys
2+
3+
😁♥️🎈✅💻🎥🧾⚖️🏎️😲🎯⚙️
4+
15
# Math
26

37
Area of a circle is $\pi r^2$

AzureDevOps.WikiPDFExport/WikiPDFExporter.cs

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,30 @@ public async Task Export()
154154
var head = "<meta http-equiv=Content-Type content=\"text/html; charset=utf-8\">";
155155
var headEnd = "</head>";
156156

157+
//this adds the css twice, but makes troubleshooting easier
158+
var cssPath = "";
159+
if (string.IsNullOrEmpty(_options.CSS))
160+
{
161+
cssPath = "devopswikistyle.css";
162+
Log("No CSS specified, using devopswikistyle.css", LogLevel.Information, 2);
163+
}
164+
else
165+
{
166+
cssPath = Path.GetFullPath(_options.CSS);
167+
if (!File.Exists(cssPath))
168+
{
169+
Log($"CSS file does not exist at path {cssPath}", LogLevel.Warning);
170+
}
171+
}
172+
173+
string style ="";
174+
if (File.Exists(cssPath))
175+
{
176+
var css = File.ReadAllText(cssPath);
177+
style = $"<style>{css}</style>";
178+
head += style;
179+
}
180+
157181
if (_options.ConvertMermaid)
158182
{
159183
string mermaid = !string.IsNullOrEmpty(_options.MermaidJsPath) ?
@@ -279,7 +303,7 @@ public async Task Export()
279303
File.WriteAllText(htmlPath, html);
280304
}
281305

282-
var path = ConvertHTMLToPDF(html);
306+
var path = ConvertHTMLToPDF(html, cssPath);
283307

284308
Console.ForegroundColor = ConsoleColor.Green;
285309
Console.WriteLine();
@@ -308,7 +332,7 @@ public async Task Export()
308332
}
309333
}
310334

311-
private string ConvertHTMLToPDF(string html)
335+
private string ConvertHTMLToPDF(string html, string cssPath)
312336
{
313337
Log("Converting HTML to PDF");
314338
Log("Ignore errors like 'Qt: Could not initialize OLE (error 80010106)'", LogLevel.Warning);
@@ -354,22 +378,6 @@ private string ConvertHTMLToPDF(string html)
354378
footerSettings.HtmUrl = _options.FooterUrl;
355379
}
356380

357-
358-
var cssPath = "";
359-
if (string.IsNullOrEmpty(_options.CSS))
360-
{
361-
cssPath = "devopswikistyle.css";
362-
Log("No CSS specified, using devopswikistyle.css", LogLevel.Information, 2);
363-
}
364-
else
365-
{
366-
cssPath = Path.GetFullPath(_options.CSS);
367-
if (!File.Exists(cssPath))
368-
{
369-
Log($"CSS file does not exist at path {cssPath}", LogLevel.Warning);
370-
}
371-
}
372-
373381
var doc = new HtmlToPdfDocument()
374382
{
375383
GlobalSettings = {
@@ -385,11 +393,11 @@ private string ConvertHTMLToPDF(string html)
385393
HtmlContent = html,
386394
WebSettings = {
387395
DefaultEncoding = "utf-8",
388-
UserStyleSheet = cssPath
396+
UserStyleSheet = "file://D:/Git/WikiPDFExport/AzureDevOps.WikiPDFExport/devopswikistyle.css"
389397
},
390398
HeaderSettings = headerSettings,
391399
FooterSettings = footerSettings,
392-
UseLocalLinks = true
400+
UseLocalLinks = true,
393401
}
394402
}
395403
};
@@ -840,7 +848,7 @@ async private Task<string> generateWorkItemLink(string stringId, WorkItemTrackin
840848
</span>
841849
</span>
842850
";
843-
851+
844852
}
845853

846854
public class MarkdownFile
219 KB
Binary file not shown.

README.md

Lines changed: 44 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -38,57 +38,22 @@ Currently it requires a x64 runtime.
3838
The download is available [here](https://github.com/MaxMelcher/AzureDevOps.WikiPDFExport/releases)
3939

4040
## ⚙ Configuration Options
41-
42-
### --help
43-
Help - outputs all the flags/parameters
44-
45-
### -o / --output
46-
The path to the export file including the filename, e.g. c:\export.pdf
47-
48-
### -b / --breakPage
49-
For every wiki page a new page in the PDF will be created
50-
51-
### -h / --heading
52-
For every wiki page create a heading in the PDF. If the file is called Home.md a new #Home-heading is added to PDF.
53-
54-
### -s / --single
55-
Path to a single markdown file to convert to PDF. If you want to write your changelog in the wiki, this is your parameter to only convert a single page.
56-
-p parameter is required, too.
57-
58-
### -p / --path
59-
Path to the wiki folder. If not provided, the current folder of the executable is used.
60-
If you only want to convert a subfolder and have images, then you must provide the path to the attachments folder with --attachments-path.
61-
6241
### --attachments-path
6342
Path to the .attachments folder. If not provided, the .attachments is assumed to be located under the folder of the wiki (-p/--path).
64-
65-
### -m / --mermaid
66-
Convert mermaid diagrams to SVG. Will download latest chromium, if chrome-path is not defined.
67-
68-
### --mermaidjs-path
69-
Path of the mermaid.js file. It'll be used if mermaid diagrams support is turned on (-m/--mermaid). If not specified, 'https://cdnjs.cloudflare.com/ajax/libs/mermaid/8.6.4/mermaid.min.js' will be downloaded.
70-
43+
### -b / --breakPage
44+
For every wiki page a new page in the PDF will be created
7145
### --chrome-path
7246
Path of the chrome or chromium executable. It'll be used if mermaid diagrams support is turned on (-m/--mermaid). If not specified, a headless version will be downloaded.
73-
7447
### --css
7548
Path to the stylesheet to overwrite the look of certain components in the PDF. See [styles.css](styles.css) for examples. To get the html file, use the [--debug flag](#-d----debug) to inspect and style it.
76-
7749
### -c / --highlight-code
7850
Highlight code blocks using highligh.js
79-
80-
### --highlight-style
81-
hightlight.js style used for code blocks. Defaults to 'vs'. See https://github.com/highlightjs/highlight.js/tree/main/src/styles for a full list.
82-
83-
### -v / --verbose
84-
Verbose mode. Logging will added to the console window
85-
8651
### -d / --debug
8752
Debug mode. Logs tons of stuff and even exports the intermediate html file
88-
89-
### --pathToHeading
90-
Add path of the file to the header
91-
53+
### --disableTelemetry
54+
Disables the telemetry tracking, see [Telemetry](#telemetry)
55+
### --filter
56+
Filters the pages depending on the page [yaml tags](https://docs.microsoft.com/en-us/azure/devops/project/wiki/wiki-markdown-guidance?view=azure-devops#yaml-tags).
9257
### --footer-left, --footer-center, --footer-right, --header-left, --header-center, --header-right,
9358
Headers and footers can be added to the document by the --header-* and
9459
--footer* arguments respectfully. In header and footer text string supplied
@@ -107,19 +72,39 @@ Headers and footers can be added to the document by the --header-* and
10772
* [doctitle] Replaced by the title of the output document
10873
* [sitepage] Replaced by the number of the page in the current site being converted
10974
* [sitepages] Replaced by the number of pages in the current site being converted
110-
75+
### --help
76+
Help - outputs all the flags/parameters
77+
### -h / --heading
78+
For every wiki page create a heading in the PDF. If the file is called Home.md a new #Home-heading is added to PDF.
11179
### --header-url, --footer-url
11280
Provide a path to html files that will be added as header and footer. See [example-footer.html](example-footer.html), [example-header.html](example-header.html)
113-
11481
### --HideHeaderLine, --hideFooterLine
11582
Removes the horizontal line in the header or footer.
116-
117-
### --disableTelemetry
118-
Disables the telemetry tracking, see [Telemetry](#telemetry)
83+
### --highlight-style
84+
hightlight.js style used for code blocks. Defaults to 'vs'. See https://github.com/highlightjs/highlight.js/tree/main/src/styles for a full list.
85+
### -m / --mermaid
86+
Convert mermaid diagrams to SVG. Will download latest chromium, if chrome-path is not defined.
87+
### --mermaidjs-path
88+
Path of the mermaid.js file. It'll be used if mermaid diagrams support is turned on (-m/--mermaid). If not specified, 'https://cdnjs.cloudflare.com/ajax/libs/mermaid/8.6.4/mermaid.min.js' will be downloaded.
11989
### --open
12090
Opens the PFD file after conversion. Great for development, not great in a build task.
121-
### --filter
122-
Filters the pages depending on the page [yaml tags](https://docs.microsoft.com/en-us/azure/devops/project/wiki/wiki-markdown-guidance?view=azure-devops#yaml-tags).
91+
### -o / --output
92+
The path to the export file including the filename, e.g. c:\export.pdf
93+
### --organization
94+
Azure Devops organization URL used to convert work item references to work item links. Ex: https://dev.azure.com/MyOrganizationName/
95+
### -p / --path
96+
Path to the wiki folder. If not provided, the current folder of the executable is used.
97+
If you only want to convert a subfolder and have images, then you must provide the path to the attachments folder with --attachments-path.
98+
### --pat
99+
Personal access token used to access your Azure Devops Organization. If no token is provided
100+
and organization and project parameters are provided, it will start a prompt asking you to login.
101+
### --pathToHeading
102+
Add path of the file to the header
103+
### -s / --single
104+
Path to a single markdown file to convert to PDF. If you want to write your changelog in the wiki, this is your parameter to only convert a single page.
105+
-p parameter is required, too.
106+
### -v / --verbose
107+
Verbose mode. Logging will added to the console window
123108

124109
## 😲 Limitations
125110

@@ -138,6 +123,17 @@ The tool uses Application Insights for basic telemetry:
138123
- In the case of an error, the exception is submitted.
139124
- No wiki data/content is submitted.
140125

126+
## FAQ
127+
128+
### Some pages are missing?
129+
Please check the .order files in your wiki if the pages are listed in there.
130+
131+
### The emoticons are missing in the PDF?
132+
Please check if you have page file that are encoded (e.g. Test%20dFiles.md)
133+
134+
### There is an error 'Qt: Could not initialize OLE (error 80010106)'.
135+
Yes, please ignore for now.
136+
141137
## ♥ Thanks
142138

143139
In this tool uses open source libraries that do the actual work - I just combined them to get the export as PDF:

release-version.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# dotnet tool install --global dotnet-warp
22

3-
$version = "3.2.0"
3+
$version = "3.3.0"
44
dotnet warp AzureDevOps.WikiPDFExport/azuredevops-export-wiki.csproj -p:Version=$version

test-run.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ foreach($wiki in $wikis)
1515
Write-Output "Running: $($wiki.FullName)"
1616

1717
#run the converter
18-
$output = dotnet run --project ".\AzureDevOps.WikiPDFExport\azuredevops-export-wiki.csproj" -- -p $wiki.FullName -o ".\tests\$($wiki.Name).pdf" --disableTelemetry --css ".\devopswikistyle.css"
18+
$output = dotnet run --project ".\AzureDevOps.WikiPDFExport\azuredevops-export-wiki.csproj" -- -p $wiki.FullName -o ".\tests\$($wiki.Name).pdf" --disableTelemetry
1919

2020
#extrac the time
2121
$export = $output | ? {$_ -match 'Export done in (\d+):(\d+):(\d+).(\d+)'}

0 commit comments

Comments
 (0)