Ejemplo n.º 1
0
// ---------------------------------------------------------------------------
    public void Write(Stream stream) {
      using (ZipFile zip = new ZipFile()) {
        NestedTables n = new NestedTables(); 
        byte[] pdf = Utility.PdfBytes(n);
        Advertisement a = new Advertisement();
        zip.AddEntry(RESULT, a.ManipulatePdf(pdf));       
        zip.AddEntry(Utility.ResultFileName(n.ToString() + ".pdf"), pdf);
        zip.AddFile(RESOURCE, "");
        zip.Save(stream);             
      }
    }
Ejemplo n.º 2
0
// --------------------------------------------------------------------------- 
    public void Write(Stream stream) {
      using (ZipFile zip = new ZipFile()) {
        NestedTables n = new NestedTables(); 
        byte[] ntPdf = Utility.PdfBytes(n);      
        Advertisement a = new Advertisement();
        byte[] aPdf = a.ManipulatePdf(ntPdf);

        PdfReader reader = new PdfReader(aPdf);
        using (MemoryStream ms = new MemoryStream()) {
          using (PdfStamper stamper = new PdfStamper(reader, ms)) {
            AcroFields form = stamper.AcroFields;
            PushbuttonField ad = form.GetNewPushbuttonFromField("advertisement");
            ad.Layout = PushbuttonField.LAYOUT_ICON_ONLY;
            ad.ProportionalIcon = true;
            ad.Image = Image.GetInstance(RESOURCE);
            form.ReplacePushbuttonField("advertisement", ad.Field);
          }
          zip.AddEntry(RESULT, ms.ToArray());
        }
        zip.AddFile(RESOURCE, "");
        zip.AddEntry(Utility.ResultFileName(a.ToString() + ".pdf"), aPdf);                
        zip.Save(stream);             
      }
    }