https://github.com/miyako/4d-plugin-poppler
Extract text from PDF, convert PDF to SVG.
https://github.com/miyako/4d-plugin-poppler
4d-plugin pdf
Last synced: about 1 month ago
JSON representation
Extract text from PDF, convert PDF to SVG.
- Host: GitHub
- URL: https://github.com/miyako/4d-plugin-poppler
- Owner: miyako
- License: mit
- Created: 2021-04-03T08:30:22.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2023-03-30T15:32:25.000Z (about 3 years ago)
- Last Synced: 2025-01-08T17:57:04.590Z (over 1 year ago)
- Topics: 4d-plugin, pdf
- Language: C
- Homepage:
- Size: 352 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README


[](LICENSE)

### Dependencies and Licensing
* the source code of this plugin developed using the [4D Plug-in SDK](https://github.com/4d/4D-Plugin-SDK) is licensed under the MIT license
* see [Poppler](https://poppler.freedesktop.org) for the licensing of **Poppler** (shared library).
* the licensing of the binary product of this plugin is subject to the licensing of all its dependencies.
# 4d-plugin-poppler
Extract text from PDF, convert PDF to SVG.
see also [4d-plugin-xpdf](https://github.com/miyako/4d-plugin-xpdf)
### Syntax
```4d
error:=PDF Convert (pdf;svg;from;to;password;method)
```
Parameter|Type|Description
------------|------|----
pdf|BLOB|The PDF document BLOB
svg|ARRAY PICTURE (or ARRAY TEXT or ARRAY BLOB)|Array to receive the pages (must be defined); See remarks below
from|LONGINT|Starting page (1 based) [optional]
to|LONGINT|Ending page (1 based) [optional]
password|TEXT|Password [optional]
method|TEXT|Callback method [optional]
error|LONGINT|Error code
```4d
error:=PDF Get text (pdf;svg;from;to;password;method)
```
Parameter|Type|Description
------------|------|----
pdf|BLOB|The PDF document BLOB
svg|ARRAY TEXT|Array to receive the pages
from|LONGINT|Starting page (1 based) [optional]
to|LONGINT|Ending page (1 based) [optional]
password|TEXT|Password [optional]
method|TEXT|Callback method [optional]
error|LONGINT|Error code
```4d
page count (pdf;password)
```
Parameter|Type|Description
------------|------|----
pdf|BLOB|The PDF document BLOB
password|TEXT|Password [optional]
count|LONGINT|Page count
### Examples
```4d
$path:=Get 4D folder(Current resources folder)+"sample.pdf"
DOCUMENT TO BLOB($path;$PDF)
ARRAY PICTURE($pages;0)
$startPage:=0
$endPage:=0
$password:=""
$callback:="PDF2SVG_CB_PICTURE"
<>p:=Progress New
Progress SET PROGRESS (<>P;0)
Progress SET BUTTON ENABLED (<>P;True)
$error:=PDF Convert ($PDF;$pages;$startPage;$endPage;$password;$callback)
Progress QUIT (<>P)
```
```4d
$path:=Get 4D folder(Current resources folder)+"sample.pdf"
DOCUMENT TO BLOB($path;$PDF)
ARRAY TEXT($pages;0)
$startPage:=0
$endPage:=0
$password:=""
$callback:="PDF2TEXT_CB"
<>p:=Progress New
Progress SET PROGRESS (<>P;0)
Progress SET BUTTON ENABLED (<>P;True)
$error:=PDF Get text ($PDF;$pages;$startPage;$endPage;$password;$callback)
Progress QUIT (<>P)
```
### Callback
The method is executed in the same process as the calling method.
Parameters:
```4d
C_LONGINT($1;$pos)//1-based
C_LONGINT($2;$total)
C_LONGINT($3;$pageNumber)//1-based
C_PICTURE($4;$page)
C_BOOLEAN($0;$stop)
```
To display a progress bar:
```4d
Progress SET PROGRESS (<>P;$pos/$total)
```
To abort:
```4d
$0:=Progress Stopped (<>P)
```
### Error codes
```c
#define PDF2SVG_ERROR_InvalidSourceData (-1)
#define PDF2SVG_ERROR_InvalidReturnType (-2)
#define PDF2SVG_ERROR_AbortedByUser (-3)
```
### Alternate syntax
Alternatively, you may pass ```ARRAY TEXT``` or ```ARRAY BLOB``` in $2. However, $4 in the callback function will not be used. The current page data will only be passed to the callback method when ```ARRAY PICTURE``` is used. It's main purpose is to display a preview image. Note that the image is a ref-counted duplicate of the final array element.
### Build notes
iconv by cmake may be missing the symbol `libiconv_set_relocation_prefix`
add a stub function
```c
extern LIBICONV_DLL_EXPORTED void libiconv_set_relocation_prefix (const char *orig_prefix,
const char *curr_prefix){do {} while(0);}
```
zlib by cmake may be missing the symbol `_inflateValidate`
normal `make` instead
---

