Пример #1
0
 public int GetCharIndexAtPos(float x, float y, float xTolerance, float yTolerance)
 {
     return(PDFium.FPDFText_GetCharIndexAtPos(Handle, x, y, xTolerance, yTolerance));
 }
Пример #2
0
        public PdfBookmark FindBookmark(string title)
        {
            var handle = PDFium.FPDFBookmark_Find(Handle, title);

            return(handle.IsNull ? null : new PdfBookmark(this, handle));
        }
Пример #3
0
 /// <summary>
 /// Creates a new <see cref="PDFiumBitmap"/>. Unmanaged memory is allocated which must
 /// be freed by calling <see cref="Dispose"/>.
 /// </summary>
 /// <param name="width">The width of the new bitmap.</param>
 /// <param name="height">The height of the new bitmap.</param>
 /// <param name="hasAlpha">A value indicating wheter the new bitmap has an alpha channel.</param>
 /// <remarks>
 /// A bitmap created with this overload always uses 4 bytes per pixel.
 /// Depending on <paramref name="hasAlpha"/> the <see cref="Format"/> is then either
 /// <see cref="BitmapFormats.BGRA"/> or <see cref="BitmapFormats.BGRx"/>.
 /// </remarks>
 public PDFiumBitmap(int width, int height, bool hasAlpha)
     : this(PDFium.FPDFBitmap_Create(width, height, hasAlpha), hasAlpha ? BitmapFormats.BGRA : BitmapFormats.BGRx)
 {
 }
Пример #4
0
 /// <summary>
 /// Loads a <see cref="PdfDocument"/> from the file system.
 /// <see cref="Close"/> must be called in order to free unmanaged resources.
 /// </summary>
 /// <param name="fileName">Filepath of the PDF file to load.</param>
 public PdfDocument(string fileName, string password = null)
     : this(PDFium.FPDF_LoadDocument(fileName, password))
 {
 }
Пример #5
0
 /// <summary>
 /// Loads a <see cref="PdfDocument"/> from '<paramref name="count"/>' bytes read from a <paramref name="stream"/>.
 /// <see cref="Close"/> must be called in order to free unmanaged resources.
 /// </summary>
 /// <param name="count">
 /// The number of bytes to read from the <paramref name="stream"/>.
 /// If the value is equal to or smaller than 0, the stream is read to the end.
 /// </param>
 public PdfDocument(Stream stream, int count = 0, string password = null)
     : this(PDFium.FPDF_LoadDocument(stream, count, password))
 {
 }
Пример #6
0
 /// <summary>
 /// Loads a <see cref="PdfDocument"/> from '<paramref name="count"/>' bytes read from a <paramref name="stream"/>.
 /// <see cref="Close"/> must be called in order to free unmanaged resources.
 /// </summary>
 /// <param name="stream"></param>
 /// <param name="fileRead"></param>
 /// <param name="count">
 /// The number of bytes to read from the <paramref name="stream"/>.
 /// If the value is equal to or smaller than 0, the stream is read to the end.
 /// </param>
 /// <param name="password"></param>
 public PdfDocument(Stream stream, FPDF_FILEREAD fileRead, int count = 0, string password = null)
     : this(PDFium.FPDF_LoadDocument(stream, fileRead, count, password))
 {
 }
Пример #7
0
 protected override void Dispose(FPDF_DOCUMENT handle)
 {
     ((IDisposable)Pages).Dispose();
     PDFium.FPDF_CloseDocument(handle);
 }
Пример #8
0
 public int CountChars() => PDFium.FPDFText_CountChars(Handle);
Пример #9
0
 /// <summary>
 /// Returns all the text on the page.
 /// </summary>
 /// <returns></returns>
 public string GetText() => PDFium.FPDFText_GetText(Handle, 0, CountChars());
Пример #10
0
 public static PdfText Load(PdfPage page) => new PdfText(page, PDFium.FPDFText_LoadPage(page.Handle));
Пример #11
0
 protected override void Dispose(FPDF_TEXTPAGE handle)
 {
     PDFium.FPDFText_ClosePage(handle);
 }
Пример #12
0
 public PDFiumException()
     : base($"PDFium Error: {PDFium.FPDF_GetLastError().GetDescription()}")
 {
 }
Пример #13
0
 /// <summary>
 /// Fills a rectangle in the <see cref="PDFiumBitmap"/> with <paramref name="color"/>.
 /// The pixel values in the rectangle are replaced and not blended.
 /// </summary>
 public void FillRectangle(int left, int top, int width, int height, FPDF_COLOR color)
 {
     PDFium.FPDFBitmap_FillRect(Handle, left, top, width, height, color);
 }
Пример #14
0
 /// <summary>
 /// Creates a new <see cref="PDFiumBitmap"/> using memory allocated by the caller.
 /// The caller is responsible for freeing the memory and that the adress stays
 /// valid during the lifetime of the returned <see cref="PDFiumBitmap"/>. To free
 /// unmanaged resources, <see cref="Dispose"/> must be called.
 /// </summary>
 /// <param name="width">The width of the new bitmap.</param>
 /// <param name="height">The height of the new bitmap.</param>
 /// <param name="format">The format of the new bitmap.</param>
 /// <param name="scan0">The adress of the memory block which holds the pixel values.</param>
 /// <param name="stride">The number of bytes per image row.</param>
 public PDFiumBitmap(int width, int height, BitmapFormats format, IntPtr scan0, int stride)
     : this(PDFium.FPDFBitmap_CreateEx(width, height, format, scan0, stride), format)
 {
 }
Пример #15
0
 /// <summary>
 /// Extracts text from the page.
 /// </summary>
 /// <param name="index">Index for the start characters.</param>
 /// <param name="count">Number of characters to be extracted.</param>
 /// <returns></returns>
 public string GetText(int index, int count)
 {
     return(PDFium.FPDFText_GetText(Handle, index, count));
 }
Пример #16
0
 public string GetText(int start_index, int count) => PDFium.FPDFText_GetText(Handle, start_index, count);
Пример #17
0
 internal PdfPageCollection(PdfDocument doc)
 {
     _doc   = doc;
     _pages = new List <PdfPage>(PDFium.FPDF_GetPageCount(doc.Handle));
 }
Пример #18
0
 public string GetBoundedText(double left, double top, double right, double bottom) => PDFium.FPDFText_GetBoundedText(Handle, left, top, right, bottom);
Пример #19
0
 public void CopyViewerPreferencesFrom(PdfDocument srcDoc) => PDFium.FPDF_CopyViewerPreferences(Handle, srcDoc.Handle);
Пример #20
0
 public string GetBoundedText(float left, float top, float right, float bottom)
 {
     return(PDFium.FPDFText_GetBoundedText(Handle, left, top, right, bottom));
 }
Пример #21
0
 /// <summary>
 /// Creates a new <see cref="PdfDocument"/>.
 /// <see cref="Close"/> must be called in order to free unmanaged resources.
 /// </summary>
 public PdfDocument()
     : this(PDFium.FPDF_CreateNewDocument())
 {
 }
Пример #22
0
 public char GetCharacter(int index)
 {
     return(PDFium.FPDFText_GetUnicode(Handle, index));
 }
Пример #23
0
 /// <summary>
 /// Loads a <see cref="PdfDocument"/> from memory.
 /// <see cref="Close"/> must be called in order to free unmanaged resources.
 /// </summary>
 /// <param name="data">Byte array containing the bytes of the PDF document to load.</param>
 /// <param name="index">The index of the first byte to be copied from <paramref name="data"/>.</param>
 /// <param name="count">The number of bytes to copy from <paramref name="data"/> or a negative value to copy all bytes.</param>
 public PdfDocument(byte[] data, int index = 0, int count = -1, string password = null)
     : this(PDFium.FPDF_LoadDocument(data, index, count, password))
 {
 }
Пример #24
0
 /// <summary>
 /// Get the font size of a particular character.
 /// </summary>
 /// <param name="index">Zero-based index of the character.</param>
 /// <returns>
 /// The font size of the particular character, measured in points (about
 /// 1/72 inch). This is the typographic size of the font (so called "em size").
 /// </returns>
 public float GetFontSize(int index)
 {
     return((float)PDFium.FPDFText_GetFontSize(Handle, index));
 }
Пример #25
0
 /// <summary>
 /// Saves the <see cref="PdfDocument"/> to a <paramref name="stream"/>.
 /// </summary>
 /// <param name="version">
 /// The new PDF file version of the saved file.
 /// 14 for 1.4, 15 for 1.5, etc. Values smaller than 10 are ignored.
 /// </param>
 public bool Save(Stream stream, SaveFlags flags = SaveFlags.None, int version = 0)
 {
     return(PDFium.FPDF_SaveAsCopy(Handle, stream, flags, version));
 }
Пример #26
0
 public FS_RECTF GetCharBox(int index)
 {
     PDFium.FPDFText_GetCharBox(Handle, index, out double left, out double right, out double bottom, out double top);
     return(new FS_RECTF((float)left, (float)right, (float)bottom, (float)top));
 }
Пример #27
0
 public string GetMetaText(MetadataTags tag) => PDFium.FPDF_GetMetaText(Handle, tag);
Пример #28
0
 protected override void Dispose(FPDF_BITMAP handle)
 {
     PDFium.FPDFBitmap_Destroy(handle);
 }