hi,
when i try to convert PDF to Jpeg i get the next Error ERROR:Conversion from string “image” to type ‘Double’ is not valid.
igave you sample of the code and the file
Dim pdfDocument As Aspose.pdf.Document = New Aspose.pdf.Document(fileFolder + fileName)
Try
' ' -----===== remove hyperLinks
For pageCount As Integer = 1 To pdfDocument.Pages.Count
Using imageStream As FileStream = New FileStream(fileFolder & "image" + pageCount & "_out" & ".jpg", FileMode.Create)
Dim resolution As Resolution = New Resolution(300)
Dim jpegDevice As JpegDevice = New JpegDevice(resolution, 100)
jpegDevice.Process(pdfDocument.Pages(pageCount), imageStream)
imageStream.Close()
End Using
Next
Catch exp As Exception
'---=== response binary for debuging ===--
'================================================================================================================
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.TrySkipIisCustomErrors = true
Response.StatusCode = 205
Response.ContentType = "text/plain"
Response.Write("ERROR:"&exp.Message)
Response.end
'================================================================================================================
End Try
Dim docStream As New MemoryStream()
pdfDocument.Save(docStream)
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.StatusCode = 202
Response.AddHeader("Content-Description", "File Transfer")
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment; filename=test.pdf")
Response.AddHeader("Content-Transfer-Encoding", "binary")
docStream.WriteTo(Response.OutputStream)
response.Write(pdfDocument)
response.end
We used following code snippet to test the scenario with Aspose.PDF for .NET 20.11 and did not notice any issue. Resultant images are also attached for your reference.
var fs = new FileStream(dataDir + "094937Anastasya Mingalyov KOROT HAIM (1) (1).pdf", FileMode.Open);
Document pdfDocument = new Document(fs);
foreach (Page page in pdfDocument.Pages)
{
using (FileStream imageStream = new FileStream(dataDir + "image" + page.Number + ".jpg", FileMode.Create))
{
Resolution resolution = new Resolution(300);
JpegDevice jpegDeviceLarge = new JpegDevice(resolution, 100);
jpegDeviceLarge.RenderingOptions.InterpolationHighQuality = true;
jpegDeviceLarge.RenderingOptions.UseNewImagingEngine = true;
jpegDeviceLarge.Process(page, imageStream);
}
}
Would you kindly share a sample console application which is able to reproduce the issue so that we can test the scenario in our environment and address it accordingly.
i get this error " Compiler Error Message: BC30002: Type ‘Aspose.Pdf.Drawing.Image’ is not defined." i used the last aspose.pdf version
Dim fs = New FileStream(fileFolder + fileName, FileMode.Open)
Dim pdfDocument As Aspose.Pdf.Document = New Aspose.Pdf.Document(fs)
For Each page As Page In pdfDocument.Pages
Using imageStream As FileStream = New FileStream(fileFolder & "image" + page.Number & ".jpg", FileMode.Create)
Dim resolution As Resolution = New Resolution(300)
Dim jpegDeviceLarge As JpegDevice = New JpegDevice(resolution, 100)
jpegDeviceLarge.RenderingOptions.InterpolationHighQuality = True
jpegDeviceLarge.RenderingOptions.UseNewImagingEngine = True
jpegDeviceLarge.Process(page, imageStream)
Dim image As Aspose.Pdf.Drawing.Image = Aspose.Pdf.Drawing.Image.FromStream(imageStream)
Using ms As MemoryStream = New MemoryStream()
image.Save(ms, Drawing.Imaging.ImageFormat.Png)
ms.WriteTo(Response.OutputStream)
End Using
End Using
Next
Would you kindly share your sample application with us in .zip format. We will test the scenario in our environment and address it accordingly. You can create a sample application as well which only includes the functionality being discussed here and share with us.