PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 7:54 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Fri May 14, 2010 7:56 am 
Offline

Joined: Fri May 14, 2010 6:46 am
Posts: 2
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
test.tif [ 170.92 KiB | Viewed 5458 times ]
Top
 Profile  
Reply with quote  
PostPosted: Fri May 14, 2010 12:15 pm 
Offline

Joined: Fri May 14, 2010 6:46 am
Posts: 2
Also I test my procedure on windows server 2008 and the conversion from jpg to PDF it's ok.

Any idea ?

Marco


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 46 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group