paulocoutinhox / pdfium-lib

PDFium - Project to compile PDFium library to multiple platforms.
https://pdfviewer.github.io/
MIT License
915 stars 86 forks source link

Question: FPDFText_GetFontSize all rerurn 0 #116

Closed tianmuji closed 2 months ago

tianmuji commented 2 months ago

I am trying to get font information from page, here is the code

const firstPage = FPDF.LoadPage(doc.processor.wasmData.wasm, 0); const firstPageText = FPDF.FPDFText_LoadPage(firstPage); const charts = FPDF.FPDFText_CountChars(firstPageText); console.log('firstPageText:'+charts); let output = ''; for (let i = 0; i < charts; i++) { const unicode = FPDF.FPDFText_GetUnicode(firstPage, i); const char = String.fromCharCode(unicode); const fontSize = FPDF.FPDFText_GetFontSize(firstPage, i); output +=Character at index ${i}: ${char} (font: ${fontSize})\n; } console.log(output);

the problem is charts sometimes return 0 unicode and fontSize always return 0

I am wondering if I can use api from TextModule the api doc says it will not work without purchasing

Could you plz help me find the issue

paulocoutinhox commented 2 months ago

With "charts" you mean graphic charts?

tianmuji commented 2 months ago

With "charts" you mean graphic charts?

Nope, charts means for characters, sorry for the abbreviation I focus on all characters I want to get all characters and its style

My goal is to edit the text content so I firstly try to get all text style to make editing effect then I want to use FPDFTextObj_Insert api to update the text object

tianmuji commented 2 months ago

the first parameter of FPDFText_GetUnicode should be firstPageText instead of firstPage