Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri Mar 22, 2024 6:59 pm

Hi everyone

i have a problem with this example.
Spire.PDF-for-.NET/blob/master/CS/13_Conversion/ToImage.cs


System.IO.Stream can not convert to system.drawing.image

Code: Select all
        PdfDocument doc = new PdfDocument();
        // Load a PDF file
        doc.LoadFromFile(fileName);
        Image image = doc.SaveAsImage(0, PdfImageType.Bitmap);


but i need a image object from the frist pdf file.
any ideas?

peterkox1
 
Posts: 1
Joined: Fri Mar 22, 2024 6:45 pm

Mon Mar 25, 2024 2:59 am

Hello,

Thanks for your inquriy.
To assist us in further investigating your issue, please share with us the following information:
1. Project type you are using(E.g Consoleapp);
2.Target platform of your project (E.g. .NET framework 7.0) ;
3. The version of Spire.PDF you currently have installed.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 757
Joined: Mon Dec 27, 2021 2:23 am

Sun Apr 07, 2024 8:53 pm

I have the same issue using the code from the tutorial:

Code: Select all
//Create a PdfDocument instance
PdfDocument pdf = new PdfDocument();
 
//Load a sample PDF document
pdf.LoadFromFile("E:\\Files\\input.pdf");
 
//Convert the first page to an image and set the image Dpi
Image image = pdf.SaveAsImage(0, PdfImageType.Bitmap, 500, 500);
 
//Save the image as a JPG file
image.Save("ToJPG.jpg", ImageFormat.Jpeg);


#1) SaveAsImage only acceptes 2 parameters
#2) SaveAsImage returns a System.IO.Stream which does not support a .Save() method


Using .Net 8.0 on a Windows machine
Testing with FreeSpire.PDF version 10.2.0

t7labarre
 
Posts: 1
Joined: Sun Apr 07, 2024 8:47 pm

Mon Apr 08, 2024 3:23 am

Hi,

Thanks for your inquiry.
Please kindly note that only the Spire.Pdf.dll for NetFrameWork4.8 and NetStandard 2.0 are provided in FreeSpire.Pdf 10.2.0, due to the Net 8.0 is used in your project, the Spire.Pdf.dll of NetStandard2.0 will be auto intalled in your prject when installing FreeSpire.Pdf through Nuget, and SaveAsImage only acceptes 2 parameters in this version’s dll.

In our commercial version of Spire.Pdf, the Spire.Pdf.dll of NetCore version are provided, such as Spire.Pdf.dll for Net 6.0、Net7.0, the SaveAsImage method can acceptes 4 parameters in these Spire.Pdf.dlls. You can have a try. For new user, we are willing to provide a temporary month license to help you remove red warning message and function limitation. If you need it, you can contact our sales team([email protected]).

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Return to Spire.PDF