Skip to content

Commit f067bad

Browse files
committed
Sample update
- ExtractTables CSV format fix - AddComments exceptions
1 parent 48aead0 commit f067bad

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/AddComment.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ void AddComment(
4747
throw std::runtime_error(pdfix->GetError());
4848

4949
PdfPage* page = doc->AcquirePage(0);
50+
if (!page)
51+
throw std::runtime_error(pdfix->GetError());
5052
PdfRect crop_box;
5153
page->GetCropBox(&crop_box);
5254

@@ -58,6 +60,8 @@ void AddComment(
5860
annot_rect.top = (crop_box.top + crop_box.bottom) / 2. + 10;
5961

6062
PdfTextAnnot* annot = page->AddTextAnnot(-1, &annot_rect);
63+
if (!annot)
64+
throw std::runtime_error(pdfix->GetError());
6165
annot->SetAuthor(L"Peter Brown");
6266
annot->SetContents(L"This is my comment.");
6367
annot->AddReply(L"Mark Fish", L"This is some reply.");

src/ExtractTables.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ void SaveTable(PdeElement* element, std::wstring save_path, int& table_index) {
7979
if (child && (child->GetType() == kPdeText)) {
8080
GetText(child, ofs, false);
8181
}
82-
if (i < count) {
82+
if (i < count - 1) {
8383
ofs << " ";
8484
}
8585
}
8686
ofs << "\"";
8787
}
8888

8989
if (col < col_count)
90-
ofs << std::endl;
90+
ofs << ",";
9191
}
9292
if (row < row_count)
9393
ofs << std::endl;

0 commit comments

Comments
 (0)