Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.apache.poi.xslf.util;
import java.awt.AlphaComposite;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.Dimension2D;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.poi.common.usermodel.GenericRecord;
import org.apache.poi.poifs.filesystem.FileMagic;
import org.apache.poi.sl.draw.Drawable;
import org.apache.poi.sl.draw.EmbeddedExtractor.EmbeddedPart;
import org.apache.poi.util.Dimension2DDouble;
import org.apache.poi.util.GenericRecordJsonWriter;
import org.apache.poi.util.LocaleUtil;
/**
* An utility to convert slides of a .pptx slide show to a PNG image
*/
public final class PPTX2PNG {
private static final Logger LOG = LogManager.getLogger(PPTX2PNG.class);
private static final String INPUT_PAT_REGEX =
"(?[^|]+)\\|(?[^|]+)\\|(?.+)\\.(?[^.]++)";
private static final Pattern INPUT_PATTERN = Pattern.compile(INPUT_PAT_REGEX);
private static final String OUTPUT_PAT_REGEX = "${basename}-${slideno}.${format}";
private static void usage(String error){
String msg =
"Usage: PPTX2PNG [options] <.ppt/.pptx/.emf/.wmf file or 'stdin'>\n" +
(error == null ? "" : ("Error: "+error+"\n")) +
"Options:\n" +
" -scale scale factor\n" +
" -fixSide specify side (long,short,width,height) to fix - use as amount of pixels\n" +
" -slide 1-based index of a slide to render\n" +
" -format png,gif,jpg,svg,pdf (,log,null for testing)\n" +
" -outdir output directory, defaults to origin of the ppt/pptx file\n" +
" -outfile output filename, defaults to '"+OUTPUT_PAT_REGEX+"'\n" +
" -outpat output filename pattern, defaults to '"+OUTPUT_PAT_REGEX+"'\n" +
" patterns: basename, slideno, format, ext\n" +
" -dump dump the annotated records to a file\n" +
" -quiet do not write to console (for normal processing)\n" +
" -ignoreParse ignore parsing error and continue with the records read until the error\n" +
" -extractEmbedded extract embedded parts\n" +
" -inputType default input file type (OLE2,WMF,EMF), default is OLE2 = Powerpoint\n" +
" some files (usually wmf) don't have a header, i.e. an identifiable file magic\n" +
" -textAsShapes text elements are saved as shapes in SVG, necessary for variable spacing\n" +
" often found in math formulas\n" +
" -charset sets the default charset to be used, defaults to Windows-1252\n" +
" -emfHeaderBounds force the usage of the emf header bounds to calculate the bounding box\n" +
" -fontdir (PDF only) font directories separated by \";\" - use $HOME for current users home dir\n" +
" defaults to the usual plattform directories\n" +
" -fontTtf (PDF only) regex to match the .ttf filenames\n" +
" -fontMap