Due to security requirements, how to remove download and print buttons from the PDF document toolbar when using Aspose.Word.dll convert a document to a PDF format?
how to remove download and print buttons in toolbar in pdf document: ReplaceTextAll.pdf (135.5 KB)
Thanks for your reply
I tried the code but did not achieve the expected goal (Aspose. Words.dll v23.7.0)
When file was saved locally, it can hide download permission, it works but i need output to browser
When to output the file stream to the client’s browser, and there are still download and print buttons on the browser. It seems that this is the built-in button of the browser. May I ask if it is possible to hide the buttons
[HttpGet]
public async Task<IActionResult> Doc2()
{
try
{
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Write("Hello, World!");
using (var ms = new MemoryStream())
{
var saveOptions = new Aspose.Words.Saving.PdfSaveOptions();
Aspose.Words.Saving.PdfEncryptionDetails encryptionDetails = new Aspose.Words.Saving.PdfEncryptionDetails(string.Empty, "ownerpass");
encryptionDetails.Permissions = PdfPermissions.DisallowAll;
saveOptions.EncryptionDetails = encryptionDetails;
// Save To Local
doc.Save(@"C:\Temp\out.pdf", saveOptions);
// Output to browser
doc.Save(ms, saveOptions);
string contentType = "application/pdf";
ms.Position = 0;
return File(ms.ToArray(), contentType);
}
}
catch (Exception ex)
{
throw;
}
}
@davidxiao2008 Encryption details are stored in the document itself, how they are interpreted by the consumer application is out of Aspose.Words scope. I am afraid, there is no way to control how browser open PDF document and what buttons are shown using Aspose.Words.
What we plan to do is to create an online preview website for files. Is there any other solution (Aspose. Word or other family) to meet this requirement (without displaying the print button or preview button), provided that it is saved as a PDF stream
@davidxiao2008 You can consider using HtmlFixed format for viewing document on web page. This is an HTML based format designed exactly for viewing purposes:
hi alexey,
Saving files in PDF format for online file preview web sit can improve user experience, and we hope to use PDF format for presentation.
Can I remove these buttons when converting aspose. Word to PDF by adding css style or JavaScript ?