Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
PdfPig
提交
1aacb142
P
PdfPig
项目概览
jobily
/
PdfPig
10 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PdfPig
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
1aacb142
编写于
1月 03, 2018
作者:
E
Eliot Jones
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add test for multiple page pdf from libre office
上级
21be34a9
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
78 addition
and
0 deletion
+78
-0
src/UglyToad.Pdf.Tests/Integration/Documents/Two Page Text Only - from libre office.pdf
...tion/Documents/Two Page Text Only - from libre office.pdf
+0
-0
src/UglyToad.Pdf.Tests/Integration/TwoPageTextOnlyLibreOfficeTests.cs
....Pdf.Tests/Integration/TwoPageTextOnlyLibreOfficeTests.cs
+58
-0
src/UglyToad.Pdf.Tests/UglyToad.Pdf.Tests.csproj
src/UglyToad.Pdf.Tests/UglyToad.Pdf.Tests.csproj
+4
-0
src/UglyToad.Pdf/Content/Page.cs
src/UglyToad.Pdf/Content/Page.cs
+14
-0
src/UglyToad.Pdf/Content/Pages.cs
src/UglyToad.Pdf/Content/Pages.cs
+2
-0
未找到文件。
src/UglyToad.Pdf.Tests/Integration/Documents/Two Page Text Only - from libre office.pdf
0 → 100644
浏览文件 @
1aacb142
此差异由.gitattributes 抑制。
src/UglyToad.Pdf.Tests/Integration/TwoPageTextOnlyLibreOfficeTests.cs
0 → 100644
浏览文件 @
1aacb142
namespace
UglyToad.Pdf.Tests.Integration
{
using
System
;
using
System.IO
;
using
Content
;
using
Xunit
;
public
class
TwoPageTextOnlyLibreOfficeTests
{
private
static
string
GetFilename
()
{
var
documentFolder
=
Path
.
GetFullPath
(
Path
.
Combine
(
AppDomain
.
CurrentDomain
.
BaseDirectory
,
".."
,
".."
,
".."
,
"Integration"
,
"Documents"
));
return
Path
.
Combine
(
documentFolder
,
"Two Page Text Only - from libre office.pdf"
);
}
[
Fact
]
public
void
HasCorrectNumberOfPages
()
{
var
file
=
GetFilename
();
using
(
var
document
=
PdfDocument
.
Open
(
File
.
ReadAllBytes
(
file
)))
{
Assert
.
Equal
(
2
,
document
.
NumberOfPages
);
}
}
[
Fact
]
public
void
HasCorrectPageSize
()
{
using
(
var
document
=
PdfDocument
.
Open
(
GetFilename
()))
{
var
page
=
document
.
GetPage
(
1
);
Assert
.
Equal
(
PageSize
.
A4
,
page
.
Size
);
page
=
document
.
GetPage
(
2
);
Assert
.
Equal
(
PageSize
.
A4
,
page
.
Size
);
}
}
[
Fact
]
public
void
PagesStartWithCorrectText
()
{
using
(
var
document
=
PdfDocument
.
Open
(
GetFilename
()))
{
var
page
=
document
.
GetPage
(
1
);
Assert
.
StartsWith
(
"Apache License"
,
page
.
Text
);
page
=
document
.
GetPage
(
2
);
Assert
.
StartsWith
(
"2. Grant of Copyright"
,
page
.
Text
);
}
}
}
}
src/UglyToad.Pdf.Tests/UglyToad.Pdf.Tests.csproj
浏览文件 @
1aacb142
...
...
@@ -16,6 +16,7 @@
<None Remove="Integration\Documents\Single Page Non Latin - from acrobat distiller.pdf" />
<None Remove="Integration\Documents\Single Page Simple - from google drive.pdf" />
<None Remove="Integration\Documents\Single Page Simple - from open office.pdf" />
<None Remove="Integration\Documents\Two Page Text Only - from libre office.pdf" />
</ItemGroup>
<ItemGroup>
...
...
@@ -43,6 +44,9 @@
<Content Include="Integration\Documents\Single Page Simple - from open office.pdf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Integration\Documents\Two Page Text Only - from libre office.pdf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
...
...
src/UglyToad.Pdf/Content/Page.cs
浏览文件 @
1aacb142
...
...
@@ -2,6 +2,7 @@
{
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
public
class
Page
{
...
...
@@ -18,6 +19,8 @@
public
IReadOnlyList
<
Letter
>
Letters
=>
Content
?.
Letters
??
new
Letter
[
0
];
public
string
Text
{
get
;
}
/// <summary>
/// Gets the width of the page in points.
/// </summary>
...
...
@@ -44,11 +47,22 @@
MediaBox
=
mediaBox
;
CropBox
=
cropBox
;
Content
=
content
;
Text
=
GetText
(
content
);
Width
=
mediaBox
.
Bounds
.
Width
;
Height
=
mediaBox
.
Bounds
.
Height
;
Size
=
mediaBox
.
Bounds
.
GetPageSize
();
}
private
static
string
GetText
(
PageContent
content
)
{
if
(
content
?.
Letters
==
null
)
{
return
string
.
Empty
;
}
return
string
.
Join
(
string
.
Empty
,
content
.
Letters
.
Select
(
x
=>
x
.
Value
));
}
}
}
\ No newline at end of file
src/UglyToad.Pdf/Content/Pages.cs
浏览文件 @
1aacb142
...
...
@@ -91,6 +91,7 @@
bool
found
=
pageNumber
==
soughtPageNumber
;
locatedPages
[
pageNumber
]
=
currentPageDictionary
;
pageNumbersObserved
.
Add
(
pageNumber
);
return
found
;
}
...
...
@@ -117,6 +118,7 @@
if
(
thisPageMatches
)
{
childFound
=
true
;
break
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录