I using PDF Sharp library to convert JPG list file into pdf file. Using pdfsharp library on windows 7 o.s. the result it's horrible. If I use TIFF tif the conversion is correct. I using 1.31.1789.0 versione into vs.2005
My source code it's that. Any idea ?
Public Shared Sub ImagesToPDF(ByVal imagePath As List(Of String), ByVal pdfPath As String)
Dim PdfDoc As PdfSharp.Pdf.PdfDocument = Nothing Dim Xgr As PdfSharp.Drawing.XGraphics = Nothing Dim Img As PdfSharp.Drawing.XImage = Nothing
Try
PdfDoc = New PdfSharp.Pdf.PdfDocument For Each f As String In imagePath PdfDoc.Pages.Add(New PdfSharp.Pdf.PdfPage)
Dim PageIndex As Integer = PdfDoc.Pages.Count - 1
Xgr = PdfSharp.Drawing.XGraphics.FromPdfPage(PdfDoc.Pages(PageIndex)) Img = PdfSharp.Drawing.XImage.FromFile(f)
If PdfDoc.Pages(PageIndex).Width.Point < Img.Size.Width Then PdfDoc.Pages(PageIndex).Width = XUnit.FromPoint(Img.Size.Width) End If
If PdfDoc.Pages(PageIndex).Height.Point < Img.Size.Height Then PdfDoc.Pages(PageIndex).Height = XUnit.FromPoint(Img.Size.Height) End If
Xgr.DrawImage(Img, 0, 0, Img.Size.Width, Img.Size.Height) Img.Dispose() Xgr.Dispose() Next
PdfDoc.Save(pdfPath) PdfDoc.Close() PdfDoc.Dispose()
Catch ex As Exception Throw New ApplicationException("Errore nel metodo " & System.Reflection.MethodInfo.GetCurrentMethod.Name & ".", ex) End Try End Sub
Attachments: |
test.tif [ 170.92 KiB | Viewed 6968 times ]
|
|