Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Last active January 28, 2023 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GroupDocsGists/ab364dcdad8e9b4badfa0bd14484c8d5 to your computer and use it in GitHub Desktop.
Save GroupDocsGists/ab364dcdad8e9b4badfa0bd14484c8d5 to your computer and use it in GitHub Desktop.
View Word Documents as PDF using C#
// How to view Word Documents as PDF using C#
using GroupDocs.Viewer.Options;
...
using (Viewer viewer = new Viewer("path/document.docx"))
{
PdfViewOptions options = new PdfViewOptions("path/Word-Document.pdf");
viewer.View(options);
}
// How to view Word Documents as Protected PDF using C#
using GroupDocs.Viewer.Options;
...
using (Viewer viewer = new Viewer("path/document.docx"))
{
Security security = new Security
{
DocumentOpenPassword = "opening-pass",
PermissionsPassword = "permission-pass",
Permissions = Permissions.AllowAll ^ Permissions.DenyPrinting
};
PdfViewOptions options = new PdfViewOptions("path/Word-Document.pdf")
{
Security = security
};
viewer.View(options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment