Im trying to generate PDF file on android using following code.

 This PDF file may contains both English and Chinese characters. 

Chinese characters are not recognized as Chinese letters(Recognized as 
images) but English letters are OK and this is causing  to increase PDF 
file size. 

Anyway android is able to generate PDF file without any issue.But i need to 
reduce the size of the PDF since i need to upload it to server.

Any workaround for this issue ?


* public void generatePDFDoc(Activity activity, View view, String 
pdfFileName, boolean isNeedToPrint) {*

*        {*

*            File pdfFile = null;*

*            PrintAttributes printAttrs = new PrintAttributes.Builder().*

*                    setColorMode(PrintAttributes.COLOR_MODE_COLOR).*

*                    setMediaSize(PrintAttributes.MediaSize.NA_LETTER).*

*                    setResolution(new PrintAttributes.Resolution("print", 
activity.PRINT_SERVICE,*

*                            25, 25)).*

*                    setMinMargins(PrintAttributes.Margins.NO_MARGINS).*

*                    build();*


*            PdfDocument document = new PrintedPdfDocument(activity, 
printAttrs);*

*            View content = view;*

*            int width = content.getWidth();*

*            int height = content.getHeight();*

*            PdfDocument.PageInfo pageInfo = new 
PdfDocument.PageInfo.Builder(width, height, 1).create();*

*            PdfDocument.Page page = document.startPage(pageInfo);*

*            content.draw(page.getCanvas());*

*            document.finishPage(page);*


*           String tempFileStr = Environment.getExternalStorageDirectory() 
+ File.separator +*

*                   ICommonConstants.OBC_RESOURCE_FOLDER + "/" + "TEMP_DO" 
+ ".pdf";*

*            File pdftempFile = new File(tempFileStr);*


*            try {*

*                pdfFile = new File(pdfFileName);*

*                if (pdfFile != null) {*

*                    FileOutputStream os = new FileOutputStream(pdfFile);*

*                    document.writeTo(os);*

*                    document.close();*

*                    os.close();*

*                }*

*            } catch (Exception e) {*

*                throw new RuntimeException("Error generating file", e);*

*            } finally {*

*                if (pdfFile != null) {*

*                    if (pdfFile.exists()) {*

*                        Log.d(TAG, "PDF GENERATED");*

*                        if (isNeedToPrint) {*

*                            printPDF(activity, pdfFileName);*

*                            activity.finish();*

*                        } else {*

*                            activity.finish();*

*                        }*

*                    }*


*                }*

*            }*



*        }*

*    }*

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/55c3eaed-8e7e-40a5-a2af-9ca6e7a4f2a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to