Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48977

PDF Size Issue with PDFMake Wrapper

$
0
0

Dear All,

I have used PDFmake-Wrapper in our application and it is generating PDF as expected but I am facing issue with size of the PDF.

In my PDF Design (see attachment) I have only 1 image with dimension 500 X 300 and single line text per page and image size is 6 MB (Max), One page size reached to 30 MB i.e. 5 times more than an image size.

Also suggest, if other better plugins are available in the market.

Please find our code below:

async generatePDF(blockNo:any,App:any) {
PdfMakeWrapper.setFonts(pdfFonts);
const pdf = new PdfMakeWrapper();
var i = 0;
for(var image of this.ImageList)
{
if(image){
if(i%2==0 && i>0)
{
pdf.add(new Txt('Item Name: ').bold().pageBreak(‘before’).end);
pdf.add(new Txt(this.PartDesc).end);
pdf.add(new Txt('Block No: ').bold().end);
pdf.add(new Txt(blockNo).end);
}
else if(i==0)
{
pdf.add(new Txt('Item Name: ').bold().end);
pdf.add(new Txt(this.PartDesc).end);
pdf.add(new Txt('Block No: ').bold().end);
pdf.add(new Txt(blockNo).end);
}

      pdf.add(pdf.ln(2));
      const img = await (new Img(image).fit([500,300]).build());
      pdf.add( img );
      i++;
    }   
  }
  if(i>0)
  {
     pdf.create().getBase64(x=>{
    this.shareBlockImage(blockNo,'data:application/pdf;base64,'+x,App) 
    }); 
  }
  else
    alert('Please select any image.');

}

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 48977

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>