Search code examples
androidpdfpdf-generation

PrintedPdfDocument vs PdfDocument


Could not find much difference in the Doc

What is the difference between them ? and when one should prefer one over other ?

For Android PDF Generation


Solution

  • PrintedPdfDocument It is an auxiliary class.

    For example, it takes the value of printAttributes.

    Sample UseCase

    val printAttributes = PrintAttributes.Builder()
                .setColorMode(PrintAttributes.COLOR_MODE_COLOR)
                .setMediaSize(pageSize.pageType)
                .setResolution(PrintAttributes.Resolution("res1", "300_DPI", 300, 300))
                .setMinMargins(PrintAttributes.Margins.NO_MARGINS)
                .build()
    
            doc = PrintedPdfDocument(context, printAttributes)
    

    As you can see, you can make customizations.

    The most important point

    public class PrintedPdfDocument extends PdfDocument
    

    It is extended from the PdfDocument class.

    If you are going to do customization, I recommend using PrintedPdfDocument .