The attached Excel document was first converted to PDF:
// Open the template excel file
Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(inputPath);
// create explicit SaveOptions
Aspose.Cells.PdfSaveOptions pdfSaveOptions = new Aspose.Cells.PdfSaveOptions();
pdfSaveOptions.OnePagePerSheet = true;
pdfSaveOptions.AllColumnsInOnePagePerSheet = true;
pdfSaveOptions.ExportDocumentStructure = true;
pdfSaveOptions.GridlineType = GridlineType.Hair;
foreach (Worksheet worksheet in wb.Worksheets)
{
worksheet.PageSetup.PrintGridlines = false;
}
// Save the pdf file.
wb.Save(outputPath, pdfSaveOptions);
That seems to work OK, see the attached .pdf file. After that I tried to convert the PDF to the 2U pdf format (listBoxFormat.SelectedItem):
// open input Pdf
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(inputPath);
// Convert to different PDF compliant document
// During conversion process, the validation is also performed
PdfFormat myPdfFormat;
if (Enum.TryParse(listBoxFormat.SelectedItem.ToString(), out myPdfFormat))
{
uint value = (uint)myPdfFormat;
}
else { /* error: the string was not an enum member */ }
string logFile = Path.GetFileNameWithoutExtension(inputPath) + "-log.xml";
pdfDocument.Convert(Path.Combine(_outDir, logFile), myPdfFormat, ConvertErrorAction.Delete);
// Save output document
pdfDocument.Save(outputPath);
After waiting for more than 5 minutes, the Save still hasn’t finished, so I have to assume there is an inifinite loop. Can you help here? I’m using Aspose libraries 22.2.
docs.zip (7.8 MB)