convert cadimage to pdf

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
Masoud
Posts: 13
Joined: 25 May 2022, 18:57

convert cadimage to pdf

Post by Masoud » 05 Nov 2023, 14:38

Hello, I am converting the cadimage I designed to dwg. But with the code below, I try to convert it to PDF, but unfortunately my output file is created without error, but it is empty

IsFlowDiagramExportDWG = CADtoDWG.SaveAsDWG(CadImage, Path + "\\" + "flowdiagram.dwg");

CADImage cadImage = CADImage.CreateImageByExtension(Path + "\\" + "flowdiagram.dwg");
cadImage.IsWithoutMargins = true;
cadImage.LoadFromFile(Path + "\\" + "flowdiagram.dwg");
CADToPDF pdf = new CADToPDF(cadImage);
pdf.SaveToFile(Path + "\\" + "flowdiagram.pdf");

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

Re: convert cadimage to pdf

Post by support » 08 Nov 2023, 10:26

Masoud wrote:
05 Nov 2023, 14:38
Hello, I am converting the cadimage I designed to dwg. But with the code below, I try to convert it to PDF, but unfortunately my output file is created without error, but it is empty

IsFlowDiagramExportDWG = CADtoDWG.SaveAsDWG(CadImage, Path + "\\" + "flowdiagram.dwg");

CADImage cadImage = CADImage.CreateImageByExtension(Path + "\\" + "flowdiagram.dwg");
cadImage.IsWithoutMargins = true;
cadImage.LoadFromFile(Path + "\\" + "flowdiagram.dwg");
CADToPDF pdf = new CADToPDF(cadImage);
pdf.SaveToFile(Path + "\\" + "flowdiagram.pdf");
Hello,
What CAD .NET version are you using? Also, do you build your project on .NET Core or .NET Framework?
If it's .NET Core, then it was a known bug with an empty PDF, and it is now fixed in the latest build of CAD .NET.

Best wishes,
Catherine.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Masoud
Posts: 13
Joined: 25 May 2022, 18:57

Re: convert cadimage to pdf

Post by Masoud » 09 Nov 2023, 17:43

hello catherina
im building my image with .net framework
my cad.net ver is 14.1.0.47734

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

Re: convert cadimage to pdf

Post by support » 10 Nov 2023, 12:34

Masoud wrote:
09 Nov 2023, 17:43
hello catherina
im building my image with .net framework
my cad.net ver is 14.1.0.47734
Hello,
Thank you for your reply.
Could you send me the file that you're trying to convert to support@cadsofttools.com? Without the file it is hard to state the issue.
Best wiches,
Catherine.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Masoud
Posts: 13
Joined: 25 May 2022, 18:57

Re: convert cadimage to pdf

Post by Masoud » 10 Nov 2023, 13:27

Thank you Catherine
Sure
Done
thank you so much
have nice day

Masoud
Posts: 13
Joined: 25 May 2022, 18:57

Re: convert cadimage to pdf

Post by Masoud » 14 Nov 2023, 13:15

Hello, thank you for your advice
I was able to get PDF output with these two tasks
First, with the help of these commands:
CADImage cadImage = CADImage.CreateImageByExtension(OutputPath + "\\" + "FlowDiagram.dwg");
cadImage.IsWithoutMargins = true;
cadImage.LoadFromFile(OutputPath + "\\" + "FlowDiagram.dwg");
CADToPDF pdf = new CADToPDF(cadImage);
pdf.SaveToFile(OutputPath + "\\" + "FlowDiagram.pdf");

Second, by changing the version of cadiimport to this version 14.1.0.50682
I contracted this so that users can use it in the future
thank you.

Now I had few quastion
I was able to make the layers black with the help of the following code

for (int i = 0; i < cadImage.CurrentLayout.Entities.Count; i++)
{
cadImage.CurrentLayout.Entities.Layer.Color = Color.Black;
}

But the layers of blocks are still colored
How can I make them black?
And how can I output in landscape mode?
Last edited by Masoud on 14 Nov 2023, 16:23, edited 1 time in total.

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

Re: convert cadimage to pdf

Post by support » 16 Nov 2023, 12:01

Masoud wrote:
14 Nov 2023, 13:15
Hello, thank you for your advice
I was able to get PDF output with these two tasks
First, with the help of these commands:
CADImage cadImage = CADImage.CreateImageByExtension(OutputPath + "\\" + "FlowDiagram.dwg");
cadImage.IsWithoutMargins = true;
cadImage.LoadFromFile(OutputPath + "\\" + "FlowDiagram.dwg");
CADToPDF pdf = new CADToPDF(cadImage);
pdf.SaveToFile(OutputPath + "\\" + "FlowDiagram.pdf");

Second, by changing the version of cadiimport to this version 14.1.0.50682
I contracted this so that users can use it in the future
thank you.

Now I had few quastion
I was able to make the layers black with the help of the following code

for (int i = 0; i < cadImage.CurrentLayout.Entities.Count; i++)
{
cadImage.CurrentLayout.Entities.Layer.Color = Color.Black;
}

But the layers of blocks are still colored
How can I make them black?
And how can I output in landscape mode?


Hello,
To set new values to the entities in a block, you should go into the block and iterate all its entities.
If you just want a black-and-white image, you could do it by using cadImage.DrawMode = CADDrawMode.Black;
(See the Editor demo for the reference)

As for the second question: pdf.Settings has PageHeight, PageWidth.
See https://cadsofttools.ru/help/cadnet/ind ... rs--.html
Best regards,
Catherine.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply