cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

J-Link batch Pdf plotting - how to add options??!!

jaapkramer
1-Newbie

J-Link batch Pdf plotting - how to add options??!!

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


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
3 REPLIES 3

On 02/15/13 02:24, jaap kramer wrote:
>
> 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)???
>

Check out this article:
jeffruff
4-Participant
(To:jaapkramer)

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());
}
}

Top Tags