Hello,
I need to convert a PNG file into a PDF.
Usually I use this code :
Dim pdfDocument As New Document()
pdfDocument.Pages.Add()
Dim Image As Aspose.Pdf.Image = New Aspose.Pdf.Image()
Image.File = file
Dim MarginInfo As MarginInfo = New MarginInfo()
MarginInfo.Top = 0
MarginInfo.Left = 0
MarginInfo.Right = 0
MarginInfo.Bottom = 0
pdfDocument.Pages(1).PageInfo.Margin = MarginInfo
pdfDocument.Pages(1).Paragraphs.Add(Image)
Dim TmpPath As String = _path_e_PPPPMMMM & “.pdf”
pdfDocument.Save(_TmpPath)
But now, for the file I posted as attachment, I receive the following exception:
System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(Stream stream, ImageFormat format)
at Aspose.Pdf.XImageCollection.#=zeDqKJl2JkLTn_x4I$g==(Stream #=zSTPS3Fc=, #=zmQ2IzQQuwJuzpkkhGQkD9jXhEMRZWAgVWxnszLi$Sw_I #=zK1vHsZM=, #=zKcUUx2bOnR$Fl9_7Qli354fG3Ti0bAsZZQ== #=znc9i8zk=, Int32 #=zgZgb6V8=, Image& #=zG9Ic9ReybXD, Stream #=zbJ4sSmYuRcGQCHbbQIj2rOE=)
at Aspose.Pdf.XImageCollection.#=zoWQ0I9xMPfuj(Int32 #=z8XmTY4o=, Stream #=zSTPS3Fc=, Int32 #=zgZgb6V8=, Boolean #=z3NM8PT7_YXDC, ImageFilterType #=znildsQc=, Byte #=zcRTyRkOEuA3B, Boolean #=zJg0qn1c=, String& #=zgey9oFmrwtfR, Stream #=zbJ4sSmYuRcGQCHbbQIj2rOE=)
at Aspose.Pdf.XImageCollection.#=zoWQ0I9xMPfuj(Int32 #=z8XmTY4o=, Stream #=zSTPS3Fc=, Int32 #=zgZgb6V8=, Boolean #=z3NM8PT7_YXDC, ImageFilterType #=znildsQc=, Boolean #=zJg0qn1c=, Stream #=zbJ4sSmYuRcGQCHbbQIj2rOE=)
at Aspose.Pdf.XImageCollection.#=zUs9M$4E=(Stream #=zSTPS3Fc=, Int32 #=zgZgb6V8=, Boolean #=z3NM8PT7_YXDC, ImageFilterType #=znildsQc=, Boolean #=zJg0qn1c=, Stream #=zbJ4sSmYuRcGQCHbbQIj2rOE=)
at Aspose.Pdf.Page.#=z71UQrIA=(Stream #=zSTPS3Fc=, Rectangle #=ziKptALY=, Matrix #=zHspMqOEdvvPN, CompositingParameters #=zhZaVNfFY$TrEJENnthVuRwA=, Boolean #=z4WIIdWI=, Boolean #=z3NM8PT7_YXDC, #=zFjemt2LbUYnIZ$RtiqcEUMLdWT4oHo386g==& #=zcxsnbw0ekSoq, Stream #=zbJ4sSmYuRcGQCHbbQIj2rOE=, Boolean #=zVQ4etSg=, Int32 #=zhZz13R8D23LB)
at Aspose.Pdf.Page.#=z71UQrIA=(Stream #=zSTPS3Fc=, Rectangle #=ziKptALY=, CompositingParameters #=zhZaVNfFY$TrEJENnthVuRwA=, Boolean #=z4WIIdWI=, Boolean #=z3NM8PT7_YXDC, Stream #=zbJ4sSmYuRcGQCHbbQIj2rOE=, Boolean #=zVQ4etSg=, Int32 #=zhZz13R8D23LB)
at Aspose.Pdf.Image.#=zToapkrg=(Double& #=zIMGides=, Double& #=zJoXdnoo=, Double& #=zKLvZ3Ts=, Boolean #=z6zs83seze3Pg, MarginInfo #=zd51tBlQ=, Double #=zSbRjuZsCiVM7, Double #=zBiBCnds=, Page #=zBdVDYsQ=, List`1 #=z1TdFx$M=, Boolean #=zT6fCl3Bozq6z, Boolean #=zWyyGG8A5voyM, Boolean #=zMpug9ts=, Paragraphs& #=zXZh4CSEoRLhk2olkhQ==, Double #=zhsJQuVDLdNDkPuQEWQ==, Double #=zIFcNHH4=, Int32 #=znuNccY$EuSHvcL3gbhL7bsk=)
at #=zZfh_Fze6sbxRhUzJvIQoXRc=.#=zToapkrg=()
at Aspose.Pdf.Page.#=z41eQlcc=(Page #=zBdVDYsQ=)
at Aspose.Pdf.Page.#=zrgVRcWEWKuVDbfr4Ow==()
at Aspose.Pdf.Document.ProcessParagraphs()
at Aspose.Pdf.Document.#=zK2KzxWYW6IXP(Stream #=zrO5u_so=, SaveOptions #=zuBOVy7thULtl)
at Aspose.Pdf.Document.#=zB0WnsfwY8HBL(String #=zKuN5UfSP2rqM)
at Aspose.Pdf.Document.Save(String outputFileName)
Can u please provide me your help ?
I run this code in a Microsoft Window Server 2003 R2, Standard Edition, Service Pack 2, and server feautures in attachment.
file.PNG.jpg (144.3 KB)
server_caracheteristic.jpg (6.2 KB)