File : Export Graphs (Advanced)
(When Graph window is active)
Export graphs as raster or vector files
1. expGraph type:=jpg path:= "c:\image";
2. expGraph type:=bmp path:= "<User Files Folder>" tr1.width:=300 tr1.unit:=2;
3. expGraph pages:=graph2 type:=psd path:= "<Project Folder><PE Path>" tr1.width:=50 tr1.unit:=3;
4. expGraph type:=pdf overwrite:=rename export:=specified pages:=2!; //sheet range (index)
5. expGraph type:=png filename:="<long name>" export:=specified pages:=col(A)[3]; // cell range
6. expGraph -theme "5 Inch Width" type:=eps path:= "c:\image";
7. expGraph type:=eps path:= "c:\image" tr.OpenGLGraph.AntiAlias:=2;
8. expgraph -t <book> path:="c:\test" tr1.Unit:=2 tr1.Width:=600;
Please refer to the page for additional option switches when accessing the x-function from script
Display Name |
Variable Name |
I/O and Type |
Default Value |
Description |
---|---|---|---|---|
Image Type | type |
Input int |
|
The exported image type for the file. The default option is Encapsulated Postscript (*.eps).
Option list:
|
Select Graph(s) | export |
Input int |
|
Use this option to select the page(s) to be exported. The default option is Active Page.
Option list:
|
Graph Page | pages |
Input string |
|
Select the graph pages in the project to be exported. Click the browse button to open Graph Browser to select the graph pages. The graph pages to be exported can be specified using cell ranges or sheet ranges to accommodate export of embedded graphs. See examples in Command Line Usage. |
Export as multi-page PDF file | multipage |
Input int |
|
Export the multiple graph pages to one PDF file with multi-pages. |
File Name(s) | filename |
Input string |
|
The name(s) for the exported image file(s).
Note:
|
Path | path |
Input string |
|
The file path to save the exported image file(s). |
Overwrite Existing | overwrite |
Input int |
|
To specify if the existing file(s) in the path should be overwritten. Ask is the default option.
Option list:
|
Graph Theme | theme |
Input string |
|
Graph theme which is used to applied on the exported pages
Any Theme saved in the theme organizer can be used with this variable. |
Use Preference Options | sysopts |
Input int |
|
Whether to use Page settings from Preference Option dialog.
Default is used. This is not visible in GUI and only used in script. |
Export Settings | tr |
Input TreeNode |
|
Page settings for export |
Keep Original Size | keepsize |
Input int |
|
Whether to keep original graph size.
Default is keep. This is not visible in GUI and only used in script. |
Image Size | tr1 |
Input TreeNode |
|
Set the size for the exported image. |
Image Settings | tr2 |
Input TreeNode |
|
Set properties of the exported image. |
This X-Function exports the graph(s) in Origin to various image file(s). It has a graphical user interface (GUI) with previews. In the left panel, there are settings for the functions. In the right, there are two tabs, one is Image, which displays a preview for the exported image, and the other is Graph, which displays a cloned graph page for the source page to be exported.
Supported Formats
Totally 14 image file formats are supported for exporting to image file. These files fall into two categories:
The supported formats have been listed for the variable Image Type in the Variables section.
Details on Some Dialog Options
In this example, we will show how to create the same sub-folder hierarchy according to project folder structure, and export graphs into their own folders named after graph window long name.
Solution for Origin 2017 and later:
Note that predefined path such as <Project Folder><PE Path> was introduced in Origin 2017 to easily export graphs according to project folders in an opj file.
doc -e P { if(page.IsEmbedded==0&&exist(%H)!=11) //Skip over any embedded graphs or Layout windows { window -a %H; //Activate graph window expGraph type:=jpg filename:="<long name>" path:="<Project Folder><PE Path>" theme:=<Original> tr.Margin:=2; } }
Solution for Origin 2016 and later:
Note that string register %@P is only introduced since Origin 2016 SR2 which denotes the full Project Explorer path of the active folder.
doc -e P { if(page.IsEmbedded==0&&exist(%H)!=11) //Skip over any embedded graphs or Layout windows { window -a %H; //Activate graph window string a$=%X; //Get windows path of saved project string b$=%@P; //Get graph project path b.Replace("/","\"); //Correct path notation i=b.delete(1); string path$=a$+b$; //Concatenate above strings to create export folder path expGraph type:=jpg filename:="<long name>" path:=path$ theme:=<Original> tr.Margin:=2; } }
Solution for Origin 2015 and earlier:
pe_cd /; //move to root directory string root_folder$; pe_path path:=root_folder$; //get directory path //type root_folder$; int cs=%[root_folder$]; //get path length cs=cs+2; //add 2 probably due to spaces and similar //cs=; doc -e P //loop over all graph-like objects { if(page.IsEmbedded==0&&exist(%H)!=11) //Skip over any embedded graphs or Layout windows { string proj_path$=%X; //Get windows path of saved project; //type "the project path is:"+proj_path$; window -a %H; string graph_fullPath$; pe_path path:=graph_fullPath$; //Get graph project explorer path; %A=graph_fullPath$; string graph_path$=%[%A,>cs]; //remove the root folder name from path //type "the graph path is:"+graph_path$; //type "graph title is:"+%H; string path$=proj_path$+graph_Path$; //Concatenate above strings to create export folder; path.Replace("/","\"); expGraph type:=jpg filename:="<long name>" path:=path$ theme:=<Original> tr.Margin:=2; }; }
Keywords:publishing