Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Console Application Converting PPTX,Docx to PDF in sharepoint 2013 using Service Applications.

$
0
0

Hi,

Need help to resolve below issues.

While converting PPTX to PDF using Powerpoint Service, am getting Error: AsyncResult operation exceeded timeout of 00:05:00

While converting DOCX to PDF Using Word Automation service, am getting Error :The file could not converted due to an intermitt error in the system.Please resubmit this file for conversion.

Environment Setup Details: 1) Single server along with local AD like staging server, 2)Office is not installed SharePoint server 2013 with SP1, SQL SERVER 2012 & Windows Sever 2012 R2.

Convertion Code PPTX TO PDF Using console Application:

Microsoft.Office.Server.PowerPoint.Conversion.FixedFormatSettings settings = new Microsoft.Office.Server.PowerPoint.Conversion.FixedFormatSettings();
settings.BitmapUnembeddableFonts = true;
 settings.FrameSlides = true;
settings.IncludeDocumentProperties = true;
settings.IncludeDocumentStructureTags = true;
settings.IncludeHiddenSlides = true;
settings.OptimizeForMinimumSize = true;
settings.UsePdfA = true;
settings.UseVerticalOrder = true;
PdfRequest request = new PdfRequest(updatedItem.File.OpenBinaryStream(), Constants.dotExtension + templateFileFormat, settings, pdfStream);

 IAsyncResult result = request.BeginConvert(SPServiceContext.GetContext(imSite), null, null);

request.EndConvert(result);
var pdffileName = Path.GetFileNameWithoutExtension(templateItem.File.Name) +Constants.pdfExtension;
SPFile pdfFile = pdfDestinationLibrary.RootFolder.Files.Add(pdffileName, pdfStream, true);
pdfDestinationLibrary.Update();

Code for Converting Docx to PDF Using Console Application :

                                                    

 SyncConverter sc = new SyncConverter(wordAutomationService);
 sc.UserToken = imWeb.CurrentUser.UserToken;
  sc.Settings.UpdateFields = true;
sc.Settings.OutputFormat = SaveFormat.PDF;
ConversionItemInfo info = sc.Convert(updatedItem.File.OpenBinaryStream(), pdfStream);
var filename = Path.GetFileNameWithoutExtension(templateItem.File.Name) + Constants.pdfExtension;
if (info.Succeeded)
{  SPFile newfile = pdfDestinationLibrary.RootFolder.Files.Add(filename, pdfStream, true);  }
 else if (info.Failed){ Console.WriteLine(info.ErrorMessage.ToString());
 Console.ReadLine();
  SPDiagnosticsCategory myCat = new SPDiagnosticsCategory(Constants.TimerJobTitle, TraceSeverity.High, EventSeverity.ErrorCritical);
 SPDiagnosticsService.Local.WriteEvent(9, myCat, EventSeverity.Error, "While Convert pdf from PPTx file", info.ErrorMessage);

}

Thanks In Advance.

Murali Krishna T


 



Murali Krishna.T



Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>