java - Printing good characters into bad characters unknown characters -


pdf files contain french accent characters such as: e tick markt on top of them same u or so.

enter image description here

when check pdf files before printing, can see absolutely correct, can read them in pdf, can zoom in , copy them fine.

but moment java touch , prints it. not work suppose be.

how can fix please? cloud version of pdf perfect once following code use handle file, characters become broken in print copy.

import java.awt.print.printerexception; import java.awt.print.printerjob; import java.io.file; import java.io.fileoutputstream; import java.io.ioexception; import java.io.inputstream; import java.net.url; import javax.print.docprintjob; import javax.print.printservice; import javax.print.attribute.hashprintrequestattributeset; import javax.print.attribute.printrequestattributeset; import javax.print.attribute.standard.mediatray; import org.apache.pdfbox.pdmodel.pddocument; import org.apache.pdfbox.printing.pdfpageable;  public class printa4 {    public static boolean savefile(url url, string file) throws ioexception {     boolean download_status = false;      system.out.println("open");     inputstream in = url.openstream();     fileoutputstream fos = new fileoutputstream(new file(file));     system.out.println("reading file...");     int length = -1;     byte[] buffer = new byte[1024];      while ((length = in.read(buffer)) > -1) {         fos.write(buffer, 0, length);     }     fos.close();     in.close();      download_status = true;     system.out.println("downloaded");     return download_status;   }    public static void main(string[] args) throws ioexception, printerexception {        string downloaded_filename = "c:/pdf.pdf";     string download_pdf_from = "http://www.example.com/1.pdf" ;     string downloaded_filename_open_as_pdf = "c:\\pdf.pdf";     string printernamedesired = "brother hl-6180dw series";      printservice[] services = printerjob.lookupprintservices();     docprintjob docprintjob = null;     (int = 0; < services.length; i++) {       system.out.println(services[i]);     }         try{       url url = new url(download_pdf_from);        if(savefile(url, downloaded_filename)) {         try {           pddocument pdf = pddocument.load(new file(downloaded_filename_open_as_pdf));           printerjob job = printerjob.getprinterjob();           (int = 0; < services.length; i++) {            if (services[i].getname().equalsignorecase(printernamedesired)) {              docprintjob = services[i].createprintjob();            }           }            job.setprintservice(docprintjob.getprintservice());           job.setpageable(new pdfpageable(pdf));             printrequestattributeset pset = new hashprintrequestattributeset();                     pset.add(mediatray.bottom);            job.print(pset);          } catch (exception e) {           system.out.println("[fail]");         }             } else {         system.out.println("[fail]");       }           } catch (exception ae) {       system.out.println("[fail]");     }     } } 


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -