Hi,
I'm creating PDFs out of images(tif,jpg), where every image is on it's own page.
While it's working fine for a small number of images, it's very time and memory consuming
when it get's to a huge number of images meaning 200 pages and more, which isn't unusual here.
Size of images is between 100 and 450KB (so far I've seen).
Size of each page in PDF should be A4, if size of image is larger, page size will be adjusted.
Am I doing something wrong or is there a better way to achieve the target?
Any memory cleaning to be done at end of procedure?
Here is the sample code:
Code:
Sub PDFCreate()
Dim i As Integer
Dim vPDFDoc As PdfDocument
Dim vPDFPage As PdfPage
Dim vXImg As XImage
Dim vXGr As XGraphics
Dim vslDebugStep As String
vslDebugStep = "CreatePDF"
vPDFDoc = New PdfDocument()
For i = 1 To 274
Console.WriteLine(i.ToString)
vPDFPage = New PdfPage()
vPDFPage.Size = PageSize.A4
vXImg = XImage.FromFile(String.Format("1898109\1898109_{0}.FOB", i.ToString))
vXImg.Interpolate = False
'adjust PageSize
If (vXImg.PointHeight > vPDFPage.Height.Value) Then vPDFPage.Height = vXImg.PointHeight
If (vXImg.PointWidth > vPDFPage.Width.Value) Then vPDFPage.Width = vXImg.PointWidth
vPDFDoc.Pages.Add(vPDFPage)
vXGr = XGraphics.FromPdfPage(vPDFDoc.Pages(i - 1))
vXGr.DrawImage(vXImg, 0, 0)
Next
vslDebugStep = "SavePDF"
vPDFDoc.Save("test.pdf")
vPDFDoc.Close()
End Sub
BTW: using PdfSharp.dll Version 1.31.1789.0 GDI build
thanks in advance for your help
jones