Last active
July 5, 2021 10:58
-
-
Save conholdate-gists/5422784fe83368b8e4e4bba3e2d03c37 to your computer and use it in GitHub Desktop.
Render ZIP Archives using C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Render ZIP Archives using C# | |
1. Render ZIP Archives in HTML | |
2. Render Specific Folder from ZIP Archives in HTML | |
3. View Content of ZIP Archives in PDF | |
4. Render ZIP Archives to JPG | |
5. Get a List of Folders from ZIP archives |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// initialize viewer | |
Viewer viewer = new Viewer("C:\\Files\\sample.zip"); | |
// create view info options | |
ViewInfoOptions viewInfoOptions = ViewInfoOptions.ForHtmlView(); | |
ViewInfo viewInfo = viewer.GetViewInfo(viewInfoOptions); | |
Console.WriteLine("File type: " + viewInfo.FileType); | |
Console.WriteLine("Pages count: " + viewInfo.Pages.Count); | |
Console.WriteLine("Folders: "); | |
Console.WriteLine(" - /"); | |
string rootFolder = string.Empty; | |
viewInfoOptions.ArchiveOptions.Folder = rootFolder; | |
// get view info | |
ArchiveViewInfo viewFolderInfo = viewer.GetViewInfo(viewInfoOptions) as ArchiveViewInfo; | |
foreach (string subFolder in viewFolderInfo.Folders) | |
{ | |
Console.WriteLine($" - {subFolder}"); | |
PrintFolders(viewer, subFolder); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// initialize viewer | |
Viewer viewer = new Viewer("C:\\Files\\sample.zip"); | |
// define PDF view options | |
PdfViewOptions viewOptions = new PdfViewOptions("C:\\Files\\output.pdf"); | |
// set new file name | |
viewOptions.ArchiveOptions.FileName = new FileName("MyFiles"); | |
viewer.View(viewOptions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// initialize viewer | |
Viewer viewer = new Viewer("C:\\Files\\sample.zip"); | |
// define HTML view options | |
HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources("C:\\Files\\output.html"); | |
viewOptions.RenderToSinglePage = true; | |
// create view | |
viewer.View(viewOptions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// initialize viewer | |
Viewer viewer = new Viewer("C:\\Files\\sample.zip"); | |
// define JPG view options | |
JpgViewOptions options = new JpgViewOptions("C:\\Files\\output_page_{0}.jpg"); | |
// create view | |
viewer.View(viewOptions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// initialize viewer | |
Viewer viewer = new Viewer("C:\\Files\\sample.zip"); | |
// define PDF view options | |
PdfViewOptions options = new PdfViewOptions("C:\\Files\\output.pdf"); | |
// create view | |
viewer.View(viewOptions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// initialize viewer | |
Viewer viewer = new Viewer("C:\\Files\\sample.zip"); | |
// define HTML view options | |
HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources("C:\\Files\\output.html"); | |
// set folder name | |
viewOptions.ArchiveOptions.Folder = "ThirdFolderWithItems"; | |
// create view | |
viewer.View(viewOptions); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment