PDFsharp & MigraDoc Forum https://forum.pdfsharp.net/ |
|
Add password https://forum.pdfsharp.net/viewtopic.php?f=2&t=4868 |
Page 1 of 1 |
Author: | slperin [ Fri Aug 15, 2025 1:01 am ] |
Post subject: | Add password |
Hi, i'm trying to set a password in a PDF document but the PdfReader method raise an exception: The file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=8.0.0.2, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies could not be loaded. The system cannot find the file specified. My program is in VB.Net FrameWork 4.8.1 PdfSharp loaded from Nuget (PdfSharp-GDI 6.2.1) Imports PdfSharp.Pdf Imports PdfSharp.Pdf.IO Public Sub AddPassword(ByVal FileName As String, ByVal Password As String) Try Dim Document As PdfDocument = PdfReader.Open(FileName, PdfDocumentOpenMode.Modify) Dim SecuritySettings As Security.PdfSecuritySettings = Document.SecuritySettings SecuritySettings.UserPassword = Password SecuritySettings.OwnerPassword = Password SecuritySettings.PermitAnnotations = False SecuritySettings.PermitAssembleDocument = False SecuritySettings.PermitExtractContent = False SecuritySettings.PermitFormsFill = False SecuritySettings.PermitFullQualityPrint = True SecuritySettings.PermitModifyDocument = False SecuritySettings.PermitPrint = True Document.SecurityHandler.SetEncryptionToV2With128Bits() Document.Save(FileName) Catch Ex As Exception LoadErrors(Ex.Message) End Try End Sub |
Author: | !!! [ Fri Aug 15, 2025 1:19 pm ] |
Post subject: | Re: Add password |
The file "'Microsoft.Extensions.Logging.Abstractions.dll" should be in the same folder where PdfSharp-gdi.dll is. |
Author: | slperin [ Sat Aug 16, 2025 3:06 pm ] |
Post subject: | Re: Add password |
Both DLLs are in the same folder. More info: EXE & DLL in VS2022. The code showed below is part of a DLL that made a PDF file. The DLL is a component library in .Net FW 4.8.1. The PdfSharp is used to protect that file with a password. The DLL is used in a WinForms .Net FW 4.8.1 proyect. |
Author: | () => true [ Sun Aug 17, 2025 4:34 pm ] |
Post subject: | Add password |
Cannot reproduce with the information you provide. Please use the IssueSubmissionTemplate to make it replicable. https://docs.pdfsharp.net/General/Issue ... About.html |
Author: | slperin [ Tue Aug 19, 2025 4:47 pm ] |
Post subject: | Re: Add password |
Hi. For some reason, the DLL doesn't copy all the referencies to the EXE proyect. The DLL has the property 'Local Copy = True'. Only happens when the PDFSharp is referenced in a DLL. To solve the problem, i copied the PDFSharp-GDI, via NuGet, to the EXE proyect. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |