Hi Wayne,
My company will be purchasing your product soon. I have used the DEMO version to develop code to be used at a customer site. The code will convert a tiff file and multiple jpeg files into one PDF. The code is working but some jpeg images are corrupt when converted to PDF. The jpeg files were captured on a Docuscan scanner. Attached is one of the images that is corrupt when converted to PDF. Also attached is the vb.net code. I started from code listed on your site. I don’t know what could be wrong with the image because I can open it with image software. Any help you can give would be appreciated.
Hi Wayne,wbarber:My company will be purchasing your product soon. I have used the DEMO version to develop code to be used at a customer site. The code will convert a tiff file and multiple jpeg files into one PDF. The code is working but some jpeg images are corrupt when converted to PDF. The jpeg files were captured on a Docuscan scanner. Attached is one of the images that is corrupt when converted to PDF. Also attached is the vb.net code. I started from code listed on your site. I don’t know what could be wrong with the image because I can open it with image software. Any help you can give would be appreciated.
When using new DOM, you do not need to specify the image file type as the engine automatically determines the type and renders it inside the PDF document. For your reference, I have also attached the resultant file generated over my end.
Dim doc As Aspose.Pdf.Document = New Aspose.Pdf.Document()<o:p></o:p>
Dim image As Aspose.Pdf.Image = New Aspose.Pdf.Image()
image.File = "c:/pdftest/DPL1_1002_001_20150109_PE_003.JPG"
doc.Pages.Add().Paragraphs.Add(image)
doc.Save("c:/pdftest/DPL1_1002_001_20150109_PE_003.pdf")
Thanks for the response.
The first image that is added to the PDF is a TIFF file followed by multiple JPEG files. I will try using the DOM approach and hopefully that will correct the issue.
Thanks again!
I tried DOM method and still having issue with certain jpeg files. I attached two of the problem jpeg files. Attached is vb.net code that will combine multiple jpeg files into a PDF. It works fine for most jpeg files. The problem is when I use it on jpeg files created by our Docuscan 9000 scanner I get error ‘A generic error occurred in GDI"’. These jpeg images can be opened by image viewer software. Source also pasted below.
Private Sub TiffToPDF_Click(sender As System.Object, e As System.EventArgs) Handles TiffToPDF.Click
Try
Dim filesLocation As String = "\\dsserv01\efcapps\Discover\Export\DFSPersonalLoans\RPEM100220150109\"
Dim pdf_FPath As String = filesLocation + "\" + "output.pdf"
Dim pdf1 As Aspose.Pdf.Document = New Aspose.Pdf.Document()
Dim image1 As Aspose.Pdf.Image = New Aspose.Pdf.Image()
Dim imageFiles As String() = Directory.GetFiles(filesLocation, "*.jpg")
Dim fileName As String = ""
For Each fileName In imageFiles
image1.File = fileName
pdf1.Pages.Add().Paragraphs.Add(image1)
Next
pdf1.Save(pdf_FPath) 'Save the Pdf
Catch ex As Exception
Dim sLogMsg = ex.Message.ToString + " ERROR: While converting to pdf at location "
End Try
End Sub
End Class
The text file I attached above was empty. Attaching source.
After testing I realized I need to instantiate a new pdf image for each image. Attached is modified code. This source successfully combines most jpeg images but not the ones I attached above.
Hi Wayne,wbarber:After testing I realized I need to instantiate a new pdf image for each image. Attached is modified code. This source successfully combines most jpeg images but not the ones I attached above.
Dim filesLocation As String = "C:\pdftest\conversionissue"<o:p></o:p>
Dim pdf_FPath As String = filesLocation + "\" + "output.pdf"
Dim pdf1 As Aspose.Pdf.Document = New Aspose.Pdf.Document()
Dim imageFiles As String() = Directory.GetFiles(filesLocation, "*.jpg")
Dim fileName As String = ""
For Each fileName In imageFiles
Dim image1 As Aspose.Pdf.Image = New Aspose.Pdf.Image()
image1.File = fileName
pdf1.Pages.Add().Paragraphs.Add(image1)
Next
pdf1.Save(pdf_FPath) 'Save
the Pdf