is it possible to check the node is box or not #66
Unanswered
jiangxiaoqiang
asked this question in
Q&A
Replies: 1 comment
-
Hi,
Sorry for the late answer
I am not sure to understand your problem.
The type of the node is given by synctex_node_type
You can use the synctex_node_display function for debugging.
In order to debug, you can also use .synctex files of you own.
JL
… Le 5 oct. 2023 à 17:57, JiangXiaoqiang ***@***.***> a écrit :
I am trying to get the pdf postion from latex source in rust, read the synctex source code to found get node attribute with box and without box, this is the rust code looks like:
pub fn get_pdf_pos(params: &GetPdfPosParams) -> Vec<PdfPosResp> {
let proj_dir = get_proj_base_dir(¶ms.project_id);
let pdf_file_name = format!("{}{}",get_filename_without_ext(¶ms.main_file),".pdf");
let file_path = join_paths(&[
&proj_dir,
&pdf_file_name.to_string(),
]);
unsafe {
let c_file_path = CString::new(file_path.clone());
if let Err(e) = c_file_path {
error!("parse out path error,{},{}", e, file_path.clone());
return Vec::new();
}
let c_build_path = CString::new(proj_dir.clone());
if let Err(e) = c_build_path {
error!("parse build path error,{},{}", e, proj_dir.clone());
return Vec::new();
}
let scanner = synctex_scanner_new_with_output_file(
c_file_path.unwrap().as_ptr(),
c_build_path.unwrap().as_ptr(),
1,
);
let tex_file_path = join_paths(&[proj_dir, params.path.clone(), params.file.clone()]);
let demo_tex = CString::new(tex_file_path.clone());
let mut position_list: Vec<PdfPosResp> = Vec::new();
let node_number = synctex_display_query(
scanner,
demo_tex.unwrap().as_ptr(),
params.line as c_int,
params.column as c_int,
0,
);
if node_number > 0 {
for _i in 0..node_number {
let node: synctex_node_p = synctex_scanner_next_result(scanner);
let page = synctex_node_page(node);
let h = synctex_node_visible_h(node);
let v = synctex_node_visible_v(node);
let height = synctex_node_visible_height(node);
let width = synctex_node_visible_width(node);
let single_pos = PdfPosResp::from((page, h, v, height, width));
position_list.push(single_pos);
}
}
return position_list;
}
}
now I found the result have some issue, the width and height is always 0. maybe I did not get the width and height by node type? I have read the node type design and found many type, how to check the type is box or not?
—
Reply to this email directly, view it on GitHub <#66>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAMK7T36X7CL56B7MLEF6HLX53KFZAVCNFSM6AAAAAA5UPXCP2VHI2DSMVQWIX3LMV43ERDJONRXK43TNFXW4OZVG4YDKMJSGI>.
You are receiving this because you are subscribed to this thread.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to get the pdf postion from latex source in rust, read the synctex source code to found get node attribute with box and without box, this is the rust code looks like:
now I found the result have some issue, the width and height is always 0. maybe I did not get the width and height by node type? I have read the node type design and found many type, how to check the type is box or not?
Beta Was this translation helpful? Give feedback.
All reactions