Esempio n. 1
0
        public unsafe static SKDocument CreatePdf(SKWStream stream, SKDocumentPdfMetadata metadata, float dpi = DefaultRasterDpi)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            using (var title = SKString.Create(metadata.Title))
                using (var author = SKString.Create(metadata.Author))
                    using (var subject = SKString.Create(metadata.Subject))
                        using (var keywords = SKString.Create(metadata.Keywords))
                            using (var creator = SKString.Create(metadata.Creator))
                                using (var producer = SKString.Create(metadata.Producer)) {
                                    var cmetadata = new SKDocumentPdfMetadataInternal {
                                        Title    = title?.Handle ?? IntPtr.Zero,
                                        Author   = author?.Handle ?? IntPtr.Zero,
                                        Subject  = subject?.Handle ?? IntPtr.Zero,
                                        Keywords = keywords?.Handle ?? IntPtr.Zero,
                                        Creator  = creator?.Handle ?? IntPtr.Zero,
                                        Producer = producer?.Handle ?? IntPtr.Zero
                                    };
                                    if (metadata.Creation != null)
                                    {
                                        var creation = SKTimeDateTimeInternal.Create(metadata.Creation.Value);
                                        cmetadata.Creation = &creation;
                                    }
                                    if (metadata.Modified != null)
                                    {
                                        var modified = SKTimeDateTimeInternal.Create(metadata.Modified.Value);
                                        cmetadata.Modified = &modified;
                                    }

                                    return(GetObject <SKDocument> (SkiaApi.sk_document_create_pdf_from_stream_with_metadata(stream.Handle, dpi, ref cmetadata)));
                                }
        }
Esempio n. 2
0
 static SKDocumentPdfMetadata()
 {
     Default = new SKDocumentPdfMetadata()
     {
         RasterDpi       = DefaultRasterDpi,
         PdfA            = false,
         EncodingQuality = 101,
     };
 }
Esempio n. 3
0
        public static SKDocument CreatePdf(Stream stream, SKDocumentPdfMetadata metadata)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            var managed = new SKManagedWStream(stream);

            return(Owned(CreatePdf(managed, metadata), managed));
        }
Esempio n. 4
0
        public static SKDocument CreatePdf(string path, SKDocumentPdfMetadata metadata)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            var stream = SKFileWStream.OpenStream(path);

            return(Owned(CreatePdf(stream, metadata), stream));
        }
Esempio n. 5
0
        public static SKDocument CreatePdf(SKWStream stream, SKDocumentPdfMetadata metadata)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            using (var title = SKString.Create(metadata.Title))
                using (var author = SKString.Create(metadata.Author))
                    using (var subject = SKString.Create(metadata.Subject))
                        using (var keywords = SKString.Create(metadata.Keywords))
                            using (var creator = SKString.Create(metadata.Creator))
                                using (var producer = SKString.Create(metadata.Producer)) {
                                    var cmetadata = new SKDocumentPdfMetadataInternal {
                                        fTitle           = title?.Handle ?? IntPtr.Zero,
                                        fAuthor          = author?.Handle ?? IntPtr.Zero,
                                        fSubject         = subject?.Handle ?? IntPtr.Zero,
                                        fKeywords        = keywords?.Handle ?? IntPtr.Zero,
                                        fCreator         = creator?.Handle ?? IntPtr.Zero,
                                        fProducer        = producer?.Handle ?? IntPtr.Zero,
                                        fRasterDPI       = metadata.RasterDpi,
                                        fPDFA            = metadata.PdfA ? (byte)1 : (byte)0,
                                        fEncodingQuality = metadata.EncodingQuality,
                                    };

                                    SKTimeDateTimeInternal creation;
                                    if (metadata.Creation != null)
                                    {
                                        creation            = SKTimeDateTimeInternal.Create(metadata.Creation.Value);
                                        cmetadata.fCreation = &creation;
                                    }
                                    SKTimeDateTimeInternal modified;
                                    if (metadata.Modified != null)
                                    {
                                        modified            = SKTimeDateTimeInternal.Create(metadata.Modified.Value);
                                        cmetadata.fModified = &modified;
                                    }

                                    return(Referenced(GetObject <SKDocument> (SkiaApi.sk_document_create_pdf_from_stream_with_metadata(stream.Handle, &cmetadata)), stream));
                                }
        }
Esempio n. 6
0
 public static SKDocument CreatePdf(SKWStream stream, SKDocumentPdfMetadata metadata, float dpi)
 {
     metadata.RasterDpi = dpi;
     return(CreatePdf(stream, metadata));
 }