We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PDF to PPTX text as images -- PDF for .NET 10.5.1.0

We’re using Aspose.Pdf.Generator to create custom PDFs with rectangles and text among other things. This works fine.

When I save the PDF as PPTX, the output looks OK, but the rectangles are output as a single image, while the text is maintained in text format.
I imagine some may prefer this, but we have an issue with this.
We need to be able to stretch and move the output on the slides such that the text transforms with the same proportions as the rectangles.
Currently, while re-sizing the rectangles, the text will attempt to word-wrap, maintains font-size, etc (see attached “ppt_test.pptx”).
Is there any way to control how text is converted as part of the PPTX conversion?
Is there anything I can do different in the PDF.Generator code to make sure the text will convert differently?

I have tried saving the pages of the PDF as images, and then adding them back in, but something is not working right (see attached “ppt-test-image.pptx”).

This is the code with commented attempts I’ve tried:
var doc = new Document(sourcePath);
var doc = new Document(fileStream);
		<span style="color:#608b4e;">//convert page to an image and add back to help with PPT conversion</span>
		<span style="color:#569cd6;">var</span> <span style="color:white;">jpegDevice</span> <span style="color:#b4b4b4;">=</span> <span style="color:#569cd6;">new</span> <span style="color:lightblue;">JpegDevice</span>(<span style="color:#569cd6;">new</span> <span style="color:lightblue;">Resolution</span>(<span style="color:#b5cea8;">300</span>), <span style="color:#b5cea8;">100</span>);

		<span style="color:#569cd6;">foreach</span> (<span style="color:lightblue;">Page</span> <span style="font-weight:bold;color:white;">page</span> <span style="color:#569cd6;">in</span> <span style="color:white;">doc</span><span style="color:#b4b4b4;">.</span><span style="color:violet;">Pages</span>)
		{

// var page = doc.Pages[1];

			<span style="color:#569cd6;">var</span> <span style="color:white;">imageStream</span> <span style="color:#b4b4b4;">=</span> <span style="color:#569cd6;">new</span> <span style="color:lightblue;">MemoryStream</span>();

// var imageStream = new FileStream(@“C:\Development\Practice\AsposePDF\AsposePdfPractice\page.jpg”, FileMode.Create);
jpegDevice.Process(page, imageStream);
// imageStream.Close();

// var image = new Image();
// page.Paragraphs.Add(image);
// image.ImageStream = imageStream;

			<span style="font-weight:bold;color:white;">page</span><span style="color:#b4b4b4;">.</span><span style="color:cyan;">AddImage</span>(<span style="color:white;">imageStream</span>, <span style="font-weight:bold;color:white;">page</span><span style="color:#b4b4b4;">.</span><span style="color:violet;">CropBox</span>);

// page.AddImage(@“C:\Development\Practice\AsposePDF\AsposePdfPractice\page.jpg”, page.CropBox);

			<span style="color:white;">imageStream</span><span style="color:#b4b4b4;">.</span><span style="color:cyan;">Close</span>();
		}

		<span style="color:white;">doc</span><span style="color:#b4b4b4;">.</span><span style="color:cyan;">Save</span>(<span style="font-weight:bold;color:violet;">filePath</span>, <span style="color:#569cd6;">new</span> <span style="color:lightblue;">PptxSaveOptions</span>());

// imageStream.Close();


Also, since some pages in our final PDF will have pages with just text (that we don’t want to convert to images), it might be easier to handle this issue in the PDF generation code, rather than trying to extract out certain pages from the PDF to create images (unless there’s an easy way to check for IDs or elements to filter out the pages we need).

Recap:
We’re creating the PDF.
We want to convert the PDF into PPTX.
We want the PPTX to have a single image per slide so it can be stretched.
We want to be able to select identifiable Pages from PDF to convert into images in PPTX.
We want to be able to use streams as much as possible since we’re running in a web context.

Do you have any suggestions?

Thanks,
Joey

Hi Joey,


Thanks for your inquiry. We will appreciate it if you please share your sample PDF document here, we will look into it and will provide you information accordingly.

We are sorry for the inconvenience caused.

Best Regards,