The whole process of creating the object:
- Code: Select all
Using Dokument As New PdfDocument
adding one or more pages:
- Code: Select all
'Seiten hinzufügen
' 1. Seite
Dim Seiten As PdfPageBase = Dokument.Pages.Add(PdfPageSize.A4, SeitenRand, SeitenAusr, SeitenOri)
' Wenn nötig weitere Seiten
If SeiteAnz > 1 Then
For SeitenID = 1 To SeiteAnz - 1
Seiten.Document.Pages.Add(PdfPageSize.A4, SeitenRand, SeitenAusr, SeitenOri)
Next SeitenID
End If
adding the content:
- Code: Select all
' Logo
Seiten.Document.Pages.Item(SeitenID).Canvas.DrawImage(Logo, RandLi, RandOb)
' Firmenname, Tel.Nr, Webseite, E-Mail Rechts im Briefkopf
Seiten.Document.Pages.Item(SeitenID).Canvas.DrawString(KopfText, HESchriftNormal, Textfarbe, HTab, RandOb)
....
printing it:
- Code: Select all
If Copies > 0 Then
Dokument.PrintSettings.Copies = Copies
Dokument.PrintSettings.PrinterName = My.Settings.DruckerA4mono
Dokument.PrintSettings.Collate = False
Dokument.PrintSettings.DocumentName = Me.Text
Dokument.PrintSettings.Duplex = Dokument.PrintSettings.CanDuplex
Dokument.PrintSettings.PrinterResolutionKind = Print.PdfPrinterResolutionKind.Medium
End If
Dokument.Print()
and finally disposing the object.
- Code: Select all
End Using
is taking place in only one sub of some 100 lines
It's working perfectly the first and second time the code ist processed. Starting from the third time several characters are missing. Each time the code is processed more characters are missing. In the attachment you can see "5" and "y" are missing. (tried to attach pdf but that isn't allowed. Anyway the only thing one could have seen there is that y and 5 where missing all over the text.)
This is only happening when the document is printed.
If i save it to a temporary file, and open it afterwards, everything is correct.
- Code: Select all
Dokument.SaveToFile(TempFile)
Process.Start(TempFile)
Another ting, i observed, that my application uses a lot of memory, when printing, and printing takes a long time.
Normally the app uses ~60 mb of memory. While printing the memory consumption rises up to more than 300 mb. After having printed the first document the memory stays at about 100 mb. So I assume, that something is not "cleaned up" properly.
Well .... I need help