@@ -0,0 +1,3747 @@
+/*%0A * Copyright 2017 Datalogics, Inc.%0A */%0A%0Apackage com.datalogics.pdf.samples.manipulation;%0A%0Aimport com.adobe.internal.io.ByteWriter;%0Aimport com.adobe.pdfjt.core.exceptions.PDFIOException;%0Aimport com.adobe.pdfjt.core.exceptions.PDFInvalidDocumentException;%0Aimport com.adobe.pdfjt.core.exceptions.PDFInvalidParameterException;%0Aimport com.adobe.pdfjt.core.exceptions.PDFInvalidXMLException;%0Aimport com.adobe.pdfjt.core.exceptions.PDFSecurityException;%0Aimport com.adobe.pdfjt.core.exceptions.PDFUnableToCompleteOperationException;%0Aimport com.adobe.pdfjt.core.license.LicenseManager;%0Aimport com.adobe.pdfjt.pdf.document.PDFDocument;%0Aimport com.adobe.pdfjt.pdf.document.PDFSaveFullOptions;%0A%0Aimport com.datalogics.pdf.samples.util.DocumentUtils;%0Aimport com.datalogics.pdf.samples.util.IoUtils;%0A%0Aimport java.io.IOException;%0Aimport java.net.URL;%0A%0A/**%0A * This sample demonstrates how to remove metadata from a PDF.%0A */%0Apublic final class RemoveMetadata %7B%0A    public static final String OUTPUT_PDF_PATH = %22MetadataRemoved.pdf%22;%0A    public static final String INPUT_PDF_PATH = %22pdfjavatoolkit-ds.pdf%22;%0A%0A    /**%0A     * This is a utility class, and won't be instantiated.%0A     */%0A    private RemoveMetadata() %7B%7D%0A%0A    /**%0A     * Main program.%0A     *%0A     * @param args command line arguments%0A     * @throws Exception a general exception was thrown%0A     */%0A    public static void main(final String... args)%0A                    throws Exception %7B%0A        // If you are using an evaluation version of the product (License Managed, or LM), set the path to where PDFJT%0A        // can find the license file.%0A        //%0A        // If you are not using an evaluation version of the product you can ignore or remove this code.%0A        LicenseManager.setLicensePath(%22.%22);%0A%0A        URL inputUrl = null;%0A        URL outputUrl = null;%0A        if (args.length %3E 0) %7B%0A            inputUrl = IoUtils.createUrlFromPath(args%5B0%5D);%0A            outputUrl = IoUtils.createUrlFromPath(args%5B1%5D);%0A        %7D else %7B%0A            inputUrl = RemoveMetadata.class.getResource(INPUT_PDF_PATH);%0A            outputUrl = IoUtils.createUrlFromPath(OUTPUT_PDF_PATH);%0A        %7D%0A%0A        removeMetadata(inputUrl, outputUrl);%0A    %7D%0A%0A    /**%0A     * Removes metadata from the supplied pdf and replaces it with metadata as if the pdf was just created. Doing a full%0A     * save prevents forensic discovery.%0A     *%0A     * @param inputUrl the path to read the input PDF from%0A     * @param outputUrl the path to output the pdf%0A     * @throws PDFInvalidDocumentException a general problem with the PDF document, which may now be in an invalid state%0A     * @throws PDFIOException there was an error reading or writing a PDF file or temporary caches%0A     * @throws PDFSecurityException some general security issue occurred during the processing of the request%0A     * @throws IOException some general io error occurred%0A     * @throws PDFInvalidXMLException there was a problem processing an XML file%0A     * @throws PDFUnableToCompleteOperationException the operation was unable to be completed%0A     * @throws PDFInvalidParameterException one or more of the parameters passed to a method is invalid%0A     */%0A    public static void removeMetadata(final URL inputUrl, final URL outputUrl)%0A                    throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException, IOException,%0A                    PDFInvalidXMLException, PDFUnableToCompleteOperationException, PDFInvalidParameterException %7B%0A        final PDFDocument document = DocumentUtils.openPdfDocument(inputUrl);%0A%0A        document.removeMetadata();%0A%0A        final ByteWriter writer = IoUtils.newByteWriter(outputUrl);%0A        document.save(writer, PDFSaveFullOptions.newInstance());%0A        writer.close();%0A        document.close();%0A    %7D%0A%7D%0A

Add RemoveMetadata sample