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

Free Support Forum - aspose.com

Export to PDF as two slides per page

Dear support,


I would like to use aspose.slides to convert PPT and PPTX files to PDF with two slides per page.

I believe I can do it manually by converting each slides to a bitmap and then pasting the bitmaps into a PDF, but is there a way to do it using the SaveOptions or other mechanism with .Slides?

For example, the pseudocode I’d want is something like the below. Do you have a mechanism along those lines?
Thanks,

dim p as new presentation(“myfile.pptx”)

dim s as new SaveOptions
s.slidesperpage = 2
s.Fileformat= pdf

p.Save(“mypdf.pdf”,SaveOptions)


Hi Mike,

I have observed your requirements and like to share that you can use Presentation.Save method overload shared over this image link to set the pages desired for PDF export. You can use any combination as per your requirements. I hope the shared information will be helpful.

Many Thanks,

Hi Mudassir,


Thanks for the feedback. I am getting closer but still not there. I can now set the slide size and identify the slides I want - but they still come out one per page. Can you suggest any approaches to get two slides per page? My code is below.

Thanks,
Mike

Dim strSlides As String = Server.MapPath("~/SpeakerDocuments/CCare_Rev 7.pptx")
Dim strDest As String = Server.MapPath("~/SpeakerDocuments/mike.pdf")
Dim sf As New Aspose.Slides.Presentation(strSlides)

With sf
'.SlideSize.SetSize(Aspose.Slides.SlideSizeType.Custom, Aspose.Slides.SlideSizeScaleType.EnsureFit)
.SlideSize.SetSize(300, 300, Aspose.Slides.SlideSizeScaleType.EnsureFit)

Dim intSlides As Integer() = {1, 2, 3, 4}

.ViewProperties.LastView = Aspose.Slides.ViewType.HandoutView
.ViewProperties.ShowComments = Aspose.Slides.NullableBool.False

.Save(strDest, intSlides, Aspose.Slides.Export.SaveFormat.Pdf)

End With

To further clarify, what I’d really like to do is the equivalent of what I can d in PPT as follows:


1. Click Print
2. Select “Print to PDF” as the printer
3. Print “2 slides per page” as the print layout

I attached a screenshot from PowerPoint just to make sure I am being clear.

Thanks,
Mike


Hi Mike,

Thanks for your interest in Aspose.Slides.

I have discussed your requirements with our product team. I regret to share with you that the requested feature is currently not available in Aspose.Slides for. However, we have already logged a new feature request with ID SLIDESNET-37475 in our issue tracking system to support it. You will be notified via this forum thread once this feature is available.

We are sorry for the inconvenience.

Hi Adnan,

Well thanks for trying. In case anyone else is interested in doing this, I extracted the slides as bitmaps and paste them into PDF pages and that is working though probably not all that efficient. A code snippet is below:

’–get PowerPoint
Dim sf As New Aspose.Slides.Presentation(strSlides)
sf.SlideSize.Orientation = Aspose.Slides.SlideOrienation.Landscape
sf.ViewProperties.ShowComments = Aspose.Slides.NullableBool.False
’–create pdf
Dim pdf As New Aspose.Pdf.Document
’–add first page
Dim pdfpage As Aspose.Pdf.Page = pdf.Pages.Add()
pdfpage.SetPageSize(610.997, 790.702)
’–select slide
for i as integer = 1 to 2
Dim sld As Aspose.Slides.Slide = sf.Slides(i)

'Convert slide to image
Dim bmp As Bitmap = sld.GetThumbnail(1.0, 1.0)

-then followed aspose instructions for inserting bitmap into page
Dim imageStream As MemoryStream = New MemoryStream
bmp.Save(imageStream, System.Drawing.Imaging.ImageFormat.Jpeg)

’ Add image to Images collection of Page Resources
pdfPage.Resources.Images.Add(imageStream, 100)
’ Using GSave operator: this operator saves current graphics state
pdfPage.Contents.Add(New Aspose.Pdf.Operator.GSave())
’ Create Rectangle and Matrix objects
Dim rectangle As New Aspose.Pdf.Rectangle(lowerleftx, lowerlefty, upperrightx, upperrighty)
Dim matrix As New Aspose.Pdf.Matrix(New Double() {rectangle.URX - rectangle.LLX, 0, 0, rectangle.URY - rectangle.LLY, rectangle.LLX, rectangle.LLY})
'Dim matrix As New Aspose.Pdf.Matrix(New Double() {rectangle.URX - rectangle.LLX, 0, 0, rectangle.LLY - rectangle.URY, rectangle.LLX, rectangle.LLY})
’ Using ConcatenateMatrix (concatenate matrix) operator: defines how image must be placed
pdfPage.Contents.Add(New Aspose.Pdf.Operator.ConcatenateMatrix(matrix))
Dim ximage As Aspose.Pdf.XImage = pdfPage.Resources.Images(pdfPage.Resources.Images.Count)
’ Using Do operator: this operator draws image
pdfPage.Contents.Add(New Aspose.Pdf.Operator.Do(ximage.Name))
’ Using GRestore operator: this operator restores graphics state
pdfPage.Contents.Add(New Aspose.Pdf.Operator.GRestore())
imageStream.Close()

next i

pdf.Save(“myfile”)

Hi Mike,


Thanks for sharing information with us.

Best Regards,