예제 #1
0
 protected void ImportAll(PdfImage dup)
 {
     name             = dup.name;
     compressed       = dup.compressed;
     compressionLevel = dup.compressionLevel;
     streamBytes      = dup.streamBytes;
     bytes            = dup.bytes;
     hashMap          = dup.hashMap;
 }
예제 #2
0
 /**
 * Writes a <CODE>PdfImage</CODE> to the outputstream.
 *
 * @param pdfImage the image to be added
 * @return a <CODE>PdfIndirectReference</CODE> to the encapsulated image
 * @throws PdfException when a document isn't open yet, or has been closed
 */
 internal virtual PdfIndirectReference Add(PdfImage pdfImage, PdfIndirectReference fixedRef)
 {
     if (! imageDictionary.Contains(pdfImage.Name)) {
         PdfXConformanceImp.CheckPDFXConformance(this, PdfXConformanceImp.PDFXKEY_IMAGE, pdfImage);
         if (fixedRef is PRIndirectReference) {
             PRIndirectReference r2 = (PRIndirectReference)fixedRef;
             fixedRef = new PdfIndirectReference(0, GetNewObjectNumber(r2.Reader, r2.Number, r2.Generation));
         }
         if (fixedRef == null)
             fixedRef = AddToBody(pdfImage).IndirectReference;
         else
             AddToBody(pdfImage, fixedRef);
         imageDictionary.Put(pdfImage.Name, fixedRef);
         return fixedRef;
     }
     return (PdfIndirectReference)imageDictionary.Get(pdfImage.Name);
 }
예제 #3
0
 /**
 * Adds an image to the document but not to the page resources. It is used with
 * templates and <CODE>Document.Add(Image)</CODE>.
 * @param image the <CODE>Image</CODE> to add
 * @param fixedRef the reference to used. It may be <CODE>null</CODE>,
 * a <CODE>PdfIndirectReference</CODE> or a <CODE>PRIndirectReference</CODE>.
 * @return the name of the image added
 * @throws PdfException on error
 * @throws DocumentException on error
 */
 public PdfName AddDirectImageSimple(Image image, PdfIndirectReference fixedRef)
 {
     PdfName name;
     // if the images is already added, just retrieve the name
     if (images.ContainsKey(image.MySerialId)) {
         name = (PdfName) images[image.MySerialId];
     }
     // if it's a new image, add it to the document
     else {
         if (image.IsImgTemplate()) {
             name = new PdfName("img" + images.Count);
             if (image is ImgWMF){
                 ImgWMF wmf = (ImgWMF)image;
                 wmf.ReadWMF(PdfTemplate.CreateTemplate(this, 0, 0));
             }
         }
         else {
             PdfIndirectReference dref = image.DirectReference;
             if (dref != null) {
                 PdfName rname = new PdfName("img" + images.Count);
                 images[image.MySerialId] = rname;
                 imageDictionary.Put(rname, dref);
                 return rname;
             }
             Image maskImage = image.ImageMask;
             PdfIndirectReference maskRef = null;
             if (maskImage != null) {
                 PdfName mname = (PdfName)images[maskImage.MySerialId];
                 maskRef = GetImageReference(mname);
             }
             PdfImage i = new PdfImage(image, "img" + images.Count, maskRef);
             if (image is ImgJBIG2) {
                 byte[] globals = ((ImgJBIG2) image).GlobalBytes;
                 if (globals != null) {
                     PdfDictionary decodeparms = new PdfDictionary();
                     decodeparms.Put(PdfName.JBIG2GLOBALS, GetReferenceJBIG2Globals(globals));
                     i.Put(PdfName.DECODEPARMS, decodeparms);
                 }
             }
             if (image.HasICCProfile()) {
                 PdfICCBased icc = new PdfICCBased(image.TagICC, image.CompressionLevel);
                 PdfIndirectReference iccRef = Add(icc);
                 PdfArray iccArray = new PdfArray();
                 iccArray.Add(PdfName.ICCBASED);
                 iccArray.Add(iccRef);
                 PdfArray colorspace = i.GetAsArray(PdfName.COLORSPACE);
                 if (colorspace != null) {
                     if (colorspace.Size > 1 && PdfName.INDEXED.Equals(colorspace[0]))
                         colorspace[1] = iccArray;
                     else
                         i.Put(PdfName.COLORSPACE, iccArray);
                 }
                 else
                     i.Put(PdfName.COLORSPACE, iccArray);
             }
             Add(i, fixedRef);
             name = i.Name;
         }
         images[image.MySerialId] = name;
     }
     return name;
 }
예제 #4
0
 protected void ImportAll(PdfImage dup)
 {
     name = dup.name;
     compressed = dup.compressed;
     compressionLevel = dup.compressionLevel;
     streamBytes = dup.streamBytes;
     bytes = dup.bytes;
     hashMap = dup.hashMap;
 }