feat: implemented wrapper and pdf doc page

This commit is contained in:
Furqan-14
2026-05-22 15:47:48 +05:30
parent d4fe33b007
commit fe627f4e19
55 changed files with 5074 additions and 101 deletions
+38
View File
@@ -0,0 +1,38 @@
$vcpkgRoot = $env:VCPKG_ROOT
if (-not $vcpkgRoot) {
$vcpkgRoot = "C:\Users\furqa\vcpkg"
$env:VCPKG_ROOT = $vcpkgRoot
Write-Host "VCPKG_ROOT was not set. Defaulting to $vcpkgRoot" -ForegroundColor Yellow
}
$vcvars = "C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
if (-not (Test-Path $vcvars)) {
$vcvars = "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
}
if (-not (Test-Path $vcvars)) {
Write-Error "Could not find vcvars64.bat. Please ensure Visual Studio or Build Tools is installed."
exit 1
}
Write-Host "Loading MSVC environment variables using $vcvars..." -ForegroundColor Cyan
cmd /c "`"$vcvars`" && set" | Where-Object { $_ -match '=' } | ForEach-Object {
$name, $value = $_ -split '=', 2
[System.Environment]::SetEnvironmentVariable($name, $value, 'Process')
}
Write-Host "Configuring CMake preset 'win-local-pdfium'..." -ForegroundColor Cyan
cmake --preset win-local-pdfium
if ($LASTEXITCODE -ne 0) {
Write-Error "CMake configuration failed."
exit $LASTEXITCODE
}
Write-Host "Building target 'pdfengine_py'..." -ForegroundColor Cyan
cmake --build --preset win-local-pdfium --target pdfengine_py
if ($LASTEXITCODE -ne 0) {
Write-Error "Build failed."
exit $LASTEXITCODE
}
Write-Host "Success! The python extension is compiled and copied to the gateway." -ForegroundColor Green
+68
View File
@@ -0,0 +1,68 @@
$sourceDir = "C:\Users\furqa\pdfium-build\checkout\pdfium\testing\resources"
$destDir = "$PSScriptRoot\..\corpus"
if (-not (Test-Path $sourceDir)) {
Write-Error "PDFium resources directory not found at: $sourceDir"
exit 1
}
$basic = @(
"about_blank.pdf",
"black.pdf",
"clip_path.pdf",
"dashed_lines.pdf",
"hello_world.pdf",
"hello_world_2_pages.pdf",
"many_rectangles.pdf",
"rectangles.pdf",
"rectangles_multi_pages.pdf",
"whitespace.pdf"
)
$fonts = @(
"latin_extended.pdf",
"rotated_text.pdf",
"rotated_text_90.pdf",
"text_font.pdf",
"utf-8.pdf",
"vertical_text.pdf",
"hebrew_mirrored.pdf"
)
$edgeCases = @(
"annots.pdf",
"bookmarks.pdf",
"combobox_form.pdf",
"embedded_attachments.pdf",
"empty_xref.pdf",
"encrypted.pdf",
"linearized.pdf",
"listbox_form.pdf",
"no_page_count.pdf",
"page_labels.pdf",
"text_form.pdf",
"unsupported_feature.pdf",
"zero_length_stream.pdf"
)
Write-Host "Ensuring corpus directory structure..."
$null = New-Item -ItemType Directory -Force -Path "$destDir\basic"
$null = New-Item -ItemType Directory -Force -Path "$destDir\fonts"
$null = New-Item -ItemType Directory -Force -Path "$destDir\edge-cases"
Write-Host "Copying basic files..."
foreach ($f in $basic) {
Copy-Item "$sourceDir\$f" "$destDir\basic\$f" -Force
}
Write-Host "Copying font files..."
foreach ($f in $fonts) {
Copy-Item "$sourceDir\$f" "$destDir\fonts\$f" -Force
}
Write-Host "Copying edge-case files..."
foreach ($f in $edgeCases) {
Copy-Item "$sourceDir\$f" "$destDir\edge-cases\$f" -Force
}
Write-Host "Test corpus (30 files) populated successfully under $destDir"
+10
View File
@@ -0,0 +1,10 @@
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$gatewayDir = Join-Path (Split-Path -Parent $scriptDir) "gateway"
Write-Host "Starting FastAPI Gateway local dev server..." -ForegroundColor Cyan
Push-Location $gatewayDir
try {
& .venv\Scripts\uvicorn app.main:app --reload
} finally {
Pop-Location
}
+15
View File
@@ -0,0 +1,15 @@
$vcvars = "C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
if (-not (Test-Path $vcvars)) {
$vcvars = "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
}
if (Test-Path $vcvars) {
cmd /c "`"$vcvars`" && set" | Where-Object { $_ -match '=' } | ForEach-Object {
$name, $value = $_ -split '=', 2
[System.Environment]::SetEnvironmentVariable($name, $value, 'Process')
}
}
Write-Host "Running C++ core unit tests..." -ForegroundColor Cyan
ctest --preset win-local-pdfium
exit $LASTEXITCODE
+10
View File
@@ -0,0 +1,10 @@
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$gatewayDir = Join-Path (Split-Path -Parent $scriptDir) "gateway"
Write-Host "Running FastAPI Gateway integration tests..." -ForegroundColor Cyan
Push-Location $gatewayDir
try {
& .venv\Scripts\pytest
} finally {
Pop-Location
}