Convert AutoCAD DXF to PDF in C# Using Aspose.CAD REST API Results Blank PDF

I’m using .NET Aspose.CAD-Cloud 20.11.0 library for conversion of my .dxf files to PDF with a code:

{
var dxfDocument = SvgDxfConverter.SvgDxfConverter.ConvertSvgStream(dto.data);
dxfDocument.Seek(0, SeekOrigin.Begin);

using Stream result = new CadApi(AppKey, AppSid)
.PostDrawingSaveAs(new PostDrawingSaveAsRequest(dxfDocument, “pdf”));
result.Seek(0, SeekOrigin.Begin);

var sr = new StreamReader(result);
var res = sr.ReadToEnd();
return res;
}

I’m trying to convert different files and always converted files being blank in all PDF readers. Otherwise, the sizes of these files match the sizes of files converted with other online tools (seems like the files are contains information)

@Rodion_Nikolaev

I tried to Convert a DXF to PDF in C# using Aspose.CAD REST API, but unable to notice your reported issue. Please share your source document with us. We will investigate the problem and will share our findings with you.

Steps to Convert AutoCAD DXF to PDF in .NET

  • Create Aspose Cloud account and get credentials to make API requests
  • Create a new Project in Visual Studio and Install Aspose.CAD NuGet package
  • Read source DXF file in a stream
  • Instantiate Aspose.CAD Cloud API object with your credentials
  • Create a PostDrawingSaveAsRequest object
  • Call PostDrawingSaveAs API method of Aspose.CAD REST API to convert DXF to PDF
  • Save PDF to local drive from PostDrawingSaveAs API method response

C# Code of DXF to PDF Converter API

string inputFilePath = @"C:/Temp/Sample.dxf";            
string format = "pdf";
var dxfDocument = File.Open(inputFilePath, FileMode.Open, FileAccess.Read);

// instantiate Aspose.CAD Cloud API 
CadApi cadApi = new CadApi(ClientSecret, ClientId);

// Convert DXF to PDF
var result = cadApi.PostDrawingSaveAs(new PostDrawingSaveAsRequest(dxfDocument, format));

// Donwload output PDF to local drive
var fileStream = System.IO.File.Create("C:/Temp/DXFtoPDF.pdf");
result.CopyTo(fileStream);
fileStream.Close();