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.

Mon Oct 16, 2017 6:02 am

Dear jperkinsSC,

Thanks for your feedback.
I used the hotfix to loaded the PDF(AMS - GA - Retail Installment Contract_Arbitration.pdf), and inserted the image then saved. Then reloaded the file and inserted the image into the field "Borrower_CreditInsurance_ESignatureArea", everything worked well on my side. I attached my result document via email. Also, I just loaded the file(AMS - GA - Retail Installment Contract_Arbitration_BuyerInitials.pdf) and inserted image, it also worked fine.
Here is my testing code.
Code: Select all
            PdfDocument doc = new PdfDocument();
            doc.LoadFromFile(@"AMS - GA - Retail Installment Contract_Arbitration 2.pdf");

            PdfImage image1 = PdfImage.FromFile(@"F:\image\flower2.jpg");
            doc.Pages[0].Canvas.DrawImage(image1, 497,753,27,18);
            MemoryStream stream = new MemoryStream();
            doc.SaveToStream(stream);

            PdfDocument Rdoc = new PdfDocument(stream);
            PdfFormWidget formWidget = Rdoc.Form as PdfFormWidget;
            for (int i = 0; i < formWidget.FieldsWidget.List.Count; i++)
            {
                PdfField field = formWidget.FieldsWidget.List[i] as PdfField;
                if (field is PdfTextBoxFieldWidget)
                {
                    PdfTextBoxFieldWidget textBoxField = field as PdfTextBoxFieldWidget;
                    if (textBoxField.Name == "Borrower_CreditInsurance_ESignatureArea")
                    {
                        PointF point = textBoxField.Location;
                        System.Drawing.Rectangle rect = new System.Drawing.Rectangle((int)point.X, (int)point.Y, (int)textBoxField.Size.Width, (int)textBoxField.Size.Height);
                        PdfImage image = PdfImage.FromFile(@"F:\image\flower2.jpg");
                        Rdoc.Pages[0].Canvas.DrawImage(image, rect);
                    }
                }
            }
            Rdoc.SaveToFile("11685.pdf");

What is your complete code ? Could you please send the code and the related image for testing.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Tue Oct 17, 2017 1:18 am

Betsy

Here is the sample code we are using

Code: Select all
 
private void button1_Click(object sender, RoutedEventArgs e)
        {

            using (var pdfDocument = new PdfDocument(File.ReadAllBytes("AMS - GA - Retail Installment Contract_Arbitration.pdf")))
            {
                var imagePath = "BuyerInitials.png";
                PdfImage pdfImageInit = PdfImage.FromFile(imagePath);
                System.Drawing.RectangleF location = new System.Drawing.Rectangle(497, 753, 27, 18);
                AddSignatureToPdf(pdfDocument, location, pdfImageInit);
                pdfDocument.SaveToFile("first.pdf");

                var imagePath2 = "BuyerSignature.png";
                PdfImage pdfImageInit2 = PdfImage.FromFile(imagePath2);
                System.Drawing.RectangleF location2= new System.Drawing.Rectangle(497, 553, 27, 18);
                AddSignatureToPdf(pdfDocument, location2, pdfImageInit2);

                pdfDocument.SaveToFile("second.pdf");
               
            }

        }

  private void AddSignatureToPdf(PdfDocument pdfDocument, System.Drawing.RectangleF rect, PdfImage pdfImage)
        {
           
            PdfPageBase page0 = pdfDocument.Pages[0];

            if (pdfImage.Width > 0 && pdfImage.Height > 0)
            {
                float imageAspectRatio = (float)pdfImage.Width / (float)pdfImage.Height;
                float newWidth = imageAspectRatio * rect.Height;
                if (newWidth <= rect.Width)
                {
                    // Adjust the width of the rect (ie, try to make the image fill the box height and let it be as wide as it comes out)
                    float delta = rect.Width - newWidth;
                    rect.X += delta / 2f;
                    rect.Width = newWidth;
                }
                else
                {
                    // Adjust the height of the rect
                    imageAspectRatio = (float)pdfImage.Height / (float)pdfImage.Width;
                    float newHeight = imageAspectRatio * rect.Width;
                    float delta = rect.Height - newHeight;
                    rect.Y += delta;
                    rect.Height = newHeight;
                }
            }

            page0.Canvas.DrawImage(pdfImage, rect);

         
        }





I have send you the images we are using via email, also attached the old spire dll where this code is working without error.

Regards

jperkinsSC
 
Posts: 93
Joined: Thu Oct 30, 2014 10:01 pm

Tue Oct 17, 2017 3:10 am

Dear jperkinsSC,

Thanks for your code.
I have reproduced the issue and posted it to our Dev team. Once there is any progress, we will let you know.
In addition, there is a solution for you, I suggest you use it firstly.
Code: Select all
                …
                var imagePath = @"F:\testing\pdf form testing\original document\BuyerInitials.png";
                PdfImage pdfImageInit = PdfImage.FromFile(imagePath);
                System.Drawing.RectangleF location = new System.Drawing.Rectangle(497, 753, 27, 18);
                AddSignatureToPdf(pdfDocument, location, pdfImageInit);
                pdfDocument.SaveToFile("first.pdf");
                //reload the PDF, then insert the second image.
                var  pdfnew= new PdfDocument("first.pdf");
                var imagePath2 = @"F:\testing\pdf form testing\original document\BuyerSignature.png";
                PdfImage pdfImageInit2 = PdfImage.FromFile(imagePath2);
                System.Drawing.RectangleF location2 = new System.Drawing.Rectangle(497, 553, 27, 18);
                AddSignatureToPdf(pdfnew, location2, pdfImageInit2);
                //save the second PDF.
                pdfnew.SaveToFile("second.pdf");
                …


Best wishes,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Wed Oct 18, 2017 1:14 am

Besty

Thanks for your response , Actually the way our code is structured its almost impossible for us to reload the pdf again,

we would really appreciate a fix for that.


Regards

jperkinsSC
 
Posts: 93
Joined: Thu Oct 30, 2014 10:01 pm

Wed Oct 18, 2017 1:20 am

Dear jperkinsSC,

Thanks for your feedback.
Once the issue is fixed, we will let you know immediately.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Wed Oct 18, 2017 10:59 pm

Thank you - Please keep us posted and let us know if there is any ETA, so that we can provide it to our customers.

jperkinsSC
 
Posts: 93
Joined: Thu Oct 30, 2014 10:01 pm

Mon Oct 23, 2017 2:59 am

Hello, please provide an update. We have not heard word since Wednesday of last week.
Thank you

jperkinsSC
 
Posts: 93
Joined: Thu Oct 30, 2014 10:01 pm

Mon Oct 23, 2017 3:27 am

Dear jperkinsSC,

I just got information from our Dev team that the issue has been resolved, it is under test phase. We will let you know as soon as the hotfix is available.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Mon Oct 23, 2017 11:39 pm

Thank you Betsy, great news.

jperkinsSC
 
Posts: 93
Joined: Thu Oct 30, 2014 10:01 pm

Wed Oct 25, 2017 2:35 pm

Hi Betsy. Sorry to be a pest but we are really hurting for time to get our release out. Can you please provide an update on testing or hopefully the hotfix itself?

jperkinsSC
 
Posts: 93
Joined: Thu Oct 30, 2014 10:01 pm

Thu Oct 26, 2017 6:54 am

Hi jperkinsSC,

Here is a hotfix for you.
http://www.e-iceblue.com/downloads/hot_ ... .9.421.zip
If there is any question, welcome to back to us.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Thu Oct 26, 2017 3:28 pm

Thank you very, very much. We will get it implemented.

jperkinsSC
 
Posts: 93
Joined: Thu Oct 30, 2014 10:01 pm

Fri Oct 27, 2017 1:33 am

Besty

The issue is not getting resolve properly , The original issue we had was missing data in fields when converting to image, now we have problem when splitting the pages it gives error on page 2 of the documents , and I have just rechecked it is also not show the data again which was fixed in the previous build,

I have send the document we are using via email , and is also available at
https://secureclose.azurewebsites.net/AMS - GA - RIC.rar

Here is the code we are using

Code: Select all
 private void button2_Click(object sender, RoutedEventArgs e)
        {
            var DocumentPath = @"AMS - GA - Retail Installment Contract_Arbitration.pdf";
            PdfDocument doc = new PdfDocument();

            doc.LoadFromFile(DocumentPath);

            string pattern = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(DocumentPath), System.IO.Path.GetFileNameWithoutExtension(DocumentPath) + "_{0}.pdf");

            doc.Split(pattern, 1);
        }


the above code is used for splitting the document into single pages , It is giving us error on page 2. (Note: we have checked in the previous versions this code was working fine the issue is in the last two builds 3.9.393 and 3.9.421)

Code: Select all
 private void button3_Click(object sender, RoutedEventArgs e)
        {
            var DocumentPath = @"AMS - GA - Retail Installment Contract_Arbitration_1.pdf";
            PdfDocument doc = new PdfDocument();
            doc.LoadFromFile(DocumentPath);
            SaveImage(doc.SaveAsImage(0, 192D, 192D), DocumentPath + 1 + "_grf");
           
        }

        private void SaveImage(BitmapSource image, string targetPath)
        {


            var encoder = new PngBitmapEncoder();
            encoder.Frames.Add(BitmapFrame.Create(image));
            using (var filestream = new FileStream(targetPath, FileMode.Create))
            {
                try
                {
                    encoder.Save(filestream);
                }
                catch (Exception e)
                {

                }
            }
        }


the above code is used to convert the page 1 of the documents into image and the data in amount financed field is missing again which was fixed in the previous build.

We are really getting out of time with our client here, so a very quick fix will be required ideally by day end today so we can test and deliver to client over the weekend.

Regards

jperkinsSC
 
Posts: 93
Joined: Thu Oct 30, 2014 10:01 pm

Fri Oct 27, 2017 2:28 am

Hi Mubasher,

So sorry that there are still issues. I have posted the issues to our Dev team, and given them the highest priority. We will let you know when the hotfix is available. We apologize for the inconvenience caused.

Best wishes,
Betsy
E-iceblue Support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Mon Oct 30, 2017 3:23 am

Hello. Any update?

jperkinsSC
 
Posts: 93
Joined: Thu Oct 30, 2014 10:01 pm

Return to Spire.PDF