Aspose question

I need to convert .DOC and .DOCX files to PDF in a VB.NET program. Which of your products would I need to purchase to accomplish this? Just ASPOSE.word OR would I also need ASPOSE.PDF?

Hi Wayne,


Thanks for your interest in Aspose.

Please note Aspose.Words for.NET supports the feature to convert DOC(X) files to PDF. Whereas Aspose.PDF for .NET converts PDF files to DOC(X). You may purchase either of these APIs or both as per your requirements.

Please feel free to contact us for any further assistance.

Best Regards,

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,

Thanks for your inquiry. As your query is more related to Aspose.Pdf, I am moving this thread in Aspose.Pdf forum where you'll be guided appropriately.

Best regards,

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.
Hi Wayne,

As per my observations, the problem might be occurring because you have specified ImageFileType as TIFF for JPEG file. Furthermore, you are also using a legacy Aspose.Pdf.Generator approach and I would recommend you to please try using new Document Object Model of Aspose.Pdf name space to perform the conversion.

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.

[VB.NET]

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.

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.
Hi Wayne,

Thanks for sharing the code snippet.

I have again tested the scenario while using Aspose.Pdf for .NET 10.0.0 in VisualStudio 2010 project with target platform as .NET Framework 4.0 running over Windows 7 (x64) and as per my observations, the Image files are properly being converted to PDF format. For your reference, I have also attached the resultant file generated over my end.

[VB.NET]

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