I have a document which is a TIFF (just some text).
I am trying to convert the TIFF to PDF.
The basic function
Public Function SpireTifToPDF(ByVal imgByte() As Byte) As Byte()
Dim doc As New PdfDocument()
Dim section As PdfSection = doc.Sections.Add()
Dim page As PdfPageBase = doc.Pages.Add()
Dim ms As New System.IO.MemoryStream(imgByte)
Dim image As Spire.Pdf.Graphics.PdfImage = Spire.Pdf.Graphics.PdfImage.FromStream(ms)
Dim widthFitRate As Single = image.PhysicalDimension.Width / page.Canvas.ClientSize.Width
Dim heightFitRate As Single = image.PhysicalDimension.Height / page.Canvas.ClientSize.Height
Dim fitRate As Single = Math.Max(widthFitRate, heightFitRate)
Dim fitWidth As Single = image.PhysicalDimension.Width / fitRate
Dim fitHeight As Single = image.PhysicalDimension.Height / fitRate
page.Canvas.DrawImage(image, 30, 30, fitWidth, fitHeight)
ms = New System.IO.MemoryStream
doc.SaveToStream(ms)
doc.Clone()
Return ms.GetBuffer
End Function
Attached is the PDF I Get from the function if I run System.IO.File.WriteAllBytes("p:\test.pdf", pdfByteArray)
Adobe says the file is corrupt and will not open.
PDF Exchange does open the file, PDF Exchange does tend to be more forgiving than Adobe.
How can I change my function to improve the file so it does not appear corrupt to adobe?
Thank You,
Daniel