Text replace issue overwrite & print locked

When I replace the text the text overlaps other text when the string is the long.
Generated print cannot be printed. how can I unlock it.
ATT00002.gif (26.6 KB)
ATT00001.gif (292.8 KB)


You can set security privileges of the PDF document with DocumentPrivilege class. Please refer to this help topic: Set Privileges on an Existing PDF File. In reference to the replacement of text, please send us your source PDF and code. We will investigate your scenario in our environment, and share our findings with you.

string mydir = source + @"";
string[] myfiles = Directory.GetFiles(mydir + “”).Select(Path.GetFileName).ToArray();
foreach (var i in myfiles)
if (i.Contains(“HSBC”))
string sub = "HSBC SA “+i.Split(’ ‘, ‘.’)[2] ;
string sub1 = i.Split(’ ‘, ‘.’)[2];
//dot was added
//string sub = str.Substring(8, 6);
//string sub1 = rowString.Substring(0, 3);
//string sub = rowString.Replace(’”’, ’ ').Trim();
if (sub.Contains(“DPM”))
Document pdfDocument = new Document(mydir + i);
//create TextAbsorber object to find all instances of the input search phrase
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(sub);
//accept the absorber for all the pages

                    SqlCommand com1 = new SqlCommand("spGetMaster", con);
                    com1.CommandType = CommandType.StoredProcedure;
                    com1.Parameters.Add("@masked", SqlDbType.VarChar).Value = sub1;
                    SqlDataReader reader = com1.ExecuteReader();
                    if (reader.HasRows)
                        //update text and other properties
                        CustName = reader["de_masked"].ToString();
                        //get the extracted text fragments
                        TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
                        //loop through the fragments             
                        foreach (TextFragment textFragment in textFragmentCollection)
                            //string str = "select de_masked from master where Masked='" + sub.ToString() + "'";
                            SqlCommand com = new SqlCommand("spGetMaster", con);
                            com.CommandType = CommandType.StoredProcedure;
                            com.Parameters.Add("@masked", SqlDbType.VarChar).Value = sub1;
                            SqlDataReader reader1 = com.ExecuteReader();
                            //update text and other properties
                            string CustName1 = reader1["de_masked"].ToString();
                            textFragment.Text = CustName1;
                        //setting password to pdf
                        SqlCommand cmd1 = new SqlCommand("spGetMaster", con);
                        cmd1.CommandType = CommandType.StoredProcedure;
                        cmd1.Parameters.Add("masked", SqlDbType.VarChar).Value = sub1;
                        SqlDataReader rd = cmd1.ExecuteReader();
                        string pass = rd["pdfpassword"].ToString();
                        custEmail = rd["Email"].ToString();
                        ccemail = rd["ccemail"].ToString();
                        pdfDocument.Encrypt(pass, "", 0, CryptoAlgorithm.RC4x128);
                        newfilename = i + ".pdf";
                        pdfDocument.Save(destination + @"\" + newfilename);

HSBC SA DPM156 Standard Valuation Pack 31 Mar 2017 (English).PDF (233.5 KB)


You are retrieving data from the database, please send us the code with real strings which are being retrieved from the database. Your response is awaited.


We have replaced HSBC SA DPM156 with Resemble Systems, and there is no overlapping of the text. This is the output PDF: Output18.5.pdf (294.3 KB)

Can you please try with longer name like ‘Resemble systems India private Limited’


We managed to replicate the problem of text overlapping in our environment on page number 3. It has been logged under the ticket ID PDFNET-44738 in our bug tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates.

What is the update on the issue ? We need this is to be fixed as soon as possible.


Thank you for getting back to us.

The issue reported by you is pending for investigations owing to previously logged tickets. It will be scheduled on its due turn that can take a few more months. We really appreciate your patience and comprehension in this regard.

However, we also offer Paid Support, where issues are used to be investigated with higher priority. Our customers, who have paid support subscription, report their issue there which are meant to be investigated urgently. In case your reported issue is a blocker, you may please consider subscribing for Paid Support. For further information, please visit Paid Support FAQs.