GithubHelp home page GithubHelp logo

tejpratap46 / pdfcreatorandroid Goto Github PK

View Code? Open in Web Editor NEW
272.0 5.0 66.0 2.35 MB

Simple library to generate and view PDF in Android

Home Page: https://link.tejpratapsingh.com/api/l/gbpdflib

License: MIT License

Java 98.11% HTML 1.89%
android-library pdf pdf-generation android

pdfcreatorandroid's Introduction

PDFCreatorAndroid

Simple library to generate and view PDF in Android


Android Arsenal


Cover

A simple library to create and view PDF with zero dependency Or native code.

Add it in your root build.gradle at the end of repositories:

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Step 2. Add the dependency

	dependencies {
	        implementation 'com.github.tejpratap46:PDFCreatorAndroid:3.0.2'
	}

Try It

Download From Play Store

Concept

  • Android has capability to print documents to PDF, this library simplifies those API's to generate PDF easily.
  • At basic level, API renders Views to PDF. To create A PDF with pages we need to submit views exactly height of one page, any view larges then that that will be trimmed.
  • This library creates pages by adding views to a parent view unitil the next view is about to exceed current page. If next view exceeds current page, that view will be added to new page.

Implementation

  1. PDF creater uses views which can be rendered, So we need to exted an activity in order to create activity.
  2. Create a Empty Activity without any layout and extend it with PDFCreatorActivity. Do not set use setContentView(int resourceId) inside your created activity.
  3. There are 3 abstract methods you have to override.
    1. getHeaderView()
      • This will be header for PDF and will be added to each page. (Accepts PDFHeaderView)
    2. getBodyViews()
      • This will return a PDFBody which consist of list of views which can be broken between pages.
    3. getFooterView()
      • This will be footer for PDF and will be added to each page. (Accepts PDFFooterView)
    4. getWatermarkView()
      • [OPTIONAL] This add a watermark image to each page. (Accepts PDFImageView), see issue #14
    5. onNextClicked()
      • This is a handler method to get callback when user taps on Next.
  4. In onCreate of you activity, you have to call createPDF(String fileName, PDFUtilListener listener). It will generate PDF and give you a PDF file in callback (if success). After receiving callback you can close activity and do whatever you need to do with PDF.
  5. This library also provides PDFUtil.pdfToBitmap(File pdfFile) method to get image preview of all pages of sepcified PDF file.

Available Views

  1. TextView -> PDFTextView
  2. VerticalView -> PDFVerticalView
  3. HorizontalView -> PDFHorizontalView
  4. ImageView -> PDFImageView
  5. TableView -> PDFTableView
  6. Saperator -> PDFLineSaperatorView

Advanced

If you cannot find some methods of a View Class inside PDFView class you can get view by calling pdfView.getView() on any available PDFView class and then update view properties.

For example Android TextView support setting html to TextView which is not available in PDFTextView, to do that see example below:

PDFTextView pdfIconLicenseView = new PDFTextView(getApplicationContext(), PDFTextView.PDF_TEXT_SIZE.H3);
Spanned icon8Link = Html.fromHtml("Icon from <a href='https://icons8.com'>https://icons8.com</a>");
pdfIconLicenseView.getView().setText(icon8Link);

Another example, Set gravity to View

pdfIconLicenseView.getView().setGravity(Gravity.CENTER_VERTICAL);

Advanced, Proceed with caution ⚠️

This is a unfinished feature, Use only for basic cases [After using this feature you cannot add child view to your custom view]. If you want to add a custom view to PDF (such as chart or icon), you just can create your own like this:

PDFVerticalView verticalView = new PDFVerticalView(context);
verticalView.setView(View view);

Example:

An example is created, Look at PdfCreatorExampleActivity of app.

VIEWS

  • PDFVerticalView
PDFVerticalView verticalView = new PDFVerticalView(getApplicationContext());
PDFTextView pdfTextView1 = new PDFTextView(getApplicationContext(), PDFTextView.PDF_TEXT_SIZE.P)
				.setText("TextView1");
verticalView.addView(pdfTextView1)
PDFTextView pdfTextView2 = new PDFTextView(getApplicationContext(), PDFTextView.PDF_TEXT_SIZE.P)
				.setText("TextView2");
verticalView.addView(pdfTextView2)
// Get View
LinearLayout layout = verticalView.getView();
  • PDFHorizontalView
PDFHorizontalView horizontalView = new PDFHorizontalView(getApplicationContext());
PDFTextView pdfTextView1 = new PDFTextView(getApplicationContext(), PDFTextView.PDF_TEXT_SIZE.P)
				.setText("TextView1");
horizontalView.addView(pdfTextView1)
PDFTextView pdfTextView2 = new PDFTextView(getApplicationContext(), PDFTextView.PDF_TEXT_SIZE.P)
				.setText("TextView2");
horizontalView.addView(pdfTextView2)
// Get View
LinearLayout layout = horizontalView.getView();
  • PDFTextView
PDFTextView pdfTextView1 = new PDFTextView(getApplicationContext(), PDFTextView.PDF_TEXT_SIZE.P)
				.setText("TextView1");
PDFTextView pdfTextView2 = new PDFTextView(getApplicationContext(), PDFTextView.PDF_TEXT_SIZE.P)
				.setText(new SpanningString("TextView2"));
// Get View
TextView textView = pdfTextView2.getView();
  • PDFImageView
PDFImageView pdfImageView = new PDFImageView(getApplicationContext(), PDFTextView.PDF_TEXT_SIZE.P)
				.setImageResource(R.drawable.ic_example);
// Get View
ImageView imageView = pdfImageView.getView();
  • PDFTableView
String[] textInTable = {"1", "2", "3", "4"};

// Create table column headers
PDFTableView.PDFTableRowView tableHeader = new PDFTableView.PDFTableRowView(getApplicationContext());
for (String s : textInTable) {
    PDFTextView pdfTextView = new PDFTextView(getApplicationContext(), PDFTextView.PDF_TEXT_SIZE.P);
    pdfTextView.setText("Header Title: " + s);
    tableHeader.addToRow(pdfTextView);
}
// Create first row
PDFTableView.PDFTableRowView tableRowView1 = new PDFTableView.PDFTableRowView(getApplicationContext());
for (String s : textInTable) {
    PDFTextView pdfTextView = new PDFTextView(getApplicationContext(), PDFTextView.PDF_TEXT_SIZE.P);
    pdfTextView.setText("Row 1 : " + s);
    tableRowView1.addToRow(pdfTextView);
}

// PDFTableView takes table header and first row at once because if page ends after adding header then first row will be on next page. To avoid confusion to user, table header and first row is printed together.
PDFTableView tableView = new PDFTableView(getApplicationContext(), tableHeader, tableRowView1);
for (int i = 0; i < 10; i++) {
    // Create 10 rows and add to table.
    PDFTableView.PDFTableRowView tableRowView = new PDFTableView.PDFTableRowView(getApplicationContext());
    for (String s : textInTable) {
	PDFTextView pdfTextView = new PDFTextView(getApplicationContext(), PDFTextView.PDF_TEXT_SIZE.P);
	pdfTextView.setText("Row " + (i + 1) + ": " + s);
	tableRowView.addToRow(pdfTextView);
    }
    tableView.addRow(tableRowView);
}
  • PDFLineSeparatorView
PDFLineSeparatorView lineSeparatorWhite = new PDFLineSeparatorView(getApplicationContext()).setBackgroundColor(Color.WHITE);
PDFLineSeparatorView lineSeparatorBlack = new PDFLineSeparatorView(getApplicationContext()).setBackgroundColor(Color.BLACK);
// Get View
View separatorView = lineSeparatorWhite.getView();

Pdf Viewer

This library now has a built-in Pdf Reader which uses PDFUtil.pdfToBitmap(savedPDFFile) internally to show preview of Pdf as Images inside a View Pager, Pdf viewer also has a RecyclerView version as well, but you need to add RecyclerView as Your Dependency. To Use ViewPager Based Pdf Viewer, you just have to create a Activity and extend it with PDFViewerActivity and call it using an Intent.

Uri pdfUri = Uri.fromFile(savedPDFFile);

Intent intentPdfViewer = new Intent(MainActivity.this, PdfViewerActivity.class);
intentPdfViewer.putExtra(PdfViewerActivity.PDF_FILE_URI, pdfUri);

startActivity(intentPdfViewer);

You can see Example Code At: PdfViewerExampleActivity of app.

Html To Pdf

You can create a Pdf from Html using Utility function PDFUtil.generatePDFFromHTML(getApplicationContext(), pdfFileToSave, "<html string />", callback);

// Create Temp File to save Pdf To
final File savedPDFFile = FileManager.getInstance().createTempFile(getApplicationContext(), "pdf", false);
// Generate Pdf From Html
PDFUtil.generatePDFFromHTML(getApplicationContext(), savedPDFFile, " <!DOCTYPE html>\n" +
    "<html>\n" +
    "<body>\n" +
    "\n" +
    "<h1>My First Heading</h1>\n" +
    "<p>My first paragraph.</p>\n" +
    " <a href='https://www.example.com'>This is a link</a>" +
    "\n" +
    "</body>\n" +
    "</html> ", new PDFPrint.OnPDFPrintListener() {
        @Override
        public void onSuccess(File file) {
            // Open Pdf Viewer
            Uri pdfUri = Uri.fromFile(savedPDFFile);

            Intent intentPdfViewer = new Intent(MainActivity.this, PdfViewerActivity.class);
            intentPdfViewer.putExtra(PdfViewerActivity.PDF_FILE_URI, pdfUri);

            startActivity(intentPdfViewer);
        }

        @Override
        public void onError(Exception exception) {
            exception.printStackTrace();
        }
});

WebView To Pdf

With this feature, you can directly create Pdf from whatever your WebView is showing. You can add contenteditable="true" and have user edit data and create pdf from edited Data. You can just call Utility function: PDFUtil.generatePDFFromWebView(savedPDFFile, webView, callback)

You can see Example Code At: PdfEditorExampleActivity of app.

// Create Temp File to save Pdf To
final File savedPDFFile = FileManager.getInstance().createTempFile(getApplicationContext(), "pdf", false);
// Generate Pdf From Html
PDFUtil.generatePDFFromWebView(savedPDFFile, webView, new PDFPrint.OnPDFPrintListener() {
    @Override
    public void onSuccess(File file) {
        // Open Pdf Viewer
        Uri pdfUri = Uri.fromFile(savedPDFFile);

        Intent intentPdfViewer = new Intent(PdfEditorActivity.this, PdfViewerActivity.class);
        intentPdfViewer.putExtra(PdfViewerActivity.PDF_FILE_URI, pdfUri);

        startActivity(intentPdfViewer);
    }

    @Override
    public void onError(Exception exception) {
        exception.printStackTrace();
    }
});

Example PDF

Donate

ko-fi

pdfcreatorandroid's People

Contributors

enocklubowa avatar tejpratap46 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pdfcreatorandroid's Issues

Don't want new activitiy

Greetings,
I don't want the pdf to be opened in a new activity. It will save in the background in my current activity and I want to upload it to the server later.
How can I trigger your class in current activity?

Clickable Phone number & email address

how to open dialer when someone click on phone number from pdf?
how to open email app when someone click on email address from pdf?

headerView.addView(getContactItem(Uri.parse("tel:" + phone).toString(), phone, R.mipmap.ic_phone_circle, 20));
headerView.addView(getContactItem("mailto:" +mail, mail, R.mipmap.ic_email_circle, 10));

it is not working... please help me.. thanks

PDFUtil.generatePDFFromHTML does support <img> tag?

Does it support <img> tag using PDFUtil.generatePDFFromHTML? I'am trying
<img src="${Uri.parse("android.resource://my.package/drawable/my_image")}"> but its not working. Also tried:
<img src="file:///android_res/drawable/my_image.png" />

user restricted while installation

Hi
I am trying to create pdf,I dont need pdf viewer so i haven't used those activities but while installing appi am facing error
12/31 17:10:54: Launching 'app' on Xiaomi Redmi Note 8.
Installation did not succeed.
The application could not be installed: INSTALL_FAILED_USER_RESTRICTED

List of apks:
[0] 'D:\Pdfgenerator2\app\build\outputs\apk\debug\app-debug.apk'
Installation via USB is disabled.
Retry
Kindly hekp.

Thanks in advance!!!

Table Column Alignment & Repeating header

Hi Tej,

thank you for creating and maintaining this library.

I have been able to use and generate a pdf. It contains a table that extends to 2 or more pages. I have two issues can you please guide

  1. Since the table repeats on two or more pages - how can the table headers be repeated?
  2. How to assign table column width - I have 2 columns, and I need the first to be on the left and seond on the right - justified...

Please guide

Thanks

Loading Images from Mobile

Hi Tej,

The user is able to upload a default image using picasso, and the uri is stored. I tried the following approach to be able to display the image from the uri for the image stored in the phone gallery but it does not work... any suggestions please?

    val imageView = PDFImageView(applicationContext)
    val imageLayoutParam = LinearLayout.LayoutParams(
        60,
        60, 0F
    )
    if(user.logoUrl != null){
        val url = URL(user.logoUrl)
        val imageBmp = BitmapFactory.decodeStream(url.openConnection().getInputStream())
        imageView.setImageScale(ImageView.ScaleType.CENTER_INSIDE)
        imageView.setImageBitmap(imageBmp)
        // imageView.setImageResource(user!!.logoUrl)
        imageLayoutParam.setMargins(0, 0, 10, 10)
        imageView.setLayout(imageLayoutParam)
        horizontalView.addView(imageView)
    }

thanks

The specified child already has a parent. You must call removeView() on the child's parent first.

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gijutsudesigns.siga.sigamovil/com.gijutsudesigns.siga.sigamovil.vistas.actividades.GenerarPdf}: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3827)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4003)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2317)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8625)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

Caused by java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
at android.view.ViewGroup.addViewInner(ViewGroup.java:6065)
at android.view.ViewGroup.addView(ViewGroup.java:5884)
at android.view.ViewGroup.addView(ViewGroup.java:5824)
at android.view.ViewGroup.addView(ViewGroup.java:5796)
at com.tejpratapsingh.pdfcreator.views.basic.PDFVerticalView.addView(PDFVerticalView.java:29)
at com.tejpratapsingh.pdfcreator.views.PDFTableView.(PDFTableView.java:29)
at com.gijutsudesigns.siga.sigamovil.vistas.actividades.GenerarPdf.getBodyViews(GenerarPdf.java:176)
at com.tejpratapsingh.pdfcreator.activity.PDFCreatorActivity.createPDF(PDFCreatorActivity.java:81)
at com.gijutsudesigns.siga.sigamovil.vistas.actividades.GenerarPdf.onCreate(GenerarPdf.java:61)
at android.app.Activity.performCreate(Activity.java:8207)
at android.app.Activity.performCreate(Activity.java:8191)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3800)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4003)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2317)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8625)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

Pdf Generator Issue -table view

I integrated your pdf library in my project. It was working fine when viewing pdf and share. But without viewing i want only share pdf.

Childview tableview coming one row in one page.

please find code for reference

public void createPDFOverall(final String fileName, final PDFUtil.PDFUtilListener pdfUtilListener) {
        // Create parent RelativeLayout
        layoutPageParent = new LinearLayout(this.ctx);
        LinearLayout.LayoutParams relParentParam = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        layoutPageParent.setLayoutParams(relParentParam);
        final ArrayList<View> bodyViewList = new ArrayList<>();
        View header = null;
        if (getHeaderView(0) != null) {
            header = getHeaderView(0).getView();
            header.setTag(PDFHeaderView.class.getSimpleName());
            bodyViewList.add(header);
            addViewToTempLayout(layoutPageParent, header);
        }

        if (getBodyViews() != null) {
            for (PDFView pdfView : getBodyViews().getChildViewList()) {
                View bodyView = pdfView.getView();
                bodyView.setTag(PDFBody.class.getSimpleName());
                bodyViewList.add(bodyView);
                addViewToTempLayout(layoutPageParent, bodyView);
            }
        }


        final Handler handler = new Handler(Looper.getMainLooper());
        final View finalHeader = header;
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                createPDFFromViewList(finalHeader, bodyViewList, fileName, new PDFUtil.PDFUtilListener() {
                    @Override
                    public void pdfGenerationSuccess(File savedPDFFile) {
                        try {
//                    pagePreviewBitmapList.clear();
//                    pagePreviewBitmapList.addAll(PDFUtil.pdfToBitmap(savedPDFFile));
//                    textViewGeneratingPDFHolder.setVisibility(View.GONE);
//                    layoutPrintPreview.setVisibility(View.VISIBLE);
                            selectedPreviewPage = 0;
//                    imageViewPDFPreview.setImageBitmap(pagePreviewBitmapList.get(selectedPreviewPage));
//                    textViewPageNumber.setText(String.format(Locale.getDefault(), "%d of %d", selectedPreviewPage + 1, pagePreviewBitmapList.size()));
                        } catch (Exception e) {
                            e.printStackTrace();
//                    imageViewPDFPreview.setVisibility(View.GONE);
//                    textViewPageNumber.setVisibility(View.GONE);
//                    buttonNextPage.setVisibility(View.GONE);
//                    buttonPreviousPage.setVisibility(View.GONE);
//                    textViewPreviewNotAvailable.setVisibility(View.VISIBLE);
                        }
                        savedPDFFilec = savedPDFFile;
                        pdfUtilListener.pdfGenerationSuccess(savedPDFFile);
                    }

                    @Override
                    public void pdfGenerationFailure(Exception exception) {
                        pdfUtilListener.pdfGenerationFailure(exception);
                    }
                });
            }
        }, 1000);

    }


    /**
     * Creates a paginated PDF page views from list of views those are already rendered on screen
     * (Only rendered views can give height)
     *
     * @param tempViewList list of views to create pdf views from, view should be already rendered to screen
     */
    private void createPDFFromViewList(final View headerView, @NonNull final ArrayList<View> tempViewList, @NonNull final String filename, final PDFUtil.PDFUtilListener pdfUtilListener) {
        tempViewList.get(tempViewList.size() - 1).post(new Runnable() {
            @Override
            public void run() {

                // Clean temp folder
                final FileManager myOPDFileManager = FileManager.getInstance();
                myOPDFileManager.cleanTempFolder(ctx);

                ((Activity) ctx).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        final List<View> pdfPageViewList = new ArrayList<>();
//                        LinearLayout currentPDFLayout = (LinearLayout) ((Activity) ctx).getLayoutInflater().inflate(com.tejpratapsingh.pdfcreator.R.layout.item_pdf_page, null);
//                        currentPDFLayout.setBackgroundColor(ContextCompat.getColor(ctx.getApplicationContext(), com.tejpratapsingh.pdfcreator.R.color.colorWhite));
//                        pdfPageViewList.add(currentPDFLayout);
                        int currentPageHeight = 0;

                        if (headerView != null) {
                            // If item is a page header, store its height so we can add it to all pages without waiting to render it every time
                            headerLayoutHeight = headerView.getHeight();
//                            headerLayoutHeight = 50;
                        }

                        int pageIndex = 1;
                        LinearLayout currentPDFLayout = null;
                        for (View viewItem : tempViewList) {
                            if (currentPageHeight + 848 > (ctx.getResources().getDimensionPixelSize(com.tejpratapsingh.pdfcreator.R.dimen.pdf_height)
                                    - (ctx.getResources().getDimensionPixelSize(com.tejpratapsingh.pdfcreator.R.dimen.pdf_margin_vertical) * 2))) {
                                currentPDFLayout = (LinearLayout) ((Activity) ctx).getLayoutInflater().inflate(com.tejpratapsingh.pdfcreator.R.layout.item_pdf_page, null);
                                currentPDFLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                                        LinearLayout.LayoutParams.WRAP_CONTENT));
                                currentPDFLayout.setBackgroundColor(ContextCompat.getColor(ctx.getApplicationContext(), com.tejpratapsingh.pdfcreator.R.color.colorWhite));
                                pdfPageViewList.add(currentPDFLayout);

                                currentPageHeight = 0;

                                // Add page header again
                                if (headerLayoutHeight > 0) {
                                    // If height is available, only then add header
                                    LinearLayout layoutHeader = getHeaderView(pageIndex).getView();
                                    addViewToTempLayout(layoutPageParent, layoutHeader);
                                    currentPageHeight += headerLayoutHeight;
                                    layoutPageParent.removeView(layoutHeader);
                                    currentPDFLayout.addView(layoutHeader);

                                    pageIndex = pageIndex + 1;
                                }
                                currentPageHeight += viewItem.getHeight();
                                if (viewItem.getParent() != null) {
                                    ((ViewGroup) viewItem.getParent()).removeView(viewItem); // <- fix
                                }
                                currentPDFLayout.addView(viewItem);
                            }


                        }

                        PDFUtil.getInstance().generatePDF(pdfPageViewList, myOPDFileManager.createTempFileWithName(ctx.getApplicationContext(), filename + ".pdf", false).getAbsolutePath(), pdfUtilListener);
                    }
                });
            }
        });
    }

//    protected abstract PDFHeaderView getHeaderView(int page);
//
//    protected abstract PDFBody getBodyViews();


    protected PDFHeaderView getHeaderView(int pageIndex) {
        PDFHeaderView headerView = new PDFHeaderView(ctx);


//        PDFTextView pdfTextViewPage = new PDFTextView(ctx, PDFTextView.PDF_TEXT_SIZE.SMALL);
//        pdfTextViewPage.setText(String.format(Locale.getDefault(), "Page: %d", pageIndex + 1));
//        pdfTextViewPage.setLayout(new LinearLayout.LayoutParams(
//                LinearLayout.LayoutParams.MATCH_PARENT,
//                LinearLayout.LayoutParams.MATCH_PARENT, 0));
//        pdfTextViewPage.getView().setGravity(Gravity.END);
//
//        headerView.addView(pdfTextViewPage);


        PDFHorizontalView horizontalViewLogo = new PDFHorizontalView(ctx);

        PDFImageView imageView = new PDFImageView(ctx);
        LinearLayout.LayoutParams imageLayoutParam = new LinearLayout.LayoutParams(100,
                100);
//        imageView.setImageScale(ImageView.ScaleType.CENTER_INSIDE);
        imageView.setImageResource(R.mipmap.ic_launcher);
        imageLayoutParam.setMargins(0, 0, 10, 0);
        imageView.setLayout(imageLayoutParam);
        horizontalViewLogo.addView(imageView);
        horizontalViewLogo.getView().setGravity(Gravity.CENTER_HORIZONTAL);
        headerView.addView(horizontalViewLogo);

        PDFHorizontalView horizontalView = new PDFHorizontalView(ctx);


        PDFTextView pdfTextView = new PDFTextView(ctx, PDFTextView.PDF_TEXT_SIZE.HEADER);
//        SpannableString word = new SpannableString(" Transaction Detail Statement\n");
//        word.setSpan(new ForegroundColorSpan(Color.DKGRAY), 0, word.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        pdfTextView.setText(" Transaction Detail Statement");
        pdfTextView.setTextColor(Color.BLUE);
        pdfTextView.setLayout(new LinearLayout.LayoutParams(
                0,
                LinearLayout.LayoutParams.WRAP_CONTENT, 1));
        pdfTextView.getView().setGravity(Gravity.CENTER);
        pdfTextView.getView().setTypeface(pdfTextView.getView().getTypeface(), Typeface.BOLD);
        horizontalView.addView(pdfTextView);
        headerView.addView(horizontalView);

        PDFTextView pdfCompanyNameView = new PDFTextView(ctx, PDFTextView.PDF_TEXT_SIZE.H3);
        pdfCompanyNameView.setText("Company Namennnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn");
        pdfTextView.setLayout(new LinearLayout.LayoutParams(
                0,
                LinearLayout.LayoutParams.WRAP_CONTENT, 1));
        headerView.addView(pdfCompanyNameView);

        PDFTextView pdfAddressView = new PDFTextView(ctx, PDFTextView.PDF_TEXT_SIZE.P);
        pdfTextView.setLayout(new LinearLayout.LayoutParams(
                0,
                LinearLayout.LayoutParams.WRAP_CONTENT, 1));
        pdfAddressView.setText("Address Line 1\nCity, State - 123456");
        headerView.addView(pdfAddressView);


        PDFHorizontalView pdfHorizontalViewR4 = new PDFHorizontalView(ctx);
        PDFHorizontalView pdfHorizontalViewR5 = new PDFHorizontalView(ctx);
        PDFHorizontalView pdfHorizontalViewR6 = new PDFHorizontalView(ctx);
        PDFTextView filter1View = new PDFTextView(ctx, PDFTextView.PDF_TEXT_SIZE.P, false, "");
        SpannableString filter1SS = new SpannableString("Filter");
        filter1SS.setSpan(new ForegroundColorSpan(Color.WHITE), 0, filter1SS.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        filter1View.setText(filter1SS);
        filter1View.getView().setBackgroundColor(ctx.getResources().getColor(R.color.grey_500));
        filter1View.setLayout(new LinearLayout.LayoutParams(0,
                LinearLayout.LayoutParams.WRAP_CONTENT, 1));
        filter1View.getView().setGravity(Gravity.CENTER);
        filter1View.getView().setTypeface(filter1View.getView().getTypeface(), Typeface.NORMAL);

        PDFTextView filterSpaceView = new PDFTextView(ctx, PDFTextView.PDF_TEXT_SIZE.P, false, "");
        SpannableString spaceSS = new SpannableString(" ");
        spaceSS.setSpan(new ForegroundColorSpan(Color.WHITE), 0, spaceSS.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        filterSpaceView.setText(spaceSS);
        filterSpaceView.getView().setBackgroundColor(ctx.getResources().getColor(R.color.colorWhite));
        filterSpaceView.setLayout(new LinearLayout.LayoutParams(3,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        filterSpaceView.getView().setGravity(Gravity.CENTER);
        filterSpaceView.getView().setTypeface(filterSpaceView.getView().getTypeface(), Typeface.NORMAL);

        PDFTextView filter2View = new PDFTextView(ctx, PDFTextView.PDF_TEXT_SIZE.P, false, "");
        SpannableString filter2SS = new SpannableString("Period");
        filter2SS.setSpan(new ForegroundColorSpan(Color.WHITE), 0, filter2SS.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        filter2View.setText(filter2SS);
        filter2View.getView().setBackgroundColor(ctx.getResources().getColor(R.color.grey_500));
        filter2View.setLayout(new LinearLayout.LayoutParams(0,
                LinearLayout.LayoutParams.WRAP_CONTENT, 1));
        filter2View.getView().setGravity(Gravity.CENTER);
        filter2View.getView().setTypeface(filter2View.getView().getTypeface(), Typeface.NORMAL);

        pdfHorizontalViewR4.addView(filter1View);
        pdfHorizontalViewR4.addView(filterSpaceView);
        pdfHorizontalViewR4.addView(filter2View);

        PDFTextView filter3View = new PDFTextView(ctx, PDFTextView.PDF_TEXT_SIZE.P, false, "");
        SpannableString filter3SS = new SpannableString("filter");
        filter3SS.setSpan(new ForegroundColorSpan(Color.WHITE), 0, filter3SS.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        filter3View.setText(filter3SS);
        filter3View.getView().setBackgroundColor(ctx.getResources().getColor(R.color.grey_500));
        filter3View.setLayout(new LinearLayout.LayoutParams(0,
                LinearLayout.LayoutParams.WRAP_CONTENT, 1));
        filter3View.getView().setGravity(Gravity.CENTER);
        filter3View.getView().setTypeface(filter3View.getView().getTypeface(), Typeface.NORMAL);

        PDFTextView filterSpace1View = new PDFTextView(ctx, PDFTextView.PDF_TEXT_SIZE.P, false, "");
        SpannableString space1SS = new SpannableString(" ");
        space1SS.setSpan(new ForegroundColorSpan(Color.WHITE), 0, space1SS.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        filterSpace1View.setText(space1SS);
        filterSpace1View.getView().setBackgroundColor(ctx.getResources().getColor(R.color.colorWhite));
        filterSpace1View.setLayout(new LinearLayout.LayoutParams(3,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        filterSpace1View.getView().setGravity(Gravity.CENTER);
        filterSpace1View.getView().setTypeface(filterSpace1View.getView().getTypeface(), Typeface.NORMAL);

        PDFTextView filter4View = new PDFTextView(ctx, PDFTextView.PDF_TEXT_SIZE.P, false, "");
        SpannableString filter4SS = new SpannableString("Period");
        filter4SS.setSpan(new ForegroundColorSpan(Color.WHITE), 0, filter4SS.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        filter4View.setText(filter4SS);
        filter4View.getView().setBackgroundColor(ctx.getResources().getColor(R.color.grey_500));
        filter4View.setLayout(new LinearLayout.LayoutParams(0,
                LinearLayout.LayoutParams.WRAP_CONTENT, 1));
        filter4View.getView().setGravity(Gravity.CENTER);
        filter4View.getView().setTypeface(filter4View.getView().getTypeface(), Typeface.NORMAL);

        pdfHorizontalViewR5.addView(filter3View);
        pdfHorizontalViewR5.addView(filterSpace1View);
        pdfHorizontalViewR5.addView(filter4View);

        String[] textInTable = {"Transaction ID", "Mobile Number", "Cash Back \n(MMK)", "Opening Balance \n(MMK)", "Credit \n(MMK)", "Debit \n(MMK)", "Closing Balance \n(MMK)", "Date & Time"};
        for (String title : textInTable) {
            PDFTextView headerTitleView = new PDFTextView(ctx, PDFTextView.PDF_TEXT_SIZE.P, false, "");
            headerTitleView.setLayout(new LinearLayout.LayoutParams(0,
                    40, 1));
            headerTitleView.setText(title);
            headerTitleView.getView().setTextSize(4f);
            headerTitleView.setTextColor(ctx.getResources().getColor(R.color.colorWhite));
            headerTitleView.getView().setGravity(Gravity.CENTER);
//            if (!title.equals("Date & Time"))
//                headerTitleView.setBackground(ctx.getResources().getDrawable(R.drawable.right_vertical_line));
//            else
            headerTitleView.setBackgroundColor(ctx.getResources().getColor(R.color.blue_700));
            pdfHorizontalViewR6.addView(headerTitleView);
        }

        headerView.addView(pdfHorizontalViewR4);
        headerView.addView(pdfHorizontalViewR5);
        headerView.addView(pdfHorizontalViewR6);

        PDFLineSeparatorView lineSeparatorView1 = new PDFLineSeparatorView(ctx).setBackgroundColor(Color.WHITE);
        headerView.addView(lineSeparatorView1);


        return headerView;
    }

    protected PDFBody getBodyViews() {
        PDFBody pdfBody = new PDFBody();


        String[] textInTable = {"1", "2", "3", "4", "5", "6", "7", "8"};

//        PDFLineSeparatorView lineSeparatorView2 = new PDFLineSeparatorView(ctx).setBackgroundColor(Color.WHITE);
//        pdfBody.addView(lineSeparatorView2);
//        PDFTextView pdfTableTitleView = new PDFTextView(ctx, PDFTextView.PDF_TEXT_SIZE.P);
//        pdfTableTitleView.setText("");
//        pdfBody.addView(pdfTableTitleView);

//        String[] textInTableHeader = {"Transaction ID", "Mobile Number", "Cash Back \n(MMK)", "Opening Balance \n(MMK)", "Credit \n(MMK)", "Debit \n(MMK)", "Closing Balance \n(MMK)", "Date & Time"};

        PDFTableView.PDFTableRowView tableHeader = new PDFTableView.PDFTableRowView(ctx);
       /* for (String s : textInTableHeader) {
            PDFTextView pdfTextView = new PDFTextView(ctx, PDFTextView.PDF_TEXT_SIZE.P);
            pdfTextView.setText(textInTableHeader[s]);
            tableHeader.addToRow(pdfTextView);
        }*/

      /*  for (int kl = 0; kl < textInTableHeader.length; kl++) {
            PDFTextView pdfTextView = new PDFTextView(ctx, PDFTextView.PDF_TEXT_SIZE.P);
            pdfTextView.setText(textInTableHeader[kl]);
            pdfTextView.getView().setGravity(Gravity.CENTER);
            tableHeader.addToRow(pdfTextView);
        }*/

        String[] textInTableContent = {"1771662528", "(+91)9500465992", "  ဦးသက္နုိင္ဦး", "5,536.59", "2", "-", "5,537.59", "Mon, 07-Sep-2020 19:07:19"};

        PDFTableView.PDFTableRowView tableRowView = new PDFTableView.PDFTableRowView(ctx);
        tableRowView.setLayout(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                30));
        PDFTableView tableView = new PDFTableView(ctx, tableHeader, tableRowView);

        for (int i = 0; i < 40; i++) {
            // Create 10 rows
            PDFTableView.PDFTableRowView tableRowView1 = new PDFTableView.PDFTableRowView(ctx);
            PDFTableView.PDFTableRowView tableRowView2 = new PDFTableView.PDFTableRowView(ctx);
            tableRowView1.setLayout(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                    30));
            tableRowView2.setLayout(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                    1));
            tableRowView2.setBackgroundColor(ctx.getResources().getColor(R.color.colorBlack));
            /*  for (String s : textInTable) {
                PDFTextView pdfTextView = new PDFTextView(ctx, PDFTextView.PDF_TEXT_SIZE.P);
                pdfTextView.setText("Row " + (i + 2) + ": " + s);
                tableRowView.addToRow(pdfTextView);
            }*/
            for (int j = 0; j < 1; j++) {

                for (int k = 0; k < textInTableContent.length; k++) {
                    PDFTextView pdfTextView = new PDFTextView(ctx, PDFTextView.PDF_TEXT_SIZE.P);
                    pdfTextView.setText(i + textInTableContent[k]);
                    pdfTextView.getView().setGravity(Gravity.CENTER);
                    tableRowView1.addToRow(pdfTextView);
                }
            }
            tableView.addRow(tableRowView1);
            tableView.addRow(tableRowView2);


        }

        pdfBody.addView(tableView);

        PDFLineSeparatorView lineSeparatorView3 = new PDFLineSeparatorView(ctx).setBackgroundColor(Color.BLACK);
        pdfBody.addView(lineSeparatorView3);

//        PDFTextView pdfIconLicenseView = new PDFTextView(ctx, PDFTextView.PDF_TEXT_SIZE.H3);
//        Spanned icon8Link = Html.fromHtml("Icon from <a href='https://icons8.com'>https://icons8.com</a>");
//        pdfIconLicenseView.getView().setText(icon8Link);
//        pdfBody.addView(pdfIconLicenseView);

        return pdfBody;
    }

cannot resize entire row depending on the value in textviews

I was trying to create a table view, but the values in each text view in the table view might vary. so need the entire row to resize depending on the value present in the text view. if you can see the first header row I just added some characters to the first text view, the rest columns does not match the height to the first row. tried adding layout params to text view and the row. same issue persists.

image

int[] widthPercent2 = {5, 12, 17, 10, 10, 10, 10, 10, 8, 8};
   String[] headerTitle2 = {"S# fjtdhrdygkyftjf", "Item Code", "Item Name", "Cs Qty", "Pc Qty", "Cs Price", "Pc Price", "Sub Total", "VAT", "Total"};
   String[] childTitle1 = {"1", itemCode[0], itemName[0], csQty[0], pcQty[0], csPrice[0], pcPrice[0], subtotal[0], vat[0], total[0]};

private PDFTableView.PDFTableRowView createTableHeader(String[] headerTitle) {
       PDFTableView.PDFTableRowView tableHeaderRow = new PDFTableView.PDFTableRowView(getApplicationContext());
       for (int i = 0; i < headerTitle.length; i++) {
           tableHeaderRow.addToRow(createHeaderColumn(headerTitle[i], i));
       }
       tableHeaderRow.setLayout(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT));
       return tableHeaderRow;
   }

private PDFTextView createHeaderColumn(String title, int pos) {
       PDFTextView pdfTextView = new PDFTextView(getApplicationContext(), PDFTextView.PDF_TEXT_SIZE.P).setText(title);
       if (pos == 0) {
           pdfTextView.getView().setBackground(getResources().getDrawable(R.drawable.border_left_top_right_grey));
       } else {
           pdfTextView.getView().setBackground(getResources().getDrawable(R.drawable.border_top_right_grey));
       }


       pdfTextView.getView().setTextSize(TypedValue.COMPLEX_UNIT_SP,  (float) 3.5);
       pdfTextView.setTextTypeface(ResourcesCompat.getFont(getApplicationContext(), R.font.calibrib));
       pdfTextView.setPadding(10, 0, 0, 0);
       pdfTextView.setLayout(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
       return pdfTextView;
   }

I attach the row to the table using the below mentioned code

PDFTableView tableView = new PDFTableView(getApplicationContext(), createTableHeader(headerTitleInv),
                createTableChildFirstRow(childTitleInv, 1));
        tableView.setColumnWidth(widthPercentInv);
        pdfBody.addView(tableView);
        pdfBody.addView(createSeparator(Color.WHITE, 15));

Could anyone tell me what I'm doing wrong/missing out..

NullPointer exception Click on next

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.sit.a22junpdftestapplication, PID: 12173
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sit.a22junpdftestapplication/com.sit.a22junpdftestapplication.PdfViewerActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.tejpratapsingh.pdfcreator.custom.ViewPagerForPhotoView.setAdapter(androidx.viewpager.widget.PagerAdapter)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2946)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3081)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6810)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.tejpratapsingh.pdfcreator.custom.ViewPagerForPhotoView.setAdapter(androidx.viewpager.widget.PagerAdapter)' on a null object reference
at com.tejpratapsingh.pdfcreator.activity.PDFViewerActivity.onCreate(PDFViewerActivity.java:71)
at com.sit.a22junpdftestapplication.PdfViewerActivity.onCreate(PdfViewerActivity.java:25)
at android.app.Activity.performCreate(Activity.java:7224)
at android.app.Activity.performCreate(Activity.java:7213)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2926)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3081) 
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) 
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:201) 
at android.app.ActivityThread.main(ActivityThread.java:6810) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873) 

Null Pointer Error when using setImageBitmap for ImageView

Hi,

I am trying to display an image from the gallery using Mediastore but when I run the below code, the pdf doesnt launch but crashes with an error saying below. Can you please guide? It is the only issue with launching this feature... inability to display image from gallery on pdf.

   java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter exception
        at in.trial.trial.Invoicing.ui.downloadInvoicePdf$onCreate$1.pdfGenerationFailure(Unknown Source:2)
        at com.tejpratapsingh.pdfcreator.activity.PDFCreatorActivity$1.pdfGenerationFailure(PDFCreatorActivity.java:128)
        at com.tejpratapsingh.pdfcreator.utils.PDFUtil$GeneratePDFAsync.onPostExecute(PDFUtil.java:192)
        at com.tejpratapsingh.pdfcreator.utils.PDFUtil$GeneratePDFAsync.onPostExecute(PDFUtil.java:129)
if(user.logoUrl != null){
    val uri = user.logoUrl!!.toUri()
    try {
            if(Build.VERSION.SDK_INT < 28) {
                bitmap = MediaStore.Images.Media.getBitmap(
                    this.contentResolver,
                    uri
                )
            } else {
                val source = ImageDecoder.createSource(this.contentResolver, uri)
                bitmap = ImageDecoder.decodeBitmap(source)
            }
    } catch (e: Exception) {
        e.printStackTrace()
    }
    Log.i("Link", bitmap.toString())
    imageView.setImageBitmap(bitmap)
    imageLayoutParam.setMargins(0, 0, 10, 10)
    imageView.setLayout(imageLayoutParam)
    horizontalView.addView(imageView)
}

Arabic contents in PDFs generated from HTML

I am using the library in my android app since first release on March 2021. the generation from HTML with arabic contents was fine in first release. but when I published new release this month with new build, some devices running Android 11 especially OPPO phones (not all) fails to render arabic contents in the PDFs (it was working before but fails in the new release). I tried to embed fonts (attach the base64 string in the css) that support arabic in the HTML but with no luck.

Could you please help.

PDF size issue

I am also facing the same size issue with different cases.
1st generated PDF without adding any image - PDF size 355 Kb.
Then again generate pdf by adding one image (122 kb - compressed image) - PDF size 1.5 Mb
Then again generate pdf by adding same size 5 images (122 kb - compressed image) - PDF size 8 Mb.

Please reduce the pdf size issue. When pdf contains 12-15 images that size reach at 30 Mb it's so big size for document.

Thanks

Page size and color

Hi Tej,

Anyway we can possibly add background colors to the page and change by section? Cant figure it out

Also, where is the page size fixed, seems to be A4 need it to be custom.

Thanks,
Avinash

Page Orientation

I can't find a function to adjust the PDF page orientation. Like portrait orientation or landscape orientation.

Y

H

How can I customize the table

Hi @tejpratap46,
How can I customize the table with my own style. I want to generate a PDF like different tables and some of the table consist of col-span and row-span. If any options available in the PDFTableView please inform. I did not find anything about the style properties of Table.

Text Hide while creating PDF

I try to create PDF using data from database. While generating the PDF preview file, text cut off. Can you please help me.
Screenshot_20191108-121503

Pdf size issue

some devices creating the same content pdf in different sizes..some times get the file around 400kb and some times it more than 4MB...is there any solution for that ?

Print preview is set visible after pdfGenerationSuccess

layoutPrintPreview is set visible on pdfGenerationSuccess. makes the application show preview. According to my requirement, I should show it in my custom view. So the default preview opens and then my custom view opens up.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.