参考如下链接文章:
https://sunpma.com/137.html
保存一个免费SSL网站:https://freessl.cn/
https://freessl.cn/
可以申请trustAsia一年期的免费ssl,实用。
C# .NET 给PDF文件加密设定密码并设置权限
NUGET管理器中引用“pdfsharp”,然后参考如下代码。
// Open an existing document. Providing an unrequired password is ignored. PdfSharp.Pdf.PdfDocument document = PdfReader.Open(pdfFilePath); PdfSecuritySettings securitySettings = document.SecuritySettings; // Setting one of the passwords automatically sets the security level to // PdfDocumentSecurityLevel.Encrypted128Bit. //securitySettings.UserPassword = "user"; securitySettings.OwnerPassword = JinXinConnGuid.ToString(); // Don't use 40 bit encryption unless needed for compatibility reasons //securitySettings.DocumentSecurityLevel = PdfDocumentSecurityLevel.Encrypted40Bit; // Restrict some rights. securitySettings.PermitAccessibilityExtractContent = false; securitySettings.PermitAnnotations = false; securitySettings.PermitAssembleDocument = false; securitySettings.PermitExtractContent = false; securitySettings.PermitFormsFill = false; securitySettings.PermitFullQualityPrint = false; securitySettings.PermitModifyDocument = false; securitySettings.PermitPrint = true; // Save the document... document.Save(pdfFilePath);
参考网站:https://stackoverflow.com/questions/12383409/password-protecting-a-pdf-file
网页打印使用css去掉页眉页脚
加一个style标签,里面设置@page的上下边框为0mm左右为auto,这里就是设置纸张的上下边距为0mm,代码如下:
<style> @page { size: auto; /* auto is the initial value */ margin: 0mm auto 0mm auto; /* this affects the margin in the printer settings */ } </style>
部分语言直接写@page会报错,需要写成“@@page”
class=”noprint” 在Chrome打印不起作用
需要额外写一个style标签,如下:
<style media=print type="text/css"> .noprint { visibility: hidden; } </style>
再使用class=”noprint”即可生效。
<button onclick="print_page()" class="noprint">打印</button>