CADToPDF exports a blank page

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
EBrown
Posts: 3
Joined: 19 Oct 2012, 01:12

CADToPDF exports a blank page

Post by EBrown » 19 Oct 2012, 02:12

I am using the demo library, but I'm told that it should be fully functional. The code executes without any obvious errors, but the PDF file I get as output is simply a blank file.

My code is this:

Code: Select all

public bool SaveToPDF(string strSrc, string strDest) {
 bool success = false;

 try {
  CADImage img = new CADImage();
  img.UseDoubleBuffering = false;

  img.GraphicsOutMode = DrawGraphicsMode.Export;

  img.LoadFromFile(strSrc);
  img.GetExtents();

  CADImport.Export.CADToPDF c2p = new CADImport.Export.CADToPDF(img);

  if (System.IO.File.Exists(strDest)) File.Delete(strDest);
  c2p.SaveToFile(strDest);
  success = true;
 } catch (Exception ex) {
 }
 return success;
}

Please help? Thanks in advance!
EBrown Posts: 1Joined: 57 minutes ago

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: CADToPDF exports a blank page

Post by support » 19 Oct 2012, 12:14

Hello.
CAD Import .NET provides a set of classes for import different formats. Each class must be used to import corresond format. For example CADImage class provided for import DXF files, DWGImage - for import DWG. An attempt to import file of other than DXF format with your code will result in blank screen visualization. Further export to PDF will generate a blank page.
Generally we recommend to call CADImage.CreateImageByExtension method that creates object of required class for specified file extention.

Code: Select all

 try {
  CADImage img = CADImage.CreateImageByExtension(strSrc);
  img.UseDoubleBuffering = false;
...
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

EBrown
Posts: 3
Joined: 19 Oct 2012, 01:12

Re: CADToPDF exports a blank page

Post by EBrown » 19 Oct 2012, 18:09

Wonderful! That did the trick.

It would be useful if the documentation commented on this being the better way to load an existing file.

Thanks!

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: CADToPDF exports a blank page

Post by support » 22 Oct 2012, 16:58

Hello.
Thank you for the remark, we will take it into account.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply