{"id":15478049,"url":"https://github.com/rickstrahl/westwind.htmlpackager","last_synced_at":"2025-04-22T14:24:24.190Z","repository":{"id":46755049,"uuid":"146330325","full_name":"RickStrahl/Westwind.HtmlPackager","owner":"RickStrahl","description":"A small utility class used to package HTML content into a self contained HTML document both as a single file, or a folder with all dependencies copied to local.","archived":false,"fork":false,"pushed_at":"2024-03-25T20:35:51.000Z","size":1213,"stargazers_count":32,"open_issues_count":4,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-02T06:18:03.818Z","etag":null,"topics":["csharp","dotnet","dotnet-core","html","mit","package"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RickStrahl.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-27T17:20:42.000Z","updated_at":"2024-05-02T06:18:03.819Z","dependencies_parsed_at":"2024-03-25T21:50:51.715Z","dependency_job_id":null,"html_url":"https://github.com/RickStrahl/Westwind.HtmlPackager","commit_stats":{"total_commits":35,"total_committers":1,"mean_commits":35.0,"dds":0.0,"last_synced_commit":"5f8b0c67dad13994663bec22e300880a9a6deefd"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RickStrahl%2FWestwind.HtmlPackager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RickStrahl%2FWestwind.HtmlPackager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RickStrahl%2FWestwind.HtmlPackager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RickStrahl%2FWestwind.HtmlPackager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RickStrahl","download_url":"https://codeload.github.com/RickStrahl/Westwind.HtmlPackager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250256808,"owners_count":21400593,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","dotnet","dotnet-core","html","mit","package"],"created_at":"2024-10-02T04:01:50.126Z","updated_at":"2025-04-22T14:24:24.165Z","avatar_url":"https://github.com/RickStrahl.png","language":"C#","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=DJJHMXWYPT3E2"],"categories":[],"sub_categories":[],"readme":"# Westwind.HtmlPackager\n\n\u003cimg src=\"HtmlPackagerIcon.png\" /\u003e\n\nHtmlPackager is a tiny standalone Windows Exe or .NET component that allows you to package content from a URL as a self-contained, local HTML file or package of files that can be saved and viewed offline.\n\nThe packager can create:\n\n* **A single, large self-contained HTML File**\n* **An HTML file with external, local assets**\n* **A Zip package of the latter file and folder assets**\n\nThis library is provided as a **.NET Library**, a small Windows **.NET 4.5 Cosole executable** and a cross-platform  **.NET SDK Tool**:\n\n* [Chocolatey](https://chocolatey.org/packages/HtmlPackager) \n* [NuGet](https://www.nuget.org/packages/Westwind.HtmlPackager) \n* [NuGet .NET SDK Tool](https://www.nuget.org/packages/dotnet-htmlpackager) \n\nThe packager works with:\n\n* Web Urls\n* Local HTML Files\n\nThere are three packaging modes:\n\n* **Package to a single file**  \nAll related resources are downloaded and embedded into the HTML content. CSS is embedded as text while images, scripts and url resources are embedded as base64 data links. The result is one very large HTML document that contains all resources embedded. \n\n* **HTML file plus loose Resource Files**  \nProduces an HTML file plus all CSS, Script, images, fonts as loose files stored in the same folder as the HTML. An option also allows packaging the folder as a Zip file.\n\n* **Zip File with loose Resource Files**  \nSimilar to loose resource files, but all files are packaged into a single self-contained zip file to shrink the size of the output.\n\n## .NET Library\nThe .NET library allows embedding of the packaging functionality into your own applications. It is very small and self-contained and can be easily added to another project with two source files, or you can use [NuGet](https://www.nuget.org/packages/Westwind.HtmlPackager) to include the binaries. The library has an external dependency on [HtmlAgilityPack](http://html-agility-pack.net) for HTML parsing.\n\nSupported .NET Targets:\n\n* .NET 4.5+\n* .NET Standard 2.0\n\n## Standalone Command Line Tools\nThere are a also a small Windows **.NET 4.5 Cosole executable** and as a cross-platform  **.NET SDK Tool** that allow you to run this tool from the command line.\n\n### HtmlPackager Windows Console Application\nThe HTML Packager is available as a self contained Windows Console application (ILMerged single file EXE) in `HtmlPackager.exe` which [you can download and copy as needed](https://github.com/RickStrahl/Westwind.HtmlPackager/blob/master/HtmlPackager.exe).\n\nAlternately you can also use the [Chocolatey](https://chocolatey.org/packages/HtmlPackager) package:\n\n```\nchoco install HtmlPackager\n```\n\n### Cross Platform .NET SDK Global Tool\nYou can also install the cross-platform the `dotnet-htmlpackager` Nuget package that installs as a .NET SDK Global tool that can be globally  executed as `htmlpackager` once installed on Windows, Mac and Linux as long as you have the [.NET SDK 2.1 or later installed](https://www.microsoft.com/net/download/dotnet-core/2.1).\n\nTo install the tool:\n\n```\ndotnet tool install -g dotnet-htmlpackager\n```\n\nTo uninstall\n\n```\ndotnet tool uninstall -g dotnet-htmlpackager\n```\n\n### Command Line Options\nThe tool allows for a number of command line options to determine how output is returned from a URL.\n\n```txt\nSyntax:\n-------\nHtmlPackager \u003csourceUrl\u003e -o \u003coutputFile\u003e [-x|-z] -d\n\nCommands:\n---------\nHELP || /?          This help display           \n\nOptions:\n--------\nsourceUrl           Source Url or local file to an HTML document\n-o \u003coutputFile\u003e     Output HTML file or Zip file (-z)\n                    (if output file is not provided output is sent to StdOut)                                       \n-x                  Create external dependencies in folder of HTML document\n-z                  Create zip file with all dependencies included in zip\n-d                  Display generated HTML page or Zip file\n```\n\n### Examples\nThe following are a few examples you can try to capture output.\n\nCreate a single self-contained HTML document from a URL and display in your browser:\n\n```\nHtmlPackager  https://markdownmonster.west-wind.com  -o c:\\temp\\mm-output.html -d\n```\n\nCreate an HTML file from a URL with all dependencies stored as loose files in the output file's folder (`-x`) and display in your browser (`-d`):\n\n```\nHtmlPackager  https://weblog.west-wind.com -o c:\\temp\\west-wind.html -x -d\n```\n\nCreate a self-contained HTML file from a local HTML file:\n\n```\nHtmlPackager  %userprofile%\\Documents\\myapp\\somePage.html -o %TEMP%\\app_saved.html\n```\n\nNote that environment variables in paths are autoexpanded - use whatever syntax is appropriate for your OS.\n\n\nPackage to a Zip file:\n\n```\nHtmlPackager  https://github.com -o c:\\temp\\github-home.zip -z -d\n```\n\n## .NET Library and C# Source Code\nThe packager is also avalailable as a NuGet package you can add to your project.\n\n### Installation via NuGet\nYou can install this library from [NuGet](https://www.nuget.org/packages/Westwind.HtmlPackager):\n\n```\ninstall-package Westwind.HtmlPackager\n```\n\nor \n\n```\ndotnet add package Westwind.HtmlPackager\n```\n\n### Usage\nThe following are various usage examples for packaging HTML from files or Web URLs into the two package formats.\n\n#### Capture HTML File to embedded HTML as String\nThe following captures the HTML to a single file string from a local file on disk:\n\n```cs\nvar inputFile = Path.Combine(Path.GetTempPath(), \"_MarkdownMonster_Preview.html\");\nvar packager = new HtmlPackager();\nstring packaged = packager.PackageHtml(inputFile);\n\nstring outputFile = InputFile.Replace(\".html\", \"_PACKAGED.html\");\n\nFile.WriteAllText(outputFile, packaged);\n\nConsole.WriteLine(packaged);\n```\n\n#### Capture HTML File to embedded HTML as File\n\n```cs\nvar inputFile = Path.Combine(Path.GetTempPath(), \"_MarkdownMonster_Preview.html\");\nstring outputFile = InputFile.Replace(\".html\", \"_PACKAGED.html\");\n\nvar packager = new HtmlPackager();\nstring packaged = packager.PackageHtmlToFile(inputFile,outputFile);\n\n\n// display html in browser\nUtils.GoUrl(outputFile);\n```\n\n#### Capture Web Url to single File\n```cs\nvar packager = new HtmlPackager();\nstring packaged = packager.PackageHtml(\"https://west-wind.com\");\n\nstring outputFile = InputFile.Replace(\".html\", \"_PACKAGED.html\");\nFile.WriteAllText(outputFile, packaged);\n\nShellUtils.GoUrl(outputFile);\n```\n\n#### Capture File to HTML File + Loose Resources\n\n```cs\nvar packager = new HtmlPackager();\nstring outputFile = @\"c:\\temp\\GeneratedHtml\\Output.html\";\nbool result = packager.PackageHtmlToFolder(@\"c:\\temp\\tmpFiles\\_MarkdownMonster_Preview.html\", outputFile,\n    null, true);\nAssert.IsTrue(result);\n\n// Display html in browser\nUtils.GoUrl(outputFile);\n```\n\n#### Capture Web Url to HTML File + Loose Resources\n\n```cs\nvar packager = new HtmlPackager();\nstring outputFile = @\"c:\\temp\\GeneratedHtml\\Output.html\";\nbool result = packager.PackageHtmlToFolder(\"http://west-wind.com/\", outputFile, null, true);\n\nShellUtils.GoUrl(outputFile);\n```\n\n## License\nThe Westwind.HtmlPackager library is license  under the [MIT License](https://opensource.org/licenses/MIT) and there's no charge to use, integrate or modify the code for this project. You are free to use it in personal, commercial, government and any other type of application.\n\nAll source code is copyright West Wind Technologies, regardless of changes made to them. Any source code modifications must leave the original copyright code headers intact.\n\n\u003e It's free as in free beer, but if this saved you some time and you're overflowing with gratitude you can buy me a beer:\n\u003e\n\u003e [Make a Donation with PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=DJJHMXWYPT3E2)\n\n## Warranty Disclaimer: No Warranty!\nIN NO EVENT SHALL THE AUTHOR, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THIS PROGRAM AND DOCUMENTATION, BE LIABLE FOR ANY COMMERCIAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM INCLUDING, BUT NOT LIMITED TO, LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR LOSSES SUSTAINED BY THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS, EVEN IF YOU OR OTHER PARTIES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frickstrahl%2Fwestwind.htmlpackager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frickstrahl%2Fwestwind.htmlpackager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frickstrahl%2Fwestwind.htmlpackager/lists"}