ok, i can test it but we prefer to wait for resolution of IMAGING-34285 and/or some other way to create pdf from dwg, respecting original dimension.
we hope for a better solution than looping for every row of every image in every pages of pdf files it’s quite inefficient in our scenario.
by the way: can be possible to have same way for dwg files as - for example - jpg or tiff files?
for jpg files we convert to png and then insert into aspose.pdf and resulting pdf has no white space.
for dwg we only can direcly save as pdf but we have to deal with white spaces… as i said, if there are no system different from reading every lines of every images, we’ll wait for the resolution of imaging issue.
Thank’s for your diligence
Hi,
Please find below the updates for the tickets attached to this thread.
- IMAGING-34275 (CAD to Raster Image Conversion): We will try our best to provide the requested feature with the upcoming release of Aspose.Imaging for .NET 2.6.0, that is scheduled for the 1st quarter of September 2014. As soon as the feature is available for public use, you will be automatically notified.
- IMAGING-34281 (PDF seems to be blank when page dimension is too large): Upon thorough investigation, we have concluded that the presented behavior is actually not a bug of Aspose.Imaging API, rather a limitation of Acrobat Reader. It seems that Acrobat Reader cannot render a PDF page of large dimensions such as 24325 x 24325. However, other PDF viewers such as Foxit Reader, Nitro Reader, Sumatra Reader and PS_view reader which comes with LATEX distribution can render such PDF files just fine. Even the built-in PDF viewer of Opera browser can display the contents correctly. A few snapshots are attached here for your reference.
- IMAGING-34285 (PDF seems to be blank when large DWG is rendered to smaller canvas with ScaleType.GrowToFit): As you may see that the PdfOptions configurations are wrong for this scenario. The ScaleType.GrowToFit should be used in cases where DWG dimensions are smaller as compared to the rendering canvas in order to to scale the drawing accordingly. If the scenario is opposite the ScaleType.ShrinkToFit should be configured to get desired results. Current implementation of Aspose.Imaging API silently ignores the illegal configurations as discussed above, and produces a blank PDF as a result. We will enhance the module with future releases of Aspose.Imaging API to throw appropriate exception(s) for such scenarios.
- IMAGING-34286 (Support for textual contents in the DWG drawings for rendering to PDF): As discussed earlier, you can render the textual contents with the help of PdfOptions.LayoutName property. We will close this ticket as it has served its purpose. In case you require enhancements to this feature, we can log separate incident(s).
Regarding your recent concerns, we are not sure of your exact requirement so please elaborate your question for better understanding. If you wish to render the DWG files to raster images till the time IMAGING-34275 is resolved, we suggest you to use the Aspose.Pdf for .NET API in collaboration with Aspose.Imaging for .NET as discussed here. Please check the following links for your reference.
As i can see, only Nitro shows dwg real files without borders!
That said, as we mentioned we need to
Aspose.Imaging.ImageOptions.PngOptions has no options like Aspose.Imaging.ImageOptions.PdfOptions
We need the same as pdfOption:
PngOption.DrawType = Aspose.Imaging.FileFormats.Cad.CadDrawTypeMode.UseDrawColor
OptionsI.LayoutName = szLayouts[1]; (the text layout from dwg)
Thank’s
Hi Valerio,
Boole Server:As i can see, only Nitro shows dwg real files without borders
Foxit is also rendering the drawing centered without cutting it off from the right side. Whereas, a few viewers are not showing the right most drawing margin. The problem could be due to the reason that PdfOptions.CenterDrawing property not working as expected at the moment. We have logged an investigative ticket (IMAGING-34293) to look further into this matter, and to provide a fix for it.
Boole Server:That said, as we mentioned we need toSo please, insert in IMAGING-34275 other options, nowadays lacking (or open another request)go over these problems, converting first DWG/DXF files to PNG images and then from PNG to PDF files.
Aspose.Imaging.ImageOptions.PngOptions has no options like Aspose.Imaging.ImageOptions.PdfOptions
We need the same as pdfOption:
PngOption.DrawType = Aspose.Imaging.FileFormats.Cad.CadDrawTypeMode.UseDrawColor
OptionsI.LayoutName = szLayouts[1]; (the text layout from dwg)
As the requested feature (CAD to Raster Image Conversion) would be generic for all raster image formats so mostly likely the options/properties would be made available for the base class of PngOptions.
We have recorded your concerns to the related ticket, and we will discuss the matter internally to bring updates in this regard.
Ok thank you
Please let me informet about any news of resolution of IMAGING-34275 and IMAGING-34293
Hi Valerio,
Hello, we are trying to use new imaging 2.6.0 but we cannot see any difference!
what’s wrong?
Again exeption “cannot export non raster image” and in Aspose.Imaging.ImageOptions.PngOptions we cannot find “LayoutName” and “DrawType” (as in Aspose.Imaging.ImageOptions.PdfOptions)
We need to export original dwg file in png and then from png to pdf
This is our code:
Aspose.Imaging.ImageOptions.PngOptions OptionsI = new Aspose.Imaging.ImageOptions.PngOptions();
OptionsI.ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.TruecolorWithAlpha;
OptionsI.TransparentColor = new Aspose.Imaging.TransparentColorSetting(Aspose.Imaging.Color.Transparent);
Aspose.Imaging.ResolutionSetting oResI = new Aspose.Imaging.ResolutionSetting(Convert.ToDouble(m_iResolution), Convert.ToDouble(m_iResolution));
OptionsI.ResolutionSettings = oResI;
((Aspose.Imaging.Image)m_oDocument).Save(_oOutputStream, OptionsI);
again, we need to solve the exeption {“Cannot export non-raster images.”} and we need final png export WITH same options we see in PDFoptions:
string[] szLayouts = new string[((Aspose.Imaging.FileFormats.Cad.CadImage)((Aspose.Imaging.Image)m_oDocument)).Layouts.Keys.Count];
((Aspose.Imaging.FileFormats.Cad.CadImage)((Aspose.Imaging.Image)m_oDocument)).Layouts.Keys.CopyTo(szLayouts, 0);
OptionsIP.LayoutName = szLayouts[1];
OptionsIP.DrawType = Aspose.Imaging.FileFormats.Cad.CadDrawTypeMode.UseDrawColor;
Please give us some solution, now we need to solve in a short time.
Original dwg file again attached - Thank you
ps moreover in imaging 2.6.0 dll seems to be missing some Aspose.Imaging.ImageOptions.PdfOptions
as PageWidth, PageHeight, LayoutName, DrawType…
mayube they moved? where? OptionsIP.CorePdfOptions.PageHeight as example is in a read only “position”
Hi Valerio,
Thank you for testing the new release of Aspose.Imaging for .NET 2.6.0.
Please use the following piece of code to convert the DWG drawings to raster image formats.
C#
string sourceFilePath = myDir + “office.dwg”;
using (Image image = Image.Load(sourceFilePath))
{
//Create an instance of CadRasterizationOptions
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
//Set page width & height
rasterizationOptions.PageWidth = 1600;
rasterizationOptions.PageHeight = 1200;
//Center the drawing
rasterizationOptions.CenterDrawing = true;
//Create an instance of PngOptions for the resultant image
ImageOptionsBase options = new PngOptions();
//Set rasterization options
options.VectorRasterizationOptions = rasterizationOptions;
//Save resultant image
image.Save(myDir + "output.png", options);
}
Please note, with latest revision of Aspose.Imaging for .NET API, several of the PdfOptions properties have been moved to the new VectorRasterizationOptions and CadRasterizationOptions classes. Please go through the Public API Changes in Aspose.Imaging 2.6.0 for the future reference.
Hi,
we tried this new code but we experience some problems: basically PNG file result completely white or with some little regions draw.
You can see in the attachments original test file, image printed from a CAD viewer (representing real original image), and the two files exported with Aspose (png and PDF).
The C# code we used is this:
Aspose.Imaging.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.CadRasterizationOptions();
rasterizationOptions.BackgroundColor = Aspose.Imaging.Color.Black;
//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;
}
}
rasterizationOptions.DrawColor = Aspose.Imaging.Color.White;
rasterizationOptions.DrawType = Aspose.Imaging.FileFormats.Cad.CadDrawTypeMode.UseDrawColor;
rasterizationOptions.Layers = new List { "layer1" };
rasterizationOptions.LayoutName = "layout1";
Aspose.Imaging.ImageOptions.PngOptions OptionsI = new Aspose.Imaging.ImageOptions.PngOptions();
OptionsI.ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.TruecolorWithAlpha;
OptionsI.TransparentColor = new Aspose.Imaging.TransparentColorSetting(Aspose.Imaging.Color.Transparent);
Aspose.Imaging.ResolutionSetting oResI = new Aspose.Imaging.ResolutionSetting(Convert.ToDouble(m_iResolution), Convert.ToDouble(m_iResolution));
OptionsI.ResolutionSettings = oResI;
OptionsI.VectorRasterizationOptions = rasterizationOptions;
((Aspose.Imaging.Image)m_oDocument).Save(_oOutputStream, OptionsI);
as you can see we tried to change background colors or draw colors, excluding text layer and so on but we can obtain only a white image or a black image.
with pdf export, even if is the same code, we obtain a partial file with some drawings (but not all and none of text layer )
The real file contains drawings and text (over draw layer and in the right part box).
This is the first (and the one) problem: a second problem is document resizing lack in Aspose.Imaging.FileFormats.Cad.CadImage class
we use this code for all type of images (works for all images):
m_oDocument = Aspose.Imaging.Image.Load(_oInputStream);
m_iPageCount = 1;
//resize
if (((Aspose.Imaging.Image)m_oDocument).Width > ((Aspose.Imaging.Image)m_oDocument).Height)
{
if (((Aspose.Imaging.Image)m_oDocument).Width > 1024)
{
int iWidth = 1024;
int iHeight = (int)((1024.0f / (float)((Aspose.Imaging.Image)m_oDocument).Width) * (float)((Aspose.Imaging.Image)m_oDocument).Height);
((Aspose.Imaging.Image)m_oDocument).Resize(iWidth, iHeight, Aspose.Imaging.ResizeType.NearestNeighbourResample);
}
}
else
{
if (((Aspose.Imaging.Image)m_oDocument).Height > 1024)
{
int iHeight = 1024;
int iWidth = (int)((1024.0f / (float)((Aspose.Imaging.Image)m_oDocument).Height) * (float)((Aspose.Imaging.Image)m_oDocument).Width);
((Aspose.Imaging.Image)m_oDocument).Resize(iWidth, iHeight, Aspose.Imaging.ResizeType.NearestNeighbourResample);
}
}
but if we use for dwg files, like this:
m_oDocument = (Aspose.Imaging.FileFormats.Cad.CadImage)Aspose.Imaging.Image.Load(_oInputStream);
m_iPageCount = 1;
//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);
// ((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Resize(iWidth, iHeight, Aspose.Imaging.ResizeType.NearestNeighbourResample);
// }
//}
//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);
// ((Aspose.Imaging.FileFormats.Cad.CadImage)m_oDocument).Resize(iWidth, iHeight, Aspose.Imaging.ResizeType.NearestNeighbourResample);
// }
//}
the instruction .Resize throw in an Exeption “method not implemented”
Why and how we can solve? Maybe it is related with first problem?
We solved moving that code in the method (above) that exports DWG to PNG but, as we said, resulting image is completely white (or black or other background color)
Can you try our code and our test Dwg file and give us correct solution to obtain a complete png (and pdf) file like the example file we attached (that represent what we see opening with a DWG viewer)?
Thank you
The issues you have found earlier (filed as IMAGING-34275;IMAGING-34293) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
Hi Valerio,
- If you are not sure what layer represents what part of the drawing, you shouldn’t be setting the CadRasterizationOptions.Layer property as doing so may result in unexpected outcome.
- CadRasterizationOptions.LayoutName property is case sensitive so make sure you are referring to the correct layout name.
rasterizationOptions.BackgroundColor = Aspose.Imaging.Color.Black;
rasterizationOptions.DrawColor = Aspose.Imaging.Color.White;
rasterizationOptions.DrawType = Aspose.Imaging.FileFormats.Cad.CadDrawTypeMode.UseDrawColor;
rasterizationOptions.CenterDrawing = true;
rasterizationOptions.LayoutName = “Layout1”;
Let me see if we got it: in a generally working application we can’t know what kind of cad files we manage, so we don’t use the CadRasterizationOptions.Layer property and use ever rasterizationOptions.LayoutName = "Layout1"
Is it a right approach?
We need to represent all files our customer upload, we need a general solution, so LayoutName will be “Layout1” for every file or there is some method to estabilish correct name when opening original file with Aspose? Same question about vaious layers cad file could have: we need to represent ever all file’s layers, so don’t specify any layer will draw every layers?
In this approach is there a way to know background of the original cad object, so to apply it accordingly?
Is there some way to save in one image every possible layers we found in Layouts original document?
Thank you for clear our doubts
our need to resize cad object is the same need we for all other image types we treat with Aspose: in case images have some big dimension we resize for web use and we obtain smaller object to convert in images and pdf
Cad class is a part of aspose.imaging classes so we think to use the same Resize method we are using for other images
We are trying to export dwg sample files found in this site:
AutoCAD Sample Files
Aspose seems to can’t load Autocad 2010 sample files: it thrown in exeption “object out of range”
and Autocad 2011 sample files seems to be pretty empty: we can see three layouts (model, layout1, layout2) and print separately but they don’t represent the entire file(s) we can see with a dwg viewer
What is the problem with these files and how we can write a code with aspose can render the majority of dwg files completely?
Boole Server:Let me see if we got it: in a generally working application we can't know what kind of cad files we manage, so we don't use the CadRasterizationOptions.Layer property and use ever rasterizationOptions.LayoutName = "Layout1"
Is it a right approach?
Boole Server:We need to represent all files our customer upload, we need a general solution, so LayoutName will be "Layout1" for every file or there is some method to estabilish correct name when opening original file with Aspose?
Boole Server:Same question about vaious layers cad file could have: we need to represent ever all file's layers, so don't specify any layer will draw every layers?
Boole Server:In this approach is there a way to know background of the original cad object, so to apply it accordingly?
Boole Server:Is there some way to save in one image every possible layers we found in Layouts original document?
Boole Server:our need to resize cad object is the same need we for all other image types we treat with Aspose: in case images have some big dimension we resize for web use and we obtain smaller object to convert in images and pdfCad class is a part of aspose.imaging classes so we think to use the same Resize method we are using for other images
You are seeing CadImage.Resize method because this method has been implemented for the base class Image that corresponds to all image objects. We haven't yet provided the implementation specifically for CadImage class because it is complex feature, and we may take some time to provide it.I have tried to address all your concerns. In case I have missed anything or you have further questions for us, please feel free to write back.
Boole Server:We are trying to export dwg sample files found in this site:
http://knowledge.autodesk.com/support/autocad/downloads/caas/downloads/content/autocad-sample-files.html
Aspose seems to can't load Autocad 2010 sample files: it thrown in exeption "object out of range"
and Autocad 2011 sample files seems to be pretty empty: we can see three layouts (model, layout1, layout2) and print separately but they don't represent the entire file(s) we can see with a dwg viewer
What is the problem with these files and how we can write a code with aspose can render the majority of dwg files completely?
Hi, basically our request is to have a conversion from DWG to images (png) stream, having in one resulting image all the layers and layouts of original cad file
I think it can work as photoshop file’s layers: now when you convert a psd multi-layer in png you obtain all layers in one png file.
So we hope to do the same with DWG files, 2004 to 2014 format possibly.
For now there is too much limitations in dwg conversion: we risk to have many reports of bad issue by our customers, so we hide conversion for cad files.
Hi Valerio,
The issues you have found earlier (filed as IMAGING-34372;IMAGING-34285) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
Hi,
when we psd image first open it, the Layer that is selected/highlighted is the one called “Top layer”. Is it possible to select/highlight “particular layer” instead?