Dear all, I’m new to the forum. This might have been asked before, but I just thought to drop my question here, if already covered, I would appreciate if someone could put the link below.
Hi Sheng,
Thanks for your interest in Aspose.Slides.
I have observed your requirements and like to share that Aspose.Slides does support working with PHP. I suggest you to please visit the guidelines shared in this thread link for your kind reference in this regard. Please share, if you need any help in this regard.
Many Thanks,
Thanks for your reply.
Hi Sheng,
I have observed your requirements and like to share that you can convert slides to image in PHP environment using Aspose.Slides. I suggest you to please try using the following sample code on your end to serve the purpose. I hope the shared information will be helpful.
<?php
try
{
//Instantiate a Presentation object that represents a PPT file
$pres= new Java("com.aspose.slides.Presentation", "C:\\demo.ppt");
//get last position of presentation
$lastSlidePosition = $pres->getSlides()->getSlides()->size();
//iterate all slides
for ($pos = 0; $pos < $lastSlidePosition; $pos++)
{
$slide = $pres->getSlides()->get_Item($pos);
//Creating the Dimension object to specify the width and height of image
$dimension=new Java("java.awt.Dimension",720,540);
//Getting the thumbnail image of the slide of a specified size
//$image=$slide->getThumbnail($dimension);
$image=$slide->getThumbnail(1.0f,1.0f);
//Creating the ImageIO class object
$ImageIO = new Java("javax.imageio.ImageIO");
//Creating a file output stream to write the slide thumbnail
$fostream=new Java("java.io.FileOutputStream","C:\\thumbnail2.jpg");
//Saving the thumbnail image in jpeg format
$ImageIO->write($image,"jpeg",$fostream);
}
}
catch(JavaException $ex)
{
echo $ex;
}
?>
Many Thanks,
Hi Mudassir,
Many thanks!
Sheng
Hi Sheng,
I have observed the information shared by you but unfortunately unable to understand what issue is incurring on your end. Please share the detailed information along with sample project and source presentation. Is the issue you are having is related to Aspose.Slides? Please share the issue details with us so that I may help you further in this regard.
Many Thanks,
Hi Sheng,
I have observed the stack trace. Can you please make sure if your Java bridge has been successfully created in your PHP application. You can test this simply by using following statement.
$pres= new Java(“com.aspose.slides.Presentation”);
If this executes fine then it means your Java bridge is configured properly with Aspose.Slides. However, if the above empty Presentation class constructor throws exception then you need to check your environment that if that is properly configured and Aspose.Slides for Java is getting properly referenced.
If the above test pass then I suggest you to please first try using the desired code for creating image from slides in a console java application to see if there is any issue with API when dealing with source presentation. I also suggest you to please try using Aspose.Slides for Java 16.5.0 on your end.
Many Thanks,
Dear Mudassir,
Sheng
Hi Sheng,
I have checked the sample code shared by you and like to share that you are saving the same file for every slide thumbnail in your sample code shared here. You need to change the following sample code in your application with some different name every time.
$fostream=new Java(“java.io.FileOutputStream”,“/Users/user/Downloads/thumbnail2.jpg”);
You are saving every slide thumbnail with thumbnail2.jpg. Please revisit this line with some incremental file name on your end.
Many Thanks,
Hi Mudassir,
We are almost there now.
Many thanks,
Sheng
Hi Sheng,
I have observed the sample code and suggest you to please try replacing the following sample code in your code. I hope this will be helpful.
$ImageIO->write($image,“png”,$fostream);
Many Thanks,
Hi Mudassir,
Hi Sheng,
I have observed the stack trace shared by you and have observed following exception.
“Cannot find any fonts installed on the system”.
This means that you are probably having missing fonts on your deployment server or if they are there you don’t have permissions for that. You your self have mentioned that same code works fine on Windows or Mac on your end.
Please check the permissions and grant appropriate permissions. If the fonts are missing, you can copy the used fonts in target server at some location and load the fonts externally using Aspose.Slides for Java without even installing them. I hope this will be helpful.
Many Thanks,
Hi Mudassir,
Hi Sheng,
Its good to know that things are resolved on your end after installation of fonts. As far as extracting text from presentation is concerned, I request you to please visit this java documentation link for your kind reference. You may please port the java code to appropriate PHP code to serve the purpose on your end.
For PDF to Image and PDF text extraction, I will request Aspose.Pdf support team to share the feedback.
Many Thanks,
juplus:
On a separate note, we wanted to also convert PDF file to image, do you have a example code for us to use, please?
Hi Sheng,
Thanks for using our API’s.
We have an API named Aspose.Pdf for Java which offers the feature to convert PDF pages to Image format. For more information, please visit Convert PDF Pages to JPEG Image
juplus:
We also want to extract text from slides (all ppt format and PDF), could you also send me sample code for this?
Aspose.Pdf for Java also offers the feature to extract text from PDF files. For further details, please visit Search and Get Text
In case you encounter any issue, please share your resource/input documents, so that we can test the scenario in our environment.
Hi Nayyer,
Hi Sheng,
As shared earlier, please visit this java documentation link to extract the text from presentation. You may port the code to PHP to serve the purpose. I hope this will be helpful.
Many Thanks,