コード例 #1
0
ファイル: Includes.cs プロジェクト: science-docs/Scriber
        public static PdfElement?IncludePdf(CompilerState state, [Argument(ProposalProvider = typeof(IncludePdfFileProposalProvider))] Argument <string> path, Argument <PdfIncludeOptions>?options = null)
        {
            var uri   = state.Context.ResourceSet.RelativeUri(path.Value);
            var bytes = state.Context.ResourceSet.GetBytes(uri);

            var fields = options?.Value?.Fields;

            if (fields != null)
            {
                bytes = FillPdfDocument(bytes, fields);
            }

            var document = PdfReader.Open(new MemoryStream(bytes), PdfDocumentOpenMode.Import);
            var range    = options?.Value?.Range;

            if (range != null)
            {
                (int start, int end) = range.Value.GetOffsetAndLength(document.PageCount);
                if (start < 0 || start >= document.PageCount || end < 0 || end >= document.PageCount)
                {
                    throw new CompilerException(options?.Source, $"Invalid range {start}-{end} specified. For the specified document the range is limited to {start}-{end}.");
                }
            }

            var element = new PdfElement(document);

            if (range != null)
            {
                element.Range = range.Value;
            }
            return(element);
        }
コード例 #2
0
ファイル: PdfPage.cs プロジェクト: dotnetchris/nfx
        /// <summary>
        /// Adds PDF element to page's elements collection
        /// </summary>
        public void Add(PdfElement element)
        {
            if (m_Elements.Contains(element))
            {
                throw new InvalidOperationException("The element has already been added");
            }

            m_Elements.Add(element);
        }
コード例 #3
0
 public PdfExtGState(PdfElement elem, PdfFile file)
     : base(elem)
 {
     _file = file;
 }
コード例 #4
0
 public PdfDocumentPage(Document document, PdfElement element) : base(document)
 {
     Element = element;
 }