Password entry error

Hi,
With Chrome, the system prompts you to enter the password when you want to view a PDF file. What can we do about this error?
I attached the original file and corrupted file. Thanks.
YG8884.zip (376.7 KB)

@srmbimser

Can you please share sample code snippet which you have used to generate faulty file.pdf. We will test the scenario in our environment and address it accordingly.

Hi,
The document is uploaded to the system. If you want to view the PDF document with Chrome, you will be prompted to “enter the password”. A similar error does not occur in Adobe Reader or MS Explorer.

@srmbimser

We were able to notice the dialog for password entry in chrome. However, we need sample code snippet in order to analyse the issue further and address it accordingly. Please share sample code snippet which you have used to create mentioned PDF file so that we can proceed to assist you further.

We call the FileShow method as follows,

API.Global.FileShow(this.UploadDirectory + fileName.Substring(0, fileName.LastIndexOf(’.’)) + “.pdf”, this.Response);

FileShow method,
public static void FileShow(string FilePath, HttpResponse Response)
{
FileStream fs = null;
try
{
if (Response == null) return;

            string FileName = FilePath.Substring(FilePath.LastIndexOf("/") + 1);
            string FileFormat = FileName.Substring(FileName.LastIndexOf(".") + 1);
            System.IO.FileInfo info = new System.IO.FileInfo(FilePath);
            FileName = info.Name;

            fs = new FileStream(FilePath, FileMode.Open);

            Byte[] buffer = new Byte[fs.Length];
            fs.Read(buffer, 0, (int)fs.Length);

            string disposition = "attachment";
            Response.Clear();
            Response.Buffer = false;
            Response.AppendHeader("Content-Type", string.Format("application/{0}", FileFormat));
            Response.AppendHeader("Content-Transfer-Encoding", "binary");
            Response.AppendHeader("Content-Disposition", string.Format("{0}; filename={1}", disposition, HttpUtility.UrlEncode(FileName).Replace("+", "%20")));
            Response.BinaryWrite(buffer);
            Response.End();
        }
        catch (Exception hata)
        {
            throw hata;
        }
        finally
        {
            if (fs != null) fs.Close();
        }
    }

@srmbimser

Thanks for sharing a sample code snippet.

The shared code snippet is for opening PDF file in Chrome or any browser using web application. We have checked properties of PDF document that you have shared earlier with us and noticed that it was generated using Aspose.PDF for .NET 19.1. We are requesting you to share the code snippet which you have used to generate it. Or may be you have converted it from any other document.

We have also checked original.pdf file which was from another source and found it fine while opening with Chrome. Please share the code snippet that has been used to convert original.pdf file into faulty file.pdf.

@asad.ali
private void ConverToPdf()
{
string path = this.UploadDirectory + txtFileName.Text;
var book = new Workbook(path);
//Worksheet sheet2 = book.Worksheets[0];
foreach (Worksheet sheet in book.Worksheets)
{
var maxDisplayRange = GetMaxDisplayRange(sheet);
var maxCol = sheet.Cells.MaxColumn;
var maxRow = sheet.Cells.MaxRow;
if (sheet.Cells.MaxDataColumn - 1 > sheet.Cells.MaxColumn)
maxCol = sheet.Cells.MaxDataColumn - 1;
if (sheet.Cells.MaxDataRow - 1 > sheet.Cells.MaxRow)
maxRow = sheet.Cells.MaxDataRow - 1;
if (maxDisplayRange.ColumnCount - 1 > maxCol)
maxCol = maxDisplayRange.ColumnCount - 1;
if (maxDisplayRange.RowCount - 1 > maxRow)
maxRow = maxDisplayRange.RowCount - 1;
if (maxCol > 0 && maxRow > 0)
{
Aspose.Cells.PageSetup pageSetup = sheet.PageSetup;
pageSetup.PrintArea = “A1:” + CellsHelper.CellIndexToName(maxRow, maxCol);
Console.WriteLine(pageSetup.PrintArea);
}
}

        book.Save(this.UploadDirectory + txtFileName.Text.Substring(0, txtFileName.Text.LastIndexOf('.')) + ".pdf");
        API.Global.FileShow(this.UploadDirectory + txtFileName.Text.Substring(0, txtFileName.Text.LastIndexOf('.')) + ".pdf", this.Response);
    }

@srmbimser

The shared code snippet is related to Aspose.Cells and it also involves an input file. Please share that input file as well.

public string SavePostedFile(UploadedFile uploadedFile)
{
string fileName = System.IO.Path.Combine(this.UploadDirectory, uploadedFile.FileName);
extension = uploadedFile.FileName.Substring(uploadedFile.FileName.LastIndexOf(’.’), uploadedFile.FileName.Length - uploadedFile.FileName.LastIndexOf(’.’));
if (extension == “.pdf”)
{
Aspose.Pdf.Document doc = new Aspose.Pdf.Document(uploadedFile.FileContent);
doc.Save(fileName);
}
return uploadedFile.FileName;
}

@srmbimser

Thanks for your cooperation.

We have tested the scenario in our environment using Aspose.PDF for .NET 19.6 and were unable to notice any issue. Please note that we have tested the scenario with one of our sample files where we converted a sample XLSX file into PDF using Aspose.Cells and re-save it as PDF using Aspose.PDF for .NET.

It seems like the issue is related to some other part of code snippet which you are using at your end. Would you kindly prepare a narrowed down sample console application with sample files in it and share it with us in ZIP format. It would really help us replicating the issue in our environment and address it accordingly. We really appreciate your cooperation in this matter.

The aspose version in the application, net4.0 aspose.pdf.19.6.
http://dm.bimser.com.tr/eba.net/Default.aspx?turl=5LfJaIP6U0qsaGGY5goEeQ

@srmbimser

Thanks for your cooperation and shared requested information.

We were able to replicate the issue in our environment. Therefore, for the sake of correction, we have logged it as PDFNET-46631 in our issue tracking system. We will look into details of the issue and keep you posted with the status of its resolution. Please be patient and spare us little time.

We are sorry for the inconvenience.

Hi, Is there an improvement on PDFNET-46631 issue?

@srmbimser

Regretfully, the earlier logged ticket is not yet resolved. We will surely review and resolve it after fixing issues logged prior to it as per the policy of normal support model and share updates with you within this forum thread. We highly appreciate your patience and comprehension in this regard. Please give us some time.

We apologize for the inconvenience.

Hi, Is there an improvement on PDFNET-46631 issue?

@srmbimser

We are afraid that the earlier logged ticket could not get resolved. However, we will surely let you know as soon as we have some definite updates about its resolution or fix ETA. Your patience and comprehension is highly appreciated in this matter. We apologize for the inconvenience.