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 Nov 25, 2019 2:09 pm

I hava a pdf with formfields. I set the Text of this fields.

After that I want to add a transparent Image OVER that field:

Dim pf = PdfImage.FromFile("c:\sign.png")
docpages(0).Canvas.DrawImage(pf, 350, 620, 100, 50)

But the Image is behind that field, not in front.

What can I do?

UweGabbert
 
Posts: 10
Joined: Mon Mar 05, 2018 9:25 am

Tue Nov 26, 2019 1:52 am

Hi,

Thanks for your inquiry.
To help us investigate accurately, please provide following information.
1. Input PDF file
2. Your image file
3. The output you got
4. The full code you were using
5. The desired PDF you want

Sincerely,
Betsy
E-iceblue support team
User avatar

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

Tue Nov 26, 2019 6:38 am

Code: Select all
        Dim pdfDoc As New Spire.Pdf.PdfDocument(PdfConformanceLevel.None)
        pdfDoc.LoadFromFile("c:\_deploy\A_5.1-4.pdf")

' Fill the Form
        Dim formWidget As PdfFormWidget = pdfDoc.Form
        For i = 0 To formWidget.FieldsWidget.List.Count - 1
            Dim field As PdfField = TryCast(formWidget.FieldsWidget.List(i), PdfField)
            If TypeOf field Is PdfTextBoxFieldWidget Then
                Dim textBoxField As PdfTextBoxFieldWidget = TryCast(field, PdfTextBoxFieldWidget)
                Select Case textBoxField.Name
                    Case "Innung"
                        textBoxField.Text = $"innung"
                    Case "Vor und Nachname"
                        textBoxField.Text = $"Gabbert, Uwe"
                    Case "Systemverantwortlicher Leiter Region"
                        textBoxField.Text = $"SLR Uwe Gabbert"
                End Select
            End If
            field.Flatten = True
            field.ReadOnly = True
        Next

' Add Graphics. Dont Work

        Dim seiten = pdfDoc.Pages
        Dim pf = PdfImage.FromFile("c:\_deploy\uwe.png")
        seiten(0).Canvas.DrawImage(pf, 300, 600, 150, 75)

' Save and Show
        Dim dt = $"c:\_deploy\A5.1-4_{Guid.NewGuid.ToString}.pdf"
        pdfDoc.SaveToFile(dt, FileFormat.PDF)
        Process.Start(dt)


I see the Sign (uwe.png) behind the Formfield. But I want to see this in Front of the document.

UweGabbert
 
Posts: 10
Joined: Mon Mar 05, 2018 9:25 am

Tue Nov 26, 2019 8:55 am

Hi,

Thanks for your information.
After checking your file, I found the textbox in your PDF had set fill color. Even using Adobe to add image, the image will be also covered by the textbox. After further investigation, I think "Fill No Color" could meet your requirement. I have set fill no color in your PDF with Adobe, and the image will not be covered. Attached is the PDF changed by Adobe. But I found using Spire to set no fill color has issues, and I have posted this issue to our Dev team. We will let you know once there is any update.

Sincerely,
Betsy
E-iceblue support team
User avatar

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

Tue Feb 11, 2020 9:25 am

Hi,

Thanks for waiting.
Now the issue is solved in Spire.PDF Pack(Hot Fix) Version:6.2.1.
Our website link: https://www.e-iceblue.com/Download/down ... t-now.html
NuGet link: https://www.nuget.org/packages/Spire.PDF/6.2.1

Below code for your kind reference:
Code: Select all
        Dim pdfDoc As New Spire.Pdf.PdfDocument(PdfConformanceLevel.None)
        pdfDoc.LoadFromFile("A_5.1-4.pdf")

        ' Fill the Form
        Dim formWidget As PdfFormWidget = pdfDoc.Form
        For i = 0 To formWidget.FieldsWidget.List.Count - 1
            Dim field As PdfField = TryCast(formWidget.FieldsWidget.List(i), PdfField)
            If TypeOf field Is PdfTextBoxFieldWidget Then
                Dim textBoxField As PdfTextBoxFieldWidget = TryCast(field, PdfTextBoxFieldWidget)
                Select Case textBoxField.Name
                    Case "Innung"
                        textBoxField.Text = "innung"
                    Case "Vor und Nachname"
                        textBoxField.Text = "Gabbert, Uwe"
                    Case "Systemverantwortlicher Leiter Region"
                        textBoxField.Text = "SLR Uwe Gabbert"
                        'set fill color
                        textBoxField.ForeColor = Color.Empty
                        textBoxField.BackColor = Color.Empty


                End Select
            End If
            field.Flatten = True
            field.ReadOnly = True
        Next

        Dim seiten = pdfDoc.Pages
        Dim pf = PdfImage.FromFile("uwe.png")
        seiten(0).Canvas.DrawImage(pf, 300, 600, 150, 75)

        ' Save and Show
        Dim dt = "19722-NoColor.pdf"
        pdfDoc.SaveToFile(dt, FileFormat.PDF)


Sincerely,
Betsy
E-iceblue support team
User avatar

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

Mon Feb 17, 2020 6:12 am

Hi,

Hope you are doing well.
Has your issue been resolved? Could you please give us some feedback at your convenience?

Sincerely,
Betsy
E-iceblue support team
User avatar

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

Return to Spire.PDF