/// <summary> /// Render a document in PDF Form /// </summary> /// <param name="DocumentName"></param> public static void RenderDocumentAsPDF(String DocumentName) { //ExStart:RenderAsPdf // Create/initialize image handler ViewerImageHandler imageHandler = new ViewerImageHandler(Utilities.GetConfigurations()); //Initialize PdfFileOptions object PdfFileOptions options = new PdfFileOptions(); // Call GetPdfFile to get FileContainer type object which contains the stream of pdf file. FileContainer container = imageHandler.GetPdfFile(DocumentName, options); //Change the extension of the file and assign to a string type variable filename String filename = Path.GetFileNameWithoutExtension(DocumentName) + ".pdf"; //Save each image at disk Utilities.SaveFile(filename, container.Stream); //ExEnd:RenderAsPdf }
/// <summary> /// Multiple pages per sheet /// </summary> /// <param name="DocumentName"></param> public static void RenderMultiExcelSheetsInOnePage(String DocumentName) { // Setup GroupDocs.Viewer config ViewerConfig config = Utilities.GetConfigurations(); // Create image or html handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); string guid = DocumentName; // Set pdf file one page per sheet option to false, default value of this option is true PdfFileOptions pdfFileOptions = new PdfFileOptions(); pdfFileOptions.Guid = guid; pdfFileOptions.CellsOptions.OnePagePerSheet = false; //Get pdf file FileContainer fileContainer = imageHandler.GetPdfFile(pdfFileOptions); Utilities.SaveFile("test.pdf", fileContainer.Stream); }
/// <summary> /// Get original file in Pdf format /// </summary> public static void Run() { Console.WriteLine("***** {0} *****", "Get original file in Pdf format"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); PdfFileOptions options = new PdfFileOptions(); options.Guid = "word.doc"; // Get file as pdf FileContainer container = imageHandler.GetPdfFile(options); Console.WriteLine("Stream lenght: {0}", container.Stream.Length); }
public static void Run() { // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image or html handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); string guid = "document.xlsx"; // Set pdf file one page per sheet option to false, default value of this option is true PdfFileOptions pdfFileOptions = new PdfFileOptions(); pdfFileOptions.Guid = guid; pdfFileOptions.CellsOptions.OnePagePerSheet = false; //Get pdf file FileContainer fileContainer = imageHandler.GetPdfFile(pdfFileOptions); //The pdf file stream Stream pdfStream = fileContainer.Stream; }