I am trying to confirm whether   tokens all together??tokens got by the code   
??List tokens = parser.getTokens();???? contains the entire information of the 
pdf file.




------------------ ???????? ------------------
??????: "Andreas Lehmkuehler";<[email protected]>;
????????: 2013??9??24??(??????) ????11:59
??????: "users"<[email protected]>; 

????: Re: What is different from the input pdf file and output pdf file??



Hi,

Am 24.09.2013 08:04, schrieb ??????????:
> package copyfile;
>
>
> import java.text.SimpleDateFormat;
> import java.util.List;
> import org.apache.pdfbox.pdfparser.PDFStreamParser;
> import org.apache.pdfbox.pdfwriter.ContentStreamWriter;
> import org.apache.pdfbox.pdmodel.PDDocument;
> import org.apache.pdfbox.pdmodel.PDDocumentCatalog;
> import org.apache.pdfbox.pdmodel.PDPage;
> import org.apache.pdfbox.pdmodel.common.PDStream;
>
>
> public class cpfile {
>       static String inputfile = "d:/pdf????/7.pdf";
>       static String outputfile = inputfile.replace(".pdf", "cp.pdf");
>
>
>       public static void main(String[] args) {
>               dealone(inputfile);
>       }
>
>
>       private static void dealone(String f) {
>               PDDocument document = null;
>               try {
>                       document = PDDocument.load(f);
>                       PDDocumentCatalog catalog = 
> document.getDocumentCatalog();
>                       List<PDPage> pages = catalog.getAllPages();
>                       for (Object pageObj : catalog.getAllPages()) {
>                               PDPage page = (PDPage) pageObj;
>                               PDFStreamParser parser = new 
> PDFStreamParser(page.getContents());
>                               parser.parse();
>                               List tokens = parser.getTokens();
>
>
>                               PDStream newContents = new PDStream(document);
>                               ContentStreamWriter writer = new 
> ContentStreamWriter(
>                                               
> newContents.createOutputStream());
>                               writer.writeTokens(tokens);
>                               newContents.addCompression();
>                               page.setContents(newContents);
>                       }
>                       document.save(outputfile);
>
>
>               } catch (Exception e) {
>                       e.printStackTrace();
>               } finally {
>                       try {
>                               document.close();
>                       } catch (Exception e) {
>                               e.printStackTrace();
>                       }
>
>
>               }
>
>
>       }
> }
What are you trying to do?

BR
Andreas Lehmk??hler

.

Reply via email to