public static cConversionResult ConvertFile(string drawingName, string polygonID) { cConversionResult ConversionResult = new cConversionResult(); string URL = null; try { URL = string.Format(ExportSettings.ApertureWebServiceUrl111, drawingName, polygonID); // string RemoteURL = "https://www9.cor-asp.ch/ApWebServices/ApDrawingPDFs.aspx?p=SwisscomTest_Portal&d={0}&L=Z_Export&S=Z_Export"; // string LocalURL = "http://vm-wincasa/ApWebServices/ApDrawingPDFs.aspx?p=Swisscom_Portal&d={0}&L=Z_Export&S=Z_Export"; //baReturnValue = DownloadPdf("https://www9.cor-asp.ch/ApWebServices/ApDrawingPDFs.aspx?p=SwisscomTest_Portal&d=1002_GB01_OG01_0000&L=Z_Export"); //baReturnValue = DownloadPdf("http://vm-wincasa/ApWebServices/ApDrawingPDFs.aspx?p=Swisscom_Portal&d=1002_GB01_OG01_0000&L=Z_Export"); //baReturnValue = DownloadPdf("http://vm-wincasa/ApWebServices/ApDrawingPDFs.aspx?p=Swisscom_Portal&d=1010_GB01_UG02_0000&L=Z_Export"); // http://vm-wincasa/ApWebServices/ApDrawingPDFs.aspx?p=Swisscom_Portal&d=1010_GB01_UG02_0000&L=Z_Export&S=Z_Export ConversionResult.PDF = DownloadPdf(URL); } catch (System.Net.WebException we) { System.Console.WriteLine(we.Message); } catch (System.Exception ex) { System.Console.WriteLine(ex.Message); } #if WITH_ASPOSE string temporaryOutFileName = System.IO.Path.GetTempFileName(); using (System.IO.Stream ms = new System.IO.MemoryStream(ConversionResult.PDF)) { // using (Aspose.Pdf.Document doc = new Aspose.Pdf.Document(@"dwg17.pdf")) using (Aspose.Pdf.Document doc = new Aspose.Pdf.Document(ms)) { Aspose.Pdf.SvgSaveOptions saveOptions = new Aspose.Pdf.SvgSaveOptions(); // do not compress SVG image to Zip archive saveOptions.CompressOutputToZipArchive = false; doc.Save(temporaryOutFileName, saveOptions); } // End Using doc ms.Close(); } // End Using ms ConversionResult.SVG = RemoveEvalString(temporaryOutFileName, URL); if (System.IO.File.Exists(temporaryOutFileName)) { System.IO.File.Delete(temporaryOutFileName); } #endif return(ConversionResult); } // End Function ConvertFile
///<Summary> /// ConvertPdfToSVG to convert PDF to SVG ///</Summary> public Response ConvertPdfToSVG(string fileName, string folderName, string userEmail) { return(ProcessTask(fileName, folderName, ".svg", true, userEmail, true, delegate(string inFilePath, string outPath, string zipOutFolder) { // Load PDF document Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(inFilePath); // Instantiate an object of SvgSaveOptions Aspose.Pdf.SvgSaveOptions saveOptions = new Aspose.Pdf.SvgSaveOptions(); // Do not compress SVG image to Zip archive saveOptions.CompressOutputToZipArchive = false; string outfileName = Path.GetFileNameWithoutExtension(fileName) + "_{0}"; int pageCount = 0; int totalPages = pdfDocument.Pages.Count; // Loop through all the pages foreach (Aspose.Pdf.Page pdfPage in pdfDocument.Pages) { if (totalPages > 1) { outPath = zipOutFolder + "/" + outfileName; outPath = string.Format(outPath, pageCount + 1); } else { outPath = zipOutFolder + "/" + Path.GetFileNameWithoutExtension(fileName); } Aspose.Pdf.Document newDocument = new Aspose.Pdf.Document(); newDocument.Pages.Add(pdfPage); newDocument.Save(outPath + ".svg", saveOptions); pageCount++; } })); }