Esempio n. 1
1
// ---------------------------------------------------------------------------
    public void Write(Stream stream) {
      MovieTemplates mt = new MovieTemplates();
      byte[] pdf = Utility.PdfBytes(mt);
      PdfReader reader = new PdfReader(pdf);
      using (ZipFile zip = new ZipFile()) {
        reader.SelectPages("4-8");
        zip.AddEntry(RESULT1, ManipulateWithStamper(reader));
/*
 * can't figure out __WHY__, but if i don't reset the reader the example
 * will __NOT__ work!
 */
        reader = new PdfReader(pdf);
        reader.SelectPages("4-8"); 
        zip.AddEntry(RESULT2, ManipulateWithCopy(reader));       
        zip.AddEntry(Utility.ResultFileName(mt.ToString() + ".pdf"), pdf);
        zip.Save(stream);
      }
    }
Esempio n. 2
0
// ---------------------------------------------------------------------------
    public void Write(Stream stream) {
      // use one of the previous examples to create a PDF
      MovieTemplates mt = new MovieTemplates();
      // Create a reader
      byte[] pdf = Utility.PdfBytes(mt);
      PdfReader reader = new PdfReader(pdf);
      // loop over all the pages in the original PDF
      int n = reader.NumberOfPages;      
      using (ZipFile zip = new ZipFile()) {
        for (int i = 0; i < n; ) {
          string dest = string.Format(RESULT, ++i);
          using (MemoryStream ms = new MemoryStream()) {
// We'll create as many new PDFs as there are pages
            // step 1
            using (Document document = new Document()) {
              // step 2
              using (PdfCopy copy = new PdfCopy(document, ms)) {
                // step 3
                document.Open();
                // step 4
                copy.AddPage(copy.GetImportedPage(reader, i));
              }
            }
            zip.AddEntry(dest, ms.ToArray());
          }
        }
        zip.AddEntry(Utility.ResultFileName(mt.ToString() + ".pdf"), pdf);
        zip.Save(stream);       
      }
    }
Esempio n. 3
0
// ---------------------------------------------------------------------------
    public void Write(Stream stream) {
      // Use old example to create PDF
      MovieTemplates mt = new MovieTemplates();
      byte[] pdf = Utility.PdfBytes(mt);
      using (ZipFile zip = new ZipFile()) { 
        using (MemoryStream ms = new MemoryStream()) {
          // step 1
          using (Document document = new Document()) {
            // step 2
            PdfWriter writer = PdfWriter.GetInstance(document, ms);
            // step 3
            document.Open();
            // step 4
            PdfPTable table = new PdfPTable(2);
            PdfReader reader = new PdfReader(pdf);
            int n = reader.NumberOfPages;
            PdfImportedPage page;
            for (int i = 1; i <= n; i++) {
              page = writer.GetImportedPage(reader, i);
              table.AddCell(Image.GetInstance(page));
            }
            document.Add(table);
          }
          zip.AddEntry(RESULT, ms.ToArray());           
        }
        zip.AddEntry(Utility.ResultFileName(mt.ToString() + ".pdf"), pdf);
        zip.Save(stream);
      }
   }
Esempio n. 4
0
// ---------------------------------------------------------------------------    
    public void Write(Stream stream) {
      using (ZipFile zip = new ZipFile()) { 
        MovieTemplates m = new MovieTemplates();
        byte[] pdf = Utility.PdfBytes(m); 
        zip.AddEntry(RESULT, new NamedActions().ManipulatePdf(pdf)); 
        zip.AddEntry(Utility.ResultFileName(m.ToString() + ".pdf"), pdf);
        zip.Save(stream);             
      }
    }
Esempio n. 5
0
// --------------------------------------------------------------------------- 
    public override void Write(Stream stream) {
      using (ZipFile zip = new ZipFile()) {
        MovieTemplates m = new MovieTemplates(); 
        byte[] pdf = Utility.PdfBytes(m);
        TimetableAnnotations2 t = new TimetableAnnotations2();
        zip.AddEntry(RESULT, t.ManipulatePdf(pdf));
        zip.AddEntry(Utility.ResultFileName(m.ToString() + ".pdf"), pdf);
        zip.Save(stream);             
      }
    }
Esempio n. 6
0
// --------------------------------------------------------------------------- 
    public void Write(Stream stream) {
      using (ZipFile zip = new ZipFile()) {
        MovieTemplates m = new MovieTemplates();
        byte[] mPdf = Utility.PdfBytes(m);
        zip.AddEntry(Utility.ResultFileName(m.ToString() + ".pdf"), mPdf);
        InspectPageContent i = new InspectPageContent();
        zip.AddEntry(RESULT, i.InspectPdf(mPdf));
        zip.Save(stream);             
      }
    }    
Esempio n. 7
0
// ---------------------------------------------------------------------------
    public void Write(Stream stream) {
      using (ZipFile zip = new ZipFile()) {
        MovieTemplates m = new MovieTemplates(); 
        byte[] pdf = Utility.PdfBytes(m);
        PrintTimeTable p = new PrintTimeTable();
        zip.AddEntry(RESULT, p.ManipulatePdf(pdf));
        zip.AddEntry(RESOURCE, p.jsString);
        zip.AddEntry(Utility.ResultFileName(m.ToString() + ".pdf"), pdf);
        zip.Save(stream);             
      }    
    }
Esempio n. 8
0
// ---------------------------------------------------------------------------      
    public void Write(Stream stream) {
      using (ZipFile zip = new ZipFile()) {
        MovieTemplates m = new MovieTemplates();
        byte[] pdf = Utility.PdfBytes(m);
        BookmarkedTimeTable b = new BookmarkedTimeTable();
        byte[] bttBytes = b.ManipulatePdf(pdf);      
        MovieHistory mh = new MovieHistory(); 
        byte[] mhBytes = Utility.PdfBytes(mh);
        List<byte[]> src = new List<byte[]>() {bttBytes, mhBytes};
        ConcatenateBookmarks cb = new ConcatenateBookmarks();
        zip.AddEntry(RESULT, cb.ManipulatePdf(src));
        zip.AddEntry(Utility.ResultFileName(b.ToString() + ".pdf"), bttBytes);
        zip.AddEntry(Utility.ResultFileName(mh.ToString() + ".pdf"), mhBytes);
        zip.Save(stream);             
      }
    }
Esempio n. 9
0
// ===========================================================================
    public void Write(Stream stream) {
        try
        {
            using (ZipFile zip = new ZipFile())
            {
                using (MemoryStream resultStream = new MemoryStream())
                {
                    using (StreamWriter sw = new StreamWriter(resultStream))
                    {
                        using (MemoryStream movies = new MemoryStream())
                        {
                            // step 1
                            MovieTemplates mt = new MovieTemplates();
                            mt.Write(movies);
                            zip.AddEntry(RESULT0, movies.ToArray());

                            // step 2
                            GarbageCollect();
                            // Do a full read
                            fullRead(sw, movies.ToArray());
                            // Do a partial read
                            partialRead(sw, movies.ToArray());
                            zip.AddEntry(RESULT, resultStream.ToArray());
                        }
                    }
                }
                zip.Save(stream);
            }
        }
        catch(Exception ex)
        {
            Console.WriteLine(ex.StackTrace);
        }
    }