Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X
Hi,
I managed to make a working J-Link tool that plots 2D drawings to pdf in batch (because Pro/Batch is very slow and not easy to use).
This is the code that I use:
window = session.OpenFile(descr);
Drawing drawing = (Drawing) session.RetrieveModel(descr);
JOptionPane.showMessageDialog(null, componentFilename + " check1");
PDFExportInstructions PDFExportInstructions_Create = null;
PDFExportInstructions pdf_instrs = pfcExport.PDFExportInstructions_Create();
drawing.Export("C:\\local" + componentFilename + ".pdf", pdf_instrs);
window.Close();
But now I want the pdf to be in black and white, and "stroke all fonts", so I need to set these options. I've tried everything, but I have no clue how to work with PDFExportInstructions.SetOptions, PDFOption_Create, SetOptionType and SetOptionValue... the helpfiles aren't exactly clear on that.
Does anyone have an example of how to set these options in Jlink (or Pro/Tookit)???
Obviously, I've googled on these terms, but apparantly I'm the world's first to use it 😉
Thanks!
Jaap
Here is the codeThat I use to set stroked or truetype and to set color or mono in the attached file.
Hope it helps
Hi all,
thanks all for the great help, all is working well now! See below for the final code.
Regards, Jaap
while ((componentFilename = br.readLine()) != null) {
try {
componentFilename = componentFilename + ".drw";
aantalRegels = aantalRegels + 1;
ModelDescriptor descr = pfcModel.ModelDescriptor_CreateFromFileName(componentFilename);
window = session.OpenFile(descr); //orig
Drawing drawing = (Drawing) session.RetrieveModel(descr); //orig
PDFExportInstructions Mypdfexportinstructions = pfcExport.PDFExportInstructions_Create(); //orig
Mypdfexportinstructions.SetFilePath("C:\\local\\ProE");// null for working directory
PDFOption MyPdfOption = pfcExport.PDFOption_Create();
PDFOption MyPdfOption2 = pfcExport.PDFOption_Create();
//set options
MyPdfOption.SetOptionType(PDFOptionType.PDFOPT_FONT_STROKE);
MyPdfOption.SetOptionValue(pfcArgument.CreateIntArgValue(PDFFontStrokeMode._PDF_STROKE_ALL_FONTS));
PDFOptions Myoptions = PDFOptions.create();
Myoptions.append(MyPdfOption);
MyPdfOption2.SetOptionType(PDFOptionType.PDFOPT_COLOR_DEPTH);
MyPdfOption2.SetOptionValue(pfcArgument.CreateIntArgValue(PDFColorDepth._PDF_CD_MONO));
Myoptions.append(MyPdfOption2);
Mypdfexportinstructions.SetOptions(Myoptions);//null is default
//end set options
drawing.Export("C:\\local\" + componentFilename + ".pdf", Mypdfexportinstructions); //orig
window.Close(); //orig
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "problem with " + componentFilename + " --> " + ex.toString());
}
}