public void PostDrawingResizeTest(string formatExtension, bool saveResultToStorage, params string[] additionalExportFormats)
        {
            string name      = null;
            int?   newWidth  = 100;
            int?   newHeight = 150;
            string folder    = CloudTestFolder;
            string storage   = DefaultStorage;
            string outName   = null;

            List <string> formatsToExport = new List <string>(this.BasicExportFormats);

            foreach (string additionalExportFormat in additionalExportFormats)
            {
                if (!formatsToExport.Contains(additionalExportFormat))
                {
                    formatsToExport.Add(additionalExportFormat);
                }
            }

            foreach (var inputFile in InputTestFiles)
            {
                if (inputFile.Name.EndsWith(formatExtension))
                {
                    name = inputFile.Name;
                }
                else
                {
                    continue;
                }

                foreach (string format in formatsToExport)
                {
                    outName = $"{name}_resize.{format}";

                    this.TestRawPostRequest(
                        $"input drawing: {name}; Output format: {format}; New width: {newWidth}; New height: {newHeight}",
                        name,
                        outName,
                        saveResultToStorage,
                        delegate(Stream inputStream, string outPath)
                    {
                        var request = new PostDrawingResizeRequest(inputStream, format, newWidth, newHeight, outPath, storage);
                        return(CadApi.PostDrawingResize(request));
                    },
                        folder,
                        storage);

                    break;
                }
            }
        }
Beispiel #2
0
        // Change scale of an image from body
        private void PostImageResize()
        {
            var    cadApi   = new CadApi(AppKey, AppSid);
            string fileName = "910609.dxf";
            // Possible values are jpg, bmp, psd, tiff, gif, png, j2k, wmf and pdf
            string formatToExport = "pdf";
            int?   newWidth       = 100;
            int?   newHeight      = 150;
            string dataFilePath   = Path.Combine(pathToDataDir(), fileName);
            string destFileName   = "910609.pdf";

            var request        = new PostDrawingResizeRequest(File.OpenRead(dataFilePath), formatToExport, newWidth, newHeight, null, null);
            var responseStream = cadApi.PostDrawingResize(request);

            // Save the output file to disk
            saveFileToDisk(responseStream, destFileName);
        }