We have a PowerPoint presentation with several text boxes that aren’t converting correctly to PDF. In some cases, the text wraps and displays outside the bounding box.
I’ve attached both the PowerPoint and the converted PDF for your review. If you compare the two, you’ll notice the issue with the text box content in the PDF.
Additionally, we need to add spacing around the borders of these PowerPoint files before conversion. I’ve included the code that handles the conversion and adds the border below.
public static void ConvertPresentationToPdf(bool adjust_border, string inputFile, string outputFile)
{
string results = String.Empty;
try
{
using (Presentation presentation = new Presentation(inputFile))
{
PdfOptions saveOptions = new PdfOptions
{
EmbedFullFonts = true // Embed all fonts in the PDF
};
presentation.Save(outputFile, Aspose.Slides.Export.SaveFormat.Pdf, saveOptions);
results = "SUCCESS";
}
if (adjust_border)
{
using (Document pdfDocument = new Document(outputFile))
{
//One inch is equal to 72 points
double horizontalPadding = (.3 * 72); // (new width - old width) / 2
double verticalPadding = (.3 * 72); // (new height - old height) / 2
// Iterate through all the pages
foreach (Page page in pdfDocument.Pages)
{
// Adjust the MediaBox and CropBox
page.MediaBox = new Rectangle(
page.MediaBox.LLX - horizontalPadding,
page.MediaBox.LLY - verticalPadding,
page.MediaBox.URX + horizontalPadding,
page.MediaBox.URY + verticalPadding
);
page.CropBox = new Rectangle(
page.CropBox.LLX - horizontalPadding,
page.CropBox.LLY - verticalPadding,
page.CropBox.URX + horizontalPadding,
page.CropBox.URY + verticalPadding
);
// Move the content to center it on the new page size
// By default, content will appear centered due to equal padding
}
// Save the updated PDF document
pdfDocument.Save(outputFile);
results = "SUCCESS";
}
}
Console.WriteLine(results);
}
catch (Exception ex)
{
Console.WriteLine($"Failure|{ex.Message}");
}
return;
}
Do you have any suggestions on how we can resolve this issue?
Thank you for your help!
Aspose-graphic_aid.pdf (3.6 MB)
Aspose-graphic_aid.zip (3.6 MB)