PdfParser: Parse inline images

This commit is contained in:
2016-09-06 17:42:13 +02:00
parent 29e49546fa
commit 4d92f144f8
2 changed files with 37 additions and 1 deletions

View File

@@ -1021,6 +1021,20 @@ namespace VAR.PdfTools
PdfContentAction action = new PdfContentAction(token, elems);
elems = new List<IPdfElement>();
actions.Add(action);
if (action.Token == "ID")
{
// Embbed inline image
byte lineFeed = 0x0A;
byte carriageReturn = 0x0D;
long distToObject = MeasureToMarkers(new char[][] {
new char[] {(char)lineFeed, 'E', 'I'},
new char[] {(char)carriageReturn, (char)lineFeed, 'E', 'I'},
});
byte[] imageBody = GetRawData(distToObject);
SkipEndOfLine();
string endToken = ParseToken();
action.Parameters.Add(new PdfStream { OriginalData = imageBody, });
}
}
} while (IsEndOfStream() == false);
return actions;

View File

@@ -470,8 +470,10 @@ namespace VAR.PdfTools
private void ProcessPage()
{
foreach (PdfContentAction action in _page.ContentActions)
int unknowCount = 0;
for (int i = 0; i < _page.ContentActions.Count; i++)
{
PdfContentAction action = _page.ContentActions[i];
// Graphics Operations
if (action.Token == "q")
{
@@ -578,6 +580,26 @@ namespace VAR.PdfTools
{
OpTextPutMultiple(((PdfArray)action.Parameters[0]));
}
else if (action.Token == "re")
{
// FIXME: Interpret this
}
else if (action.Token == "f")
{
// FIXME: Interpret this
}
else if (action.Token == "g")
{
// FIXME: Interpret this
}
else if (action.Token == "rg")
{
// FIXME: Interpret this
}
else
{
unknowCount++;
}
}
FlushTextElement();
}