When Office convert to PDF, Japanese/Chinese characters might be disappeared?

Product: webviewer

Product Version: “@pdftron/webviewer”: “^8.12.1”,

Please give a brief summary of your issue:
When Office convert to PDF, Japanese/Chinese characters might be disappeared ?

Please describe your issue and provide steps to reproduce it:
Hello! I use Core.officeToPDFBuffer to convert Office to PDF buffer
flow as follow : Office —Core.officeToPDFBuffer—>buffer—>Blob —>PDF
the exported PDF loses its Japanese and Chinese characters (they become blank)
could you give me some suggestion? thanks
(using React Web and only use webviewer, code as follow)

Please provide a link to a minimal sample where the issue is reproducible:

import React,{useEffect,useRef} from “react”;
import WebViewer from “@pdftron/webviewer”;
import { Button } from “primereact/button”;

const ApmIDP =()=>{

const viewer = useRef<any>(null);
const vwr_ins = useRef<any>(null);

//export PDF
const saveBufferAsPDFDoc =(buffer:any,filename:string)=>{
  const blob =new Blob([buffer],{type:'application/pdf'})
  const url =URL.createObjectURL(blob);
  const a = document.createElement('a');
  a.href=url;
  a.download=filename;
  document.body.appendChild(a);
  a.click();
  document.body.removeChild(a);
  URL.revokeObjectURL(url);
}

useEffect(() => {
  WebViewer(
    {
      path: '/lib/webviewer',
      initialDoc: '/doc/PTTX1.pptx',
      isReadOnly:true,
      enableAnnotations:false,
      fullAPI: true
    },
    (viewer.current as any),
  ).then((instance) => {
    vwr_ins.current=instance;
    });
}, []);

const ConvertAndMerge = async ()=>{
  const {Core} = vwr_ins.current;
  try {
    debugger;
    const buf= await Core.officeToPDFBuffer('/doc/PPTX1.pptx')//Convert, blank??
    const blob =new Blob([buf],{type:'application/pdf'})
    saveBufferAsPDFDoc(blob,'save.pdf')//export PDF
  } catch (error) {
    console.log(error);
  } 
}

return (
    <>
    <Button onClick={ConvertAndMerge}>Test</Button>
    <div className="webviewer" ref={viewer} style={{height: "100vh"}}></div>
    </>
)

}

export default ApmIDP

Hello,

Thank you for contacting WebViewer support.
Would you mind sending us a sample file you were able to reproduce the issue so we can try the same scenario here? You can send me by email if you prefer dnavarro@apryse.com.

Best,
Dandara Navarro
Web Software Developer

Hi ! sent
pptx file just like that:

have a nice day

Hi,

Could you please confirm if your email is this kai…223@…tw?

Best,
Dandara Navarro

Right !! kai31223@yahoo.com.tw

HI,

Thank you for the provided file. Would it be an option for you to update the WebViewer version to the latest one? I cannot reproduce this issue on version 10.2, but in version 8.12 I’m having issues making this conversion.

Best,
Dandara Navarro

1 Like

Hi,

Thank you for the suggestion. I have updated the version from 8.12.1 to 10.2.3. However, the Japanese/Chinese characters still disappear without an error code. Did I do something wrong?

Thanks,
Kelvin Cheng

Hi,

It’s interesting that I was able to successfully convert Office documents to PDFs at home, but not at my company. I’m wondering if I’m missing some key information, such as firewall settings?

Thanks,
Kelvin Cheng

Hello,

It shouldn’t affect the result. Did you have a chance to try again on your company? If not, could you please try again, cleaning the cache and let us know?

Thank you,
Dandara Navarro

1 Like

Hi,

Thank you for your suggestions. I finally found a solution.

My company has a firewall that blocks my code from requesting PDFTron fonts.

To solve this, I need to set up a local fonts file service. Here are the steps:

  1. Get the font files and set up a fonts file service in my company.
  2. Use Core.setCustomFontURL(‘//URL in company’) to link to the fonts file service.
  3. In the .css file, change the URL to link to the fonts file service.

This solved the problem. Is there any official documentation on this?

Best regards,
Kelvin Cheng

Hi Kevin,

Glad to hear you found the problem and a solution. Below are some links you can take a look at and check if will help to improve your solution.

Best,
Dandara Navarro

2 Likes