static void Main(string[] args) { using (MemoryStream ms = new MemoryStream()) { ImportLicense(); var folderFontSource = new FolderFontSource("./fonts", true); var fontSettings = new FontSettings(); fontSettings.SetFontsSources(new FontSourceBase[] { new SystemFontSource(), folderFontSource }); var loadOptions = new LoadOptions { FontSettings = fontSettings }; var wrdf = new Aspose.Words.Document("./input.html", loadOptions); var Dir = "./output/"; if (Directory.Exists(Dir)) { Directory.Delete(Dir, true); } Aspose.Words.Saving.PdfSaveOptions pdfSaveOptions = new Aspose.Words.Saving.PdfSaveOptions { FontEmbeddingMode = Aspose.Words.Saving.PdfFontEmbeddingMode.EmbedAll }; wrdf.Save(Dir + "output.pdf", pdfSaveOptions); wrdf.Save(Dir + "output.jpeg", Aspose.Words.SaveFormat.Jpeg); wrdf.Save(Dir + "output.html", Aspose.Words.SaveFormat.Html); wrdf.Save(Dir + "output.docx", Aspose.Words.SaveFormat.Docx); } }
public override bool Convert(string sourceFilePath, string targetPdfPath) { var doc = new Aspose.Words.Document(sourceFilePath); Aspose.Words.Saving.PdfSaveOptions saveOptions = new Aspose.Words.Saving.PdfSaveOptions(); saveOptions.OutlineOptions.HeadingsOutlineLevels = 3; doc.Save(targetPdfPath, saveOptions); return(File.Exists(targetPdfPath) && new FileInfo(targetPdfPath).Length > 0); }
private static void ConvertWordToPdfa(string fileToConvert, string destination) { var doc = new Aspose.Words.Document(fileToConvert); FontSettings.DefaultInstance.SetFontsFolder("/usr/share/fonts", true); FontSettings.DefaultInstance.SubstitutionSettings.DefaultFontSubstitution.DefaultFontName = "Arial"; var options = new Aspose.Words.Saving.PdfSaveOptions { SaveFormat = Aspose.Words.SaveFormat.Pdf, Compliance = Aspose.Words.Saving.PdfCompliance.PdfA1b, ExportDocumentStructure = true // This will include Structured Document Tags (SDT) in the PDF. }; doc.Save(destination, options); }
/// <summary> /// 将excel 转化成对应的pdf文件 /// </summary> /// <param name="soursefilepath">源文件地址</param> /// <param name="outpdfpath">目表文件地址</param> /// <returns></returns> public static bool GetPdfFromExcel(string soursefilepath, string outpdfpath) { try { using (System.IO.Stream stream = new System.IO.FileStream(soursefilepath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { Aspose.Cells.Workbook workbook = new Workbook(stream); Aspose.Words.Saving.PdfSaveOptions pdfSaveOptions = new Aspose.Words.Saving.PdfSaveOptions(); pdfSaveOptions.Compliance = Aspose.Words.Saving.PdfCompliance.PdfA1b; workbook.Save(outpdfpath, Aspose.Cells.SaveFormat.Pdf); return(true); } } catch (Exception ex) { return(false); } }
/// <summary> /// Genera una plantilla con el formato para las firmas. /// </summary> /// <param name="instancia">Documento de instancia.</param> /// <param name="plantilla">Plantilla de la taxonomía.</param> /// <param name="idioma">Idioma utilizado.</param> /// <returns>Flujo con el PDF para las fimras.</returns> public Stream GeneraDocumentoFirmasArticulo13(DocumentoInstanciaXbrlDto instancia, IDefinicionPlantillaXbrl plantilla, String idioma = "es") { var documento = new Aspose.Words.Document(); var builder = new DocumentBuilder(documento); var estructuraReporte = new ReporteXBRLDTO() { Instancia = instancia, Plantilla = plantilla, Lenguaje = idioma }; PintaCamposTablaFirmaArticulo13(builder, estructuraReporte); var streamSalida = new MemoryStream(); var savePdf = new Aspose.Words.Saving.PdfSaveOptions() { UseHighQualityRendering = true }; documento.Save(streamSalida, SaveFormat.Docx); return(streamSalida); }
public static void Run() { // ExStart:SaveEmailAsPDF // The path to the File directory string dataDir = RunExamples.GetDataDir_KnowledgeBase(); MailMessage mailMsg = MailMessage.Load(dataDir + "message3.msg"); MemoryStream ms = new MemoryStream(); mailMsg.Save(ms, Aspose.Email.SaveOptions.DefaultMhtml); // create an instance of LoadOptions and set the LoadFormat to Mhtml var loadOptions = new Aspose.Words.LoadOptions(); loadOptions.LoadFormat = LoadFormat.Mhtml; // create an instance of Document and load the MTHML from MemoryStream var document = new Aspose.Words.Document(ms, loadOptions); // create an instance of HtmlSaveOptions and set the SaveFormat to Html var saveOptions = new Aspose.Words.Saving.PdfSaveOptions(); document.Save(dataDir + "SaveEmailAsPDF_out.pdf", saveOptions); // ExEnd:SaveEmailAsPDF }