Page 1 of 1

convert cadimage to pdf

Posted: 05 Nov 2023, 14:38
by Masoud
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");

Re: convert cadimage to pdf

Posted: 08 Nov 2023, 10:26
by support
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.

Re: convert cadimage to pdf

Posted: 09 Nov 2023, 17:43
by Masoud
hello catherina
im building my image with .net framework
my cad.net ver is 14.1.0.47734

Re: convert cadimage to pdf

Posted: 10 Nov 2023, 12:34
by support
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.

Re: convert cadimage to pdf

Posted: 10 Nov 2023, 13:27
by Masoud
Thank you Catherine
Sure
Done
thank you so much
have nice day

Re: convert cadimage to pdf

Posted: 14 Nov 2023, 13:15
by Masoud
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?

Re: convert cadimage to pdf

Posted: 16 Nov 2023, 12:01
by support
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.