"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "examples/src/main/java/org/apache/pdfbox/examples/pdmodel/CreateGradientShadingPDF.java" between
pdfbox-2.0.23-src.zip and pdfbox-2.0.24-src.zip

About: Apache PDFBox is a Java PDF library tool that allows creation of new PDF documents, manipulation of existing documents and the ability to extract content from documents.

CreateGradientShadingPDF.java  (pdfbox-2.0.23-src):CreateGradientShadingPDF.java  (pdfbox-2.0.24-src)
skipping to change at line 18 skipping to change at line 18
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.pdfbox.examples.pdmodel; package org.apache.pdfbox.examples.pdmodel;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import javax.imageio.ImageIO;
import javax.imageio.stream.MemoryCacheImageOutputStream; import javax.imageio.stream.MemoryCacheImageOutputStream;
import org.apache.pdfbox.cos.COSArray; import org.apache.pdfbox.cos.COSArray;
import org.apache.pdfbox.cos.COSDictionary; import org.apache.pdfbox.cos.COSDictionary;
import org.apache.pdfbox.cos.COSInteger; import org.apache.pdfbox.cos.COSInteger;
import org.apache.pdfbox.cos.COSName; import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.cos.COSNumber; import org.apache.pdfbox.cos.COSNumber;
import org.apache.pdfbox.cos.COSStream; import org.apache.pdfbox.cos.COSStream;
import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage; import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.common.function.PDFunctionType2; import org.apache.pdfbox.pdmodel.common.function.PDFunctionType2;
import org.apache.pdfbox.pdmodel.PDPageContentStream; import org.apache.pdfbox.pdmodel.PDPageContentStream;
import org.apache.pdfbox.pdmodel.PDPageContentStream.AppendMode; import org.apache.pdfbox.pdmodel.PDPageContentStream.AppendMode;
import org.apache.pdfbox.pdmodel.graphics.color.PDDeviceRGB; import org.apache.pdfbox.pdmodel.graphics.color.PDDeviceRGB;
import org.apache.pdfbox.pdmodel.graphics.shading.PDShading; import org.apache.pdfbox.pdmodel.graphics.shading.PDShading;
import org.apache.pdfbox.pdmodel.graphics.shading.PDShadingType2; import org.apache.pdfbox.pdmodel.graphics.shading.PDShadingType2;
import org.apache.pdfbox.pdmodel.graphics.shading.PDShadingType3; import org.apache.pdfbox.pdmodel.graphics.shading.PDShadingType3;
import org.apache.pdfbox.pdmodel.graphics.shading.PDShadingType4; import org.apache.pdfbox.pdmodel.graphics.shading.PDShadingType4;
import org.apache.pdfbox.rendering.PDFRenderer;
/** /**
* This example creates a PDF with type 2 (axial) and type 3 (radial) shadings w ith a type 2 * This example creates a PDF with type 2 (axial) and type 3 (radial) shadings w ith a type 2
* (exponential) function, and a type 4 (gouraud triangle shading) without funct ion. * (exponential) function, and a type 4 (gouraud triangle shading) without funct ion.
* *
* @author Tilman Hausherr * @author Tilman Hausherr
*/ */
public class CreateGradientShadingPDF public class CreateGradientShadingPDF
{ {
skipping to change at line 197 skipping to change at line 195
// invoke shading from content stream // invoke shading from content stream
// compress parameter is set to false so that you can see the stream in a text editor // compress parameter is set to false so that you can see the stream in a text editor
PDPageContentStream contentStream = new PDPageContentStream(document , page, AppendMode.APPEND, false); PDPageContentStream contentStream = new PDPageContentStream(document , page, AppendMode.APPEND, false);
contentStream.shadingFill(axialShading); contentStream.shadingFill(axialShading);
contentStream.shadingFill(radialShading); contentStream.shadingFill(radialShading);
contentStream.shadingFill(gouraudShading); contentStream.shadingFill(gouraudShading);
contentStream.close(); contentStream.close();
document.save(file); document.save(file);
document.close(); document.close();
// render the PDF and save it into a PNG file
document = PDDocument.load(new File(file));
BufferedImage bim = new PDFRenderer(document).renderImageWithDPI(0,
100);
ImageIO.write(bim, "png", new File(file + ".png"));
document.close();
} }
finally finally
{ {
if (document != null) if (document != null)
{ {
document.close(); document.close();
} }
} }
} }
 End of changes. 5 change blocks. 
11 lines changed or deleted 2 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)