HI all,

I am trying to convert pptx file containing a custom theme and two text
boxes to pdf. I am able to convert into PDF, but the theme  size is reduced
and the two text box is printed on a white background.Any insights will be
helpful.
Code below,

static void convertToPdf(String fileName) throws IOException,
DocumentException {
>     FileInputStream inputStream = new FileInputStream(pptLocation + fileName 
> + PPT);
>     double zoom = 2;
>     AffineTransform at = new AffineTransform();
>     at.setToScale(zoom, zoom);
>     Document pdfDocument = new Document();
>     PdfWriter pdfWriter = PdfWriter.getInstance(pdfDocument, new 
> FileOutputStream(pdfLocation + fileName + PDF));
>     PdfPTable table = new PdfPTable(1);
>     pdfWriter.open();
>     pdfDocument.open();
>     Dimension pgsize = null;
>     Image slideImage = null;
>     BufferedImage img = null;
>
>
>     XMLSlideShow ppt = new XMLSlideShow(inputStream);
>     pgsize = ppt.getPageSize();
>     List<XSLFSlide> slides = ppt.getSlides();
>     pdfDocument.setPageSize(new Rectangle((float) pgsize.getWidth(), (float) 
> pgsize.getHeight()));
>     pdfWriter.open();
>     pdfDocument.open();
>     for (int i = 0; i < slides.size(); i++) {
>         img = new BufferedImage((int) Math.ceil(pgsize.width * zoom), (int) 
> Math.ceil(pgsize.height * zoom), BufferedImage.TYPE_INT_RGB);
>         Graphics2D graphics = img.createGraphics();
>         graphics.setTransform(at);
>
>         graphics.setPaint(Color.white);
>         graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, 
> pgsize.height));
>         slides.get(i).draw(graphics);
>         graphics.getPaint();
>         slideImage = Image.getInstance(img, null);
>         table.addCell(new PdfPCell(slideImage, false));
>
>     }
>     pdfDocument.add(table);
>     pdfDocument.close();
>     pdfWriter.close();
>
> }
>
>

Reply via email to