Exemple #1
0
        /// <summary>
        /// Returns the height of given page.
        /// </summary>
        /// <param name="page">Page to examine.</param>
        /// <returns>With of given page.</returns>
        /// <remarks>Used to determine which height should be used - height or thumbnail height.</remarks>
        protected override double PageHeight(IPDFPage page)
        {
            if (page == null)
            {
                throw new ArgumentNullException(nameof(page));
            }

            return(page.Height);
        }
        /// <summary>
        /// Returns the width of given page.
        /// </summary>
        /// <param name="page">Page to examine.</param>
        /// <returns>With of given page.</returns>
        /// <remarks>Used to determine which width should be used - width or thumbnail width.</remarks>
        protected override double PageWidth(IPDFPage page)
        {
            if (page == null)
            {
                throw new ArgumentNullException(nameof(page));
            }

            return(page.ThumbnailWidth);
        }
Exemple #3
0
        /// <summary>
        /// 1) Remove carbon black field(K) from CMYK colorspace from PDF file.
        /// 2) Make Ncoded PDF with Ncode image files.
        /// </summary>
        /// <param name="inputPdfFilename"></param>
        /// <param name="outputPdfFilename"></param>
        /// <param name="ncodeIamgeFilenames"></param>
        void RemoveK_and_AddNcode(string inputPdfFilename, string outputPdfFilename, string[] ncodeIamgeFilenames)
        {
            Console.WriteLine("2) Remove carbon black field(K) from CMYK colorspace from PDF file");
            Console.WriteLine();
            IPDFDocument doc    = lib.openDocument(inputPdfFilename);
            IPDFDocument newDoc = lib.copyDocumentOnlyPageStructure(doc);

            for (int i = 0; i < newDoc.getPageCount(); i++)
            {
                using (IPDFPage newPage = newDoc.getPageObj(i))
                {
                    newPage.convertColorSpaceToCMY(doc);
                }
            }



            Console.WriteLine("3) Make Ncoded PDF with Ncode image files.");
            Console.WriteLine();
            /////////////////////////////////////////////////////////////////////
            // caution : This code will not work unless Ncode image's bpp is 1.
            /////////////////////////////////////////////////////////////////////
            System.IO.MemoryStream[] ms = new System.IO.MemoryStream[ncodeIamgeFilenames.Length];

            for (int i = 0; i < ncodeIamgeFilenames.Length; ++i)
            {
                ms[i] = new System.IO.MemoryStream();
                System.Drawing.Image ss = System.Drawing.Image.FromFile(ncodeIamgeFilenames[i]);
                ss.Save(ms[i], System.Drawing.Imaging.ImageFormat.Tiff);
            }

            for (int j = 0; j < newDoc.getPageCount(); ++j)
            {
                using (var page = newDoc.getPageObj(j))
                {
                    double x0, y0, x1, y1;
                    x0 = y0 = x1 = y1 = 0;

                    page.getPageMediaBox(ref x0, ref y0, ref x1, ref y1, true);
                    page.addImageContentOver_usingStream(ms[j], true, x0, y0, x1, y1);
                }

                ms[j].Dispose();
            }

            newDoc.saveDocumentAs(outputPdfFilename);
            newDoc.closeDocument();
        }
        /// <summary>
        /// Sets all 'current' properties based on given page.
        /// </summary>
        /// <param name="page">Page to use as a source for 'current' properties.</param>
        internal void SetCurrentInformation(IPDFPage page)
        {
            var newPageIndex = 0;
            var newPageLabel = string.Empty;

            if (page != null)
            {
                newPageIndex = page.PageIndex + 1;
                newPageLabel = page.PageLabel;
            }

            if (CurrentPageIndex != newPageIndex)
            {
                CurrentPageIndex = newPageIndex;
                InvokePropertyChangedEvent(nameof(CurrentPageIndex));
            }

            if (!string.Equals(CurrentPageLabel, newPageLabel, StringComparison.Ordinal))
            {
                CurrentPageLabel = newPageLabel;
                InvokePropertyChangedEvent(nameof(CurrentPageLabel));
            }
        }
Exemple #5
0
 /// <summary>
 /// Returns the height of given page.
 /// </summary>
 /// <param name="page">Page to examine.</param>
 /// <returns>Height of given page.</returns>
 /// <remarks>Used to determine which height should be used - height or thumbnail height.</remarks>
 protected abstract double PageHeight(IPDFPage page);
Exemple #6
0
 /// <summary>
 /// Returns the width of given page.
 /// </summary>
 /// <param name="page">Page to examine.</param>
 /// <returns>Width of given page.</returns>
 /// <remarks>Used to determine which width should be used - width or thumbnail width.</remarks>
 protected abstract double PageWidth(IPDFPage page);
Exemple #7
0
        /// <summary>
        /// 1) Remove carbon black field(K) from CMYK colorspace from PDF file.
        /// 2) Make Ncoded PDF with Ncode image files.
        /// </summary>
        /// <param name="inputPdfFilename"></param>
        /// <param name="outputPdfFilename"></param>
        /// <param name="ncodeIamgeFilenames"></param>
        void RemoveK_and_AddNcode_from_Image(string inputPdfFilename, string outputPdfFilename, string[] ncodeIamgeFilenames)
        {
            IPDFDocument doc    = lib.openDocument(inputPdfFilename);
            IPDFDocument newDoc = lib.copyDocument(doc);

            if (doc == null)
            {
                Console.WriteLine("   Cannot open input PDF file.");
                return;
            }

            if (doc.getPageCount() != ncodeImageFilename.Length)
            {
                Console.WriteLine("   Page count is not correct");
                Console.WriteLine("   input PDF pages : " + doc.getPageCount().ToString());
                Console.WriteLine("   Ncode image pages : " + ncodeImageFilename.Length.ToString());

                return;
            }

            Console.WriteLine();
            Console.WriteLine("1) Removing carbon black field(K) from CMYK colorspace from PDF file");
            Console.WriteLine(" ! This step does not work if you have not entered the correct libKey.");
            Console.WriteLine();

            if (newDoc.controller().IsLibKeyOk() == true)
            {
                for (int i = 0; i < newDoc.getPageCount(); i++)
                {
                    using (IPDFPage newPage = newDoc.getPageObj(i))
                    {
                        if (newPage.convertColorSpaceToCMY(doc, 200) == false)
                        {
                            Console.WriteLine(newPage.lastErrorMsg());
                            return;
                        }
                    }
                }
            }

            Console.WriteLine("2) Making Ncoded PDF with Ncode image files.");
            Console.WriteLine();
            /////////////////////////////////////////////////////////////////////
            // caution : This code will not work unless Ncode image's bpp is 1.
            /////////////////////////////////////////////////////////////////////
            System.IO.MemoryStream[] ms = new System.IO.MemoryStream[ncodeIamgeFilenames.Length];

            for (int i = 0; i < ncodeIamgeFilenames.Length; ++i)
            {
                ms[i] = new System.IO.MemoryStream();
                System.Drawing.Image ss = System.Drawing.Image.FromFile(ncodeIamgeFilenames[i]);
                ss.Save(ms[i], System.Drawing.Imaging.ImageFormat.Tiff);

                using (var page = newDoc.getPageObj(i))
                {
                    double x0, y0, x1, y1;
                    x0 = y0 = 0;
                    x1 = ss.Width * 72 / 600;
                    y1 = ss.Height * 72 / 600;

                    if (page.addImageContentOver_usingStream(ms[i], true, x0, y0, x1, y1) == false)
                    {
                        Console.WriteLine(page.lastErrorMsg());
                        return;
                    }
                }

                ms[i].Dispose();
            }

            newDoc.saveDocumentAs(outputPdfFilename);
            newDoc.closeDocument();
            doc.closeDocument();
        }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PDFPageRenderInfo"/> class.
 /// </summary>
 /// <param name="page">Page to render.</param>
 public PDFPageRenderInfo(IPDFPage page)
 {
     Page = page;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PDFFindPage"/> class.
 /// </summary>
 /// <param name="relatedPage">Page where was searched text found at least one time.</param>
 public PDFFindPage(IPDFPage relatedPage)
 {
     RelatedPage = relatedPage ?? throw new ArgumentNullException(nameof(relatedPage));
     Positions   = new ObservableCollection <IPDFFindPosition>();
 }