Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed May 04, 2022 8:43 pm

I am generating a PDF, prior to 8.3.9 we were using 5.7.0 and never had this issue, we generate the PDF and save it and anyone can open it, now with this new version, when saving the PDF, when they try to open it in Adobe, it asks them for an Open to Read password, we are not setting one, it is not in code, and after reviewing the documentation, it said to clear the password use:

pdf.Security.UserPassword = string.empty;

but pdf.Security.UserPassword is read only, it has a getter but not a setter.

we are using a simple
pdf.LoadFromFile("filename.pdf");

and simple
pdf.SaveToFile("filename.pdf");

no where in code are we adding a needed password to open to read the document, we have the distributors license

additionally, you can actually open the PDF in Edge to read it just fine, it is Adobe that is requiring the open to read password

What is the fix for this?

JonathanWood
 
Posts: 26
Joined: Fri Feb 26, 2016 2:19 am

Thu May 05, 2022 8:16 am

Hi,

Thank you for your inquiry.
I simulated a PDF to test, but did not reproduce your problem. In theory, if your input document has no password and your code does not set one, it is impossible to add a password to the generated PDF. At present, the latest version of Spire.PDF is (Spire.PDF Pack(Hot Fix) Version:8.4.15), I suggest that you first give this version a try. If the issue still exists, please provide the following information for further investigation. You can attach your document here or send it to us via email (support@e-iceblue.com). Thank you in advance.
1) Your input and output PDF
2) Your full testing code and testing environment, such as Win10, 64bit
3) Application type, such as Console App, .NET Framework 4.8

Sincerely,
Kylie
E-iceblue support team
User avatar

kylie.tian
 
Posts: 412
Joined: Mon Mar 07, 2022 2:30 am

Fri May 06, 2022 1:16 pm

The Input PDF has a password that we do not have for making design changes using Adobe but there is no read password, I update form fields using Spire.PDF and I place a picture on the PDF and I save it, there is no password for reading on it to begin with and in 5.7.0 of Spire.PDF this process works flawlessly, but in the latest version that I have of Spire.PDF 8.3.9 after running the exact same code and saving the document, the resulting document contains a read only password that it didn't contain before and I never set in code. I will email support with the PDF in question, then what you will need to do to test, is to do a regular load of the PDF document, update a form field, attach a JPG image and simply save it, then try to open it in Adobe Acrobat DC. Additionally, even though Adobe wants the read password on the resulting PDF, you can open the PDF in Edge or Chrome and read it just fine.

Windows 10, 64 bit desktop
Windows Forms Application
.NET Framework 4.6 version of the library

Attached is a short snippet that should work for your purpose in testing the PDF I send.
Code: Select all
//Create a PdfDocument object
PdfDocument doc = new PdfDocument();
doc.LoadFromFile("testfile.pdf");
//Get form
PdfFormWidget formWidget = doc.Form as PdfFormWidget;
for (int i = 0; i < formWidget.FieldsWidget.List.Count; i++)
{
   PdfField field = formWidget.FieldsWidget.List[i] as PdfField;
   //Fill the data for textBoxField
   if (field is PdfTextBoxFieldWidget)
   {
      PdfTextBoxFieldWidget textBoxField = field as PdfTextBoxFieldWidget;
      listTextBoxNames.Add(textBoxField.Name);
      switch (textBoxField.Name)
      {
         case "AgencyCode": {
            textBoxField.Text = "TEST FIELD";
            } break;
                        default:
         {
            textBoxField.Text = textBoxField.Name;
         }
         break;
      }
   }
}

// need to now apply the image to the document, remove what you do not need, just place the image anywhere, doesn't matter for testing
PdfImage image = PdfImage.FromFile("yourimage.jpg");
// use for scaling if needed
float width = image.Width/5f;
float height = image.Height/5f;
float x = 40;
float y = 192;
PointF location = new PointF(x, y);
SizeF size = new SizeF(width, height);
PdfPageCollection pageinfo = doc.Pages;
PdfPageBase lastpage = doc.Pages[doc.Pages.Count-1];
lastpage.Canvas.DrawImage(image, location, size);
doc.SaveToFile("outputfile.pdf");



Hopefully the stripped down code works on your end, sending the source PDF over.

JonathanWood
 
Posts: 26
Joined: Fri Feb 26, 2016 2:19 am

Sat May 07, 2022 6:28 am

Hi,

Thank you for your reply.
Kindly note the latest version has been updated to Spire.PDF Pack(Hot Fix) Version:8.5.0. I did a test with your code and PDF document in our latest version, it worked fine without password. Please remove all old spire dlls from your project and download the latest one to try again. Please feel free to contact me if you have any questions.
Website downloads link: https://www.e-iceblue.com/Download/download-pdf-for-net-now.html
Nuget download link: https://www.nuget.org/packages/Spire.PDF/8.5.0

Sincerely,
Kylie
E-iceblue support team
User avatar

kylie.tian
 
Posts: 412
Joined: Mon Mar 07, 2022 2:30 am

Tue May 10, 2022 12:49 pm

Good morning, did you test it against the PDF I emailed support or a test PDF you have or generated.

JonathanWood
 
Posts: 26
Joined: Fri Feb 26, 2016 2:19 am

Wed May 11, 2022 6:47 am

Hi,

Yes, I tested the PDF document you emailed with the latest version 8.5.0, and it worked well without password. Do you test the latest version? It will be greatly appreciated if you can provide some feedback after testing.

Sincerely,
Kylie
E-iceblue support team
User avatar

kylie.tian
 
Posts: 412
Joined: Mon Mar 07, 2022 2:30 am

Wed May 11, 2022 7:35 pm

Downloaded and updated to 8.5.0 and this version doesn't have the problem 8.3.9 did on the PDF's with security.
Thanks, glad it was discovered and resolved along the line.

JonathanWood
 
Posts: 26
Joined: Fri Feb 26, 2016 2:19 am

Thu May 12, 2022 7:24 am

Hi,

Thanks for your confirmation.
If you need assistance in the future, please don't hesitate to contact us.
Wish you a nice day :D

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.PDF