We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

关于 aspose.cad to pdf 文件失真 线宽过大

1.zip (7.7 MB)

代码如下:
static void convertDwg2Pdf(String dwg, String pdf) {
CadImage objImage = (CadImage) com.aspose.cad.Image.load(dwg);
CadBaseObject[] cbs = objImage.getObjects();
for (CadBaseObject cb : cbs) {
System.out.println(cb.getTypeName());

	}
	CadLayersList layersList = objImage.getLayers();
	System.out.println("w : " + objImage.getWidth());
	int cadUnitType = objImage.getUnitType();
	System.out.println("cad unit type: " + cadUnitType);

	System.out.println("UnitlessDefaultUnitType: " + objImage.getUnitlessDefaultUnitType());

	objImage.setDefaultLineWeight(0.01f);

	CadLayoutDictionary layoutDictionary = objImage.getLayouts();
	Dictionary.ValueCollection<String, CadLayout> layouts = layoutDictionary.getValues();
	for (CadLayout layout :
			layouts) {
		System.out.println("layout: " + layout.getLayoutName());
		System.out.println(layout.getPaperSize());

		System.out.println("PlotPaperSize: " + layout.getPlotPaperSize());
		System.out.println("PlotPaperUnits: " + layout.getPlotPaperUnits());
		System.out.println("PlotRotation: " + layout.getPlotRotation());
	}


	double factor = getFactor(cadUnitType == UnitType.Unitless ?
			objImage.getUnitlessDefaultUnitType() : cadUnitType
	);
	System.out.println("factor: " + factor);

	CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
	rasterizationOptions.setBackgroundColor(Color.getWhite());
	


	System.out.println(rasterizationOptions.getRelativeScale());

	rasterizationOptions.setPageWidth(800);
	rasterizationOptions.setPageHeight(600);
	rasterizationOptions.setDrawType(CadDrawTypeMode.UseObjectColor);


	rasterizationOptions.setAutomaticLayoutsScaling(true);

	System.out.println("缩放" + objImage.getStyles());

	HashMap<String, SizeF> layoutPageSizes = new HashMap<String, SizeF>();
	System.out.println("layouts : " + layouts.size());
	rasterizationOptions.setPdfProductLocation("center");
	RasterizationQuality rasterizationQuality = new RasterizationQuality();

	rasterizationQuality.setTextThicknessNormalization(true);
	
	rasterizationOptions.setQuality(rasterizationQuality);

	rasterizationOptions.setExportAllLayoutContent(true);


	List<String> ls = new ArrayList<String>();
	for (CadLayout layout :
			layouts) {
		System.out.println("Layout: " + layout.getLayoutName());
		System.out.println("PaperSize: " + layout.getPaperSize());

		System.out.println("PlotPaperUnits: " + layout.getPlotPaperUnits());
		System.out.println("PlotRotation: " + layout.getPlotRotation());
		System.out.println("PlotPaperSize: " + layout.getPlotPaperSize());
		System.out.println("max x y " + layout.getMaxLimits().getX() + ":" + layout.getMaxLimits().getY());
		System.out.println("min x y " + layout.getMinLimits().getX() + ":" + layout.getMinLimits().getY());
		System.out.println("BasePoint x y " + layout.getInsertionBasePoint().getX() + ":" + layout.getInsertionBasePoint().getY());


		CadSize cadSize = layout.getPlotPaperSize();

		List<CadBase> cs = layout.getChildObjects();

		for (CadBase c : cs) {
			System.out.println(c);
		}
		
		
		ls.add(layout.getLayoutName());
	
	}
	rasterizationOptions.setLayouts(ls.toArray(new String[ls.size()]));
	rasterizationOptions.setUnitType(objImage.getUnitType());
	rasterizationOptions.setLayoutPageSizes(layoutPageSizes);

	
	PdfOptions pdfOptions = new PdfOptions();

	pdfOptions.setVectorRasterizationOptions(rasterizationOptions);
	ResolutionSetting rs = new ResolutionSetting();
	rs.setVerticalResolution(600);
	rs.setHorizontalResolution(600);
	pdfOptions.setResolutionSettings(rs);


	// Export the DWG to PDF
	objImage.save(pdf, pdfOptions);

}

@liuling,
您能否更详细地解释哪条线有问题,您希望得到什么结果?