请教下teigha 转pdf如何设置纸张大小,方向,及打印范围
请教下teigha 转pdf如何设置纸张大小,方向,及打印范围,官网下载的试用版例子没有看到.net的,
网上版本4.0无法转pdf,4.02可以转, 但是没有找到设置的方法, 请问大佬们遇到过这种情况吗
自己写一个打印机驱动程序? 我这两下子, 不太行 https://www.123pan.com/s/26LA-6udAA?提取码:ZRC7 本帖最后由 Sring65 于 2024-9-2 13:41 编辑
3.9 试了下导出不了,可以试下aspose.cad网上有破解版本,还有论坛可以询问
public static void Main(string[] args)
{
//AsposeLisence.setLisence();//自行百度破解
// The path to the documents directory.
string MyDir = "C:\\Users\\Administrator\\Desktop\\test\\";
string filePathDWG = MyDir + "TestFile.dwg";
string filePathFinish = MyDir + "TestFile.dwg.pdf";
Stopwatch stopWatch = new Stopwatch();
try
{
stopWatch.Start();
Console.WriteLine("正在打开文件: " + filePathDWG);
using (CadImage cadImage = (CadImage)Image.Load(filePathDWG))
{
stopWatch.Stop();
// Get the elapsed time as a TimeSpan value.
TimeSpan ts = stopWatch.Elapsed;
// Format and display the TimeSpan value.
string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
ts.Hours, ts.Minutes, ts.Seconds,
ts.Milliseconds / 10);
Console.WriteLine("RunTime for loading " + elapsedTime);
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
rasterizationOptions.PageWidth = 1600;
rasterizationOptions.PageHeight = 1600;
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.VectorRasterizationOptions = rasterizationOptions;
stopWatch = new Stopwatch();
stopWatch.Start();
cadImage.Save(filePathFinish, pdfOptions);
stopWatch.Stop();
// Get the elapsed time as a TimeSpan value.
ts = stopWatch.Elapsed;
// Format and display the TimeSpan value.
elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
ts.Hours, ts.Minutes, ts.Seconds,
ts.Milliseconds / 10);
Console.WriteLine("RunTime for converting " + elapsedTime);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Sring65 发表于 2024-8-21 16:35
3.9 试了下导出不了,可以试下aspose.cad网上有破解版本,还有论坛可以询问
谢谢大佬:lol:lol 本帖最后由 Sring65 于 2024-9-23 16:24 编辑
teigha 4.02 pdf可以设置大小,成功导出指定大小页面
private void Update1() // export to pdf
{
OdRxModule mod = Globals.odrxDynamicLinker().loadApp("TD_PdfExport");
if (null == mod)
{
MessageBox.Show("Failed to load PDF export module", "Error");
}
Microsoft.Win32.SaveFileDialog dlgPdf = new Microsoft.Win32.SaveFileDialog();
dlgPdf.DefaultExt = ".pdf";
dlgPdf.Title = "PDF Export default";
dlgPdf.Filter = "PDF files|*.pdf";
// Display SaveFileDialog by calling ShowDialog method
if (dlgPdf.ShowDialog() != true)
{
return;
}
using (PDFExportParams Params = new PDFExportParams())
{
OdGsPageParams pParams = new OdGsPageParams();
Params.setDatabase(TDDatabase);
Params.setVersion(PDFExportParams.PDFExportVersions.kPDFv1_5);
using (OdStreamBuf file = Globals.odrxSystemServices().createFile(dlgPdf.FileName, FileAccessMode.kFileWrite, FileShareMode.kShareDenyNo, FileCreationDisposition.kCreateAlways))
{
Params.setOutput(file);
Params.setExportFlags(
(PDFExportParams.PDFExportFlags.kEmbededTTF) |
(PDFExportParams.PDFExportFlags.kSHXTextAsGeometry) | // no in sample
//(PDFExportParams.PDFExportFlags.kTTFTextAsGeometry) | // no in sample
(PDFExportParams.PDFExportFlags.kSimpleGeomOptimization) |
(PDFExportParams.PDFExportFlags.kZoomToExtentsMode) |
(PDFExportParams.PDFExportFlags.kEnableLayers) | // under condition
(PDFExportParams.PDFExportFlags.kIncludeOffLayers) | // under condition
(PDFExportParams.PDFExportFlags.kUseHLR) |
(PDFExportParams.PDFExportFlags.kFlateCompression) |
(PDFExportParams.PDFExportFlags.kASCIIHexEncoding) |
(PDFExportParams.PDFExportFlags.kExportHyperlinks));
Params.setTitle(dlgPdf.Title);
//Params.setAuthor("WpfSample2");
//Params.setSubject("WpfSample2");
//Params.setKeywords("WpfSample2");
//Params.setCreator("WpfSample2");
//Params.setProducer("WpfSample2");
UInt32[] CurPalette = AllPalettes.getLightPalette();// OdDgColorTable.currentPalette(CurDb);
CurPalette = 0x00ffffff; // the same as ODRGB(255, 255, 255); in the similar C++ code extract
//OdDbColorTable.correctPaletteForWhiteBackground(CurPalette);
Params.Palette = CurPalette;
Params.setBackground(CurPalette);
/*if (dlgPdf.m_Layouts == 1) // all
{
OdDbModelTable pModelTable = TDDatabase.getModelTable();
if (null != pModelTable)
{
OdDgElementIterator pIter = pModelTable.createIterator();
for (; !pIter.done(); pIter.step())
{
OdDgModel pModel = OdDgModel.cast(pIter.item().openObject());
if (null != pModel)
{
Params.layouts.Add(pModel.getName());
}
}
}
}*/
/*Params.layouts.Add(TDDatabase.findActiveLayout(true));
UInt32 nPages = (UInt32)(1 > Params.layouts.Count ? 1 : Params.layouts.Count);
OdGsPageParams pageParams = new OdGsPageParams();
pageParams.set(210, 295);
Params.pageParams.resize(nPages);*/
OdGsPageParams pageParams = new OdGsPageParams();
pageParams.set(400, 400);
OdGsPageParamsArray odGsPageParamsArray = new OdGsPageParamsArray();
odGsPageParamsArray.Add(pageParams);
Params.setPageParams(odGsPageParamsArray);
PdfExportModule module = new PdfExportModule(OdRxModule.getCPtr(mod).Handle, false); //= PdfExportModule.cast();
OdPdfExport exporter = module.create();
UInt32 errCode = exporter.exportPdf(Params);
if (errCode != 0)
{
String errMes = exporter.exportPdfErrorCode(errCode);
String str;
str = string.Format("Error number : {0}. \n {1}", errCode, errMes);
if (errCode == 0x10008)
{
str += "\nPlease enable Zoom to extents check box or\ndefine page parameters for layout in page setup dialog.";
}
MessageBox.Show("PDF error", str);
}
}
}
}
Sring65 发表于 2024-9-23 16:22
teigha 4.02 pdf可以设置大小,成功导出指定大小页面
哇塞, 谢谢谢谢大佬
页:
[1]