for IMAGING-34372, we tried last 2.7.0 version but still we cannot see all dwg layouts in exported images or pdf (see examples in attachment, original dwg viewed with a dwg viewer, and aspose images or pdf export)
so, what’s wrong ?
Hi Valerio,
using (CadImage image = (CadImage)Image.Load(sourceFilePath))
{
CadLayoutDictionary layouts = image.Layouts;
string[] layoutNames = new string[layouts.Count];
int i = 0;
foreach(CadLayout layout in layouts.Values)
{
layoutNames[i++] = layout.LayoutName;
}
//Create an instance of CadRasterizationOptions
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
//Set page width & height
rasterizationOptions.PageWidth = 1200;
rasterizationOptions.PageHeight = 1200;
//Specify a list of layout names
rasterizationOptions.Layouts = layoutNames;
//Create an instance of TiffOptions for the resultant image
ImageOptionsBase options = new TiffOptions();
//Set rasterization options
options.VectorRasterizationOptions = rasterizationOptions;
//Save resultant image
image.Save(myDir + “output.tiff”, options);
}
Hi again,
Ok, thank you for splitting threads.
So, omitting 1.dwg you are investingating and focusing on other 2.dwg, we see two problems.
we tried exporting as png (one layout on one png in a loop on layouts.count) and as PDF with this code:
Aspose.Imaging.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.CadRasterizationOptions();
rasterizationOptions.PageWidth = ((Aspose.Imaging.Image)m_oDocument).Width;
rasterizationOptions.PageHeight = ((Aspose.Imaging.Image)m_oDocument).Height;
rasterizationOptions.BackgroundColor = Aspose.Imaging.Color.White;
rasterizationOptions.DrawColor = Aspose.Imaging.Color.Black;
rasterizationOptions.DrawType = Aspose.Imaging.FileFormats.Cad.CadDrawTypeMode.UseDrawColor;
rasterizationOptions.CenterDrawing = true;
Aspose.Imaging.FileFormats.Cad.CadLayoutDictionary layouts = ((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Layouts;
string[] layoutNames = new string[layouts.Count];
int i = 0;
foreach (Aspose.Imaging.FileFormats.Cad.CadObjects.CadLayout layout in layouts.Values)
{
layoutNames[i++] = layout.LayoutName;
}
//commented
// rasterizationOptions.Layouts = layoutNames;
Aspose.Imaging.ImageOptions.PdfOptions OptionsIP = new Aspose.Imaging.ImageOptions.PdfOptions();
Aspose.Imaging.ResolutionSetting oResIP = new Aspose.Imaging.ResolutionSetting(Convert.ToDouble(m_iResolution), Convert.ToDouble(m_iResolution));
OptionsIP.ResolutionSettings = oResIP;
OptionsIP.VectorRasterizationOptions = rasterizationOptions;
((Aspose.Imaging.Image)m_oDocument).Save(_oOutputStream, OptionsIP);
1
as you can see we comment the line rasterizationOptions.Layouts = layoutNames;
'cause there is some difference passing all the layouts or passing noone (see attachments), in one case we obtain a pdf with page 1 = layout 1 and page 2 = model, in the other case we obtain a pdf with page 1 = model and page 2 = blank page
2
in every cases we lack some items (text) we can see in dwg viewer (see in attachment, model and layout1)
thank you
Hi Valerio,
we cannot say…maybe the difference is in the output on stream?
This is our complete code:
Aspose.Imaging.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.CadRasterizationOptions();
rasterizationOptions.PageWidth = ((Aspose.Imaging.Image)m_oDocument).Width;
rasterizationOptions.PageHeight = ((Aspose.Imaging.Image)m_oDocument).Height;
if (((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Width > ((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Height)
{
if (((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Width > 1024)
{
int iWidth = 1024;
int iHeight = (int)((1024.0f / (float)((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Width) * (float)((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Height);
rasterizationOptions.PageWidth = iWidth;
rasterizationOptions.PageHeight = iHeight;
}
}
else
{
if (((Aspose.Imaging.Image)m_oDocument).Height > 1024)
{
int iHeight = 1024;
int iWidth = (int)((1024.0f / (float)((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Height) * (float)((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Width);
rasterizationOptions.PageWidth = iWidth;
rasterizationOptions.PageHeight = iHeight;
}
}
//imposto i colori per evitare di usare quelli originali (potrei avere linee uguali allo sfondo)
rasterizationOptions.BackgroundColor = Aspose.Imaging.Color.White;
rasterizationOptions.DrawColor = Aspose.Imaging.Color.Black;
rasterizationOptions.DrawType = Aspose.Imaging.FileFormats.Cad.CadDrawTypeMode.UseDrawColor;
rasterizationOptions.CenterDrawing = true;
//nessun layer impostato -> li disegna tutti
// rasterizationOptions.Layers = new List { “layer1” };
// al momento non è possibile sapere in che layout si trovi il disegno intero (assume che sia nel Model)
//foreach (KeyValuePair<string, Aspose.Imaging.FileFormats.Cad.CadObjects.CadLayout> cl in ((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Layouts)
//{
// if (cl.Value.LayoutName.ToLower() != “model”)
// { rasterizationOptions.LayoutName = cl.Value.LayoutName; }
//}
Aspose.Imaging.FileFormats.Cad.CadLayoutDictionary layouts = ((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Layouts;
string[] layoutNames = new string[layouts.Count];
int i = 0;
foreach (Aspose.Imaging.FileFormats.Cad.CadObjects.CadLayout layout in layouts.Values)
{
layoutNames[i++] = layout.LayoutName;
}
//non specifico nessun layout: li disegna tutti, uno per pagina
// rasterizationOptions.Layouts = layoutNames;
Aspose.Imaging.ImageOptions.PdfOptions OptionsIP = new Aspose.Imaging.ImageOptions.PdfOptions();
// OptionsIP.ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.TruecolorWithAlpha;
// OptionsI.TransparentColor = new Aspose.Imaging.TransparentColorSetting(Aspose.Imaging.Color.Transparent);
Aspose.Imaging.ResolutionSetting oResIP = new Aspose.Imaging.ResolutionSetting(Convert.ToDouble(m_iResolution), Convert.ToDouble(m_iResolution));
OptionsIP.ResolutionSettings = oResIP;
OptionsIP.VectorRasterizationOptions = rasterizationOptions;
((Aspose.Imaging.Image)m_oDocument).Save(_oOutputStream, OptionsIP);
with comment on line // rasterizationOptions.Layouts = layoutNames;
it generates a pdf , while uncomment that line the pdf… complete
(in attachment original dwg and the two pdf)
Hi Valerio,
ok thanks
we use this kind of resize in every cases of exporting images or pdf to obtain smaller files
Hi Valerio,
The issues you have found earlier (filed as IMAGING-34582;IMAGING-34581) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
hello, any news about 3d graphics?
concerning your suggestion: it is not our scenario.
Our customers upload some cad files (dwg, dxf…) BUT we cannot say if they are 2d or 3d.
So our use of aspose.imaging has to be intended as reading dwg file and convert it in image(s) and pdf file
So how can we set TypeOfEntities according to the content of file? is it possible to know if a cad file contains or not some 3d layout? is there a possibility to export/print all layouts to a pdf even if the file has 2D and 3D content?
any new about it?
thanks
The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.