0

I would like create a text layer over an image, which is not added to pdf doc as cell.

This is my current code:

    Dim pdfDoc As New Document(PageSize.A4, 50, 50, 25, 25)
    Dim output = New MemoryStream()
    'Dim path As String = "\\pcpke735\PKESimulation\pdf\"
    Dim path As String = "C:\PKE Simulation AG\WebApplication1\pdf\"
    Dim filename As String = "Leistungen_" & DateTime.Now.Date.ToString("ddMMyyyy") & "_" & Date.Now.ToString("hhmmss") & ".pdf"
    Dim pdfWrite As PdfWriter = PdfWriter.GetInstance(pdfDoc, New FileStream(path & filename, FileMode.Create))

    Dim sparplan_bez As String

    Try
        pdfDoc.AddTitle("Leistungen")
        pdfDoc.Open()

        'Headerbild einfügen
        Dim logo = iTextSharp.text.Image.GetInstance(Server.MapPath("/images/head.png"))

        logo.ScaleAbsolute(600, 150)
        logo.SetAbsolutePosition(0, 700)
        logo.Alignment = iTextSharp.text.Image.UNDERLYING
        pdfDoc.Add(logo)

        'Vier Leerzeilen
        pdfDoc.Add(New Paragraph(vbCrLf))
        pdfDoc.Add(New Paragraph(vbCrLf))
        pdfDoc.Add(New Paragraph(vbCrLf))
        pdfDoc.Add(New Paragraph(vbCrLf))

        'Dim logo = iTextSharp.text.Image.GetInstance(Server.MapPath("/Logo/PKE.jpg"))
        'logo.SetAbsolutePosition(450, 750)

        'Schriftart und Grösse setzen
        Dim titleFont = FontFactory.GetFont("Arial", 18, Font.BOLD)
        Dim subTitelFont = FontFactory.GetFont("Arial", 14, Font.BOLD)
        Dim boldTableFont = FontFactory.GetFont("Arial", 12, Font.BOLD)
        Dim standardFont = FontFactory.GetFont("Arial", 11)

        'Vier Leerzeilen
        pdfDoc.Add(New Paragraph(vbCrLf))
        pdfDoc.Add(New Paragraph(vbCrLf))

        'Titelzeile
        Dim cb = pdfWrite.DirectContent
        cb.BeginText()
        cb.SetTextMatrix(210, 230)
        Dim Tfont = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, False)
        cb.SetFontAndSize(Tfont, 24)
        cb.ShowText("Simulation per " & eintrittper.Text)
        cb.EndText()

        pdfDoc.Add(New Paragraph(vbCrLf))
        pdfDoc.Add(New Paragraph("Erstellt am: " & Now(), standardFont))
        pdfDoc.Add(New Paragraph(vbCrLf))
        pdfDoc.Close()

        Dim quelle As String = "/pdf/" & filename
        Response.Write("<script>window.open('" & quelle & "')</script>")
    Catch ex As Exception
        'WriteLog("Fehler PDF Leistungen erstellen : " & Err.Description)
        'errorState = True
    End Try
End Sub

The Direct content object should be placed over the image.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
R Funky
  • 11
  • 3
    I answer a lot of questions on Stack Overflow, but I stopped reading yours after reading *iTextsharp isn't realy well documented with real examples*. That is untrue and insulting, hence there was no reason for me to read on and to look what your question was about. – Bruno Lowagie Sep 29 '16 at 08:45
  • @RFunky It is not clear from your question what the desired behavior is in contrast to the observable behavior. – mkl Sep 29 '16 at 15:10
  • 1
    read link http://stackoverflow.com/questions/8657857/itextsharp-text-overlapping-image, i hope this will help you – Patrick R Oct 01 '16 at 13:29

0 Answers0