private static Stream ToStream(SvgDocument svgDocument, bool gzip) { var ms = new MemoryStream(); var svgSaveOptions = new SvgSaveOptions(); if (gzip) { using (var compressed = new GZipStream(ms, CompressionMode.Compress, true)) { // unfortunately svgDocument.SaveToStream wants to read the stream current position // and GZipStream.Position is not supported // svgDocument.SaveToStream(compressed, new SvgSaveOptions() { }); // Save to a temp stream first using (var tempStream = new MemoryStream()) { svgDocument.SaveToStream(tempStream, svgSaveOptions); tempStream.Position = 0; ServiceHelper.CopyStream(tempStream, compressed); } } } else { svgDocument.SaveToStream(ms, svgSaveOptions); } ms.Position = 0; return(ms); }
public void CheckThatAllMethodsArePresent() { HtmlFixedSaveOptions htmlFixedSaveOptions = new HtmlFixedSaveOptions(); htmlFixedSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback(); ImageSaveOptions imageSaveOptions = new ImageSaveOptions(SaveFormat.Png); imageSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback(); PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(); pdfSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback(); PsSaveOptions psSaveOptions = new PsSaveOptions(); psSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback(); SvgSaveOptions svgSaveOptions = new SvgSaveOptions(); svgSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback(); XamlFixedSaveOptions xamlFixedSaveOptions = new XamlFixedSaveOptions(); xamlFixedSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback(); XpsSaveOptions xpsSaveOptions = new XpsSaveOptions(); xpsSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback(); }
public void CheckThatAllMethodsArePresent() { HtmlFixedSaveOptions htmlFixedSaveOptions = new HtmlFixedSaveOptions(); htmlFixedSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback(); ImageSaveOptions imageSaveOptions = new ImageSaveOptions(SaveFormat.Png); imageSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback(); PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(); pdfSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback(); PsSaveOptions psSaveOptions = new PsSaveOptions(); psSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback(); SvgSaveOptions svgSaveOptions = new SvgSaveOptions(); svgSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback(); SwfSaveOptions swfSaveOptions = new SwfSaveOptions(); swfSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback(); XamlFixedSaveOptions xamlFixedSaveOptions = new XamlFixedSaveOptions(); xamlFixedSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback(); XpsSaveOptions xpsSaveOptions = new XpsSaveOptions(); xpsSaveOptions.PageSavingCallback = new CustomPageFileNamePageSavingCallback(); }
public static void Run() { // ExStart:PDFToSVG // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion(); // Load PDF document Document doc = new Document(dataDir + "input.pdf"); // Instantiate an object of SvgSaveOptions SvgSaveOptions saveOptions = new SvgSaveOptions(); // Do not compress SVG image to Zip archive saveOptions.CompressOutputToZipArchive = false; // Save the output in SVG files doc.Save(dataDir + "PDFToSVG_out.svg", saveOptions); // ExEnd:PDFToSVG }
public static void Run() { // ExStart:PDFToSVG // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion(); // Load PDF document Document doc = new Document(dataDir + "input.pdf"); // Instantiate an object of SvgSaveOptions SvgSaveOptions saveOptions = new SvgSaveOptions(); // Do not compress SVG image to Zip archive saveOptions.CompressOutputToZipArchive = false; // Save the output in SVG files doc.Save(dataDir + "PDFToSVG_out_.svg", saveOptions); // ExEnd:PDFToSVG }
[Test] //ExSkip public void SvgResourceFolder() { Document doc = new Document(MyDir + "Rendering.docx"); SvgSaveOptions options = new SvgSaveOptions { SaveFormat = SaveFormat.Svg, ExportEmbeddedImages = false, ResourcesFolder = ArtifactsDir + "SvgResourceFolder", ResourcesFolderAlias = ArtifactsDir + "SvgResourceFolderAlias", ShowPageBorder = false, ResourceSavingCallback = new ResourceUriPrinter() }; Directory.CreateDirectory(options.ResourcesFolderAlias); doc.Save(ArtifactsDir + "SvgSaveOptions.SvgResourceFolder.svg", options); }
public void SaveLikeImage() { //ExStart //ExFor:SvgSaveOptions.FitToViewPort //ExFor:SvgSaveOptions.ShowPageBorder //ExFor:SvgSaveOptions.TextOutputMode //ExFor:SvgTextOutputMode //ExSummary:Shows how to mimic the properties of images when converting a .docx document to .svg. Document doc = new Document(MyDir + "Document.docx"); // Configure the SvgSaveOptions object to save with no page borders or selectable text. SvgSaveOptions options = new SvgSaveOptions { FitToViewPort = true, ShowPageBorder = false, TextOutputMode = SvgTextOutputMode.UsePlacedGlyphs }; doc.Save(ArtifactsDir + "SvgSaveOptions.SaveLikeImage.svg", options); //ExEnd }