-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2faf28c
Showing
6 changed files
with
317 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Compiled source # | ||
################### | ||
*.com | ||
*.class | ||
*.dll | ||
*.exe | ||
*.o | ||
*.so | ||
#*.lib | ||
*.pdb | ||
*.ilk | ||
BuildLog.htm | ||
*.obj | ||
*.idb | ||
|
||
_.swp | ||
|
||
#Visual Studio unwanted# | ||
######################## | ||
*.user | ||
*.ncb | ||
*.suo | ||
*.pch | ||
*.dep | ||
*.manifest | ||
*.manifest.res | ||
|
||
#unwanted other sources # | ||
######################## | ||
PDFWriter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// standard library includes | ||
#include <iostream> | ||
#include <string> | ||
using namespace std; | ||
// end standard library includes | ||
|
||
// pdfwriter library includes | ||
#include "PDFWriter.h" | ||
#include "PDFPage.h" | ||
#include "PageContentContext.h" | ||
#include "PDFFormXObject.h" | ||
#include "ResourcesDictionary.h" | ||
// end pdfwriter library includes | ||
|
||
static const wstring scBasePath = L"C:\\Users\\gal\\Documents\\Visual Studio 2008\\Projects\\PDFWriterSamples\\BasicImageAndText\\Materials\\"; | ||
static const wstring scSystemFontsPath = L"C:\\windows\\fonts\\"; | ||
|
||
int main(int argc, wchar_t* argv[]) | ||
{ | ||
PDFWriter pdfWriter; | ||
EStatusCode status; | ||
|
||
do | ||
{ | ||
status = pdfWriter.StartPDF(scBasePath + L"BasicImageAndText.pdf",ePDFVersion13); | ||
if(status != eSuccess) | ||
break; | ||
|
||
// Create a new page | ||
PDFPage* pdfPage = new PDFPage(); | ||
pdfPage->SetMediaBox(PDFRectangle(0,0,595,842)); | ||
|
||
// Create an image object from image | ||
PDFFormXObject* image = pdfWriter.CreateFormXObjectFromJPGFile(scBasePath + L"SanAntonioPass.JPG"); | ||
if(!image) | ||
{ | ||
status = eFailure; | ||
break; | ||
} | ||
|
||
// Create a content context for the page | ||
PageContentContext* pageContentContext = pdfWriter.StartPageContentContext(pdfPage); | ||
|
||
// Place the image in the center of the page | ||
pageContentContext->q(); | ||
pageContentContext->cm(0.4,0,0,0.4,57.5,241); | ||
pageContentContext->Do(pdfPage->GetResourcesDictionary().AddFormXObjectMapping(image->GetObjectID())); | ||
pageContentContext->Q(); | ||
|
||
// Image object can be deleted right after i was used | ||
delete image; | ||
|
||
|
||
// Create a title text over the image | ||
PDFUsedFont* arialTTF = pdfWriter.GetFontForFile(scSystemFontsPath + L"arial.ttf"); | ||
if(!arialTTF) | ||
{ | ||
status = eFailure; | ||
break; | ||
} | ||
|
||
pageContentContext->BT(); | ||
pageContentContext->k(0,0,0,1); | ||
pageContentContext->Tf(arialTTF,20); | ||
pageContentContext->Tm(1,0,0,1,90,610); | ||
pageContentContext->Tj(L"San Antonio Pass, Cordillera Huayhuash, Peru"); | ||
pageContentContext->ET(); | ||
|
||
// End content context, and write the page | ||
status = pdfWriter.EndPageContentContext(pageContentContext); | ||
if(status != eSuccess) | ||
break; | ||
|
||
status = pdfWriter.WritePageAndRelease(pdfPage); | ||
if(status != eSuccess) | ||
break; | ||
|
||
status = pdfWriter.EndPDF(); | ||
}while(false); | ||
|
||
if(eSuccess == status) | ||
cout<<"Succeeded in creating PDF file\n"; | ||
else | ||
cout<<"Failed in creating PDF file\n"; | ||
|
||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
<?xml version="1.0" encoding="Windows-1252"?> | ||
<VisualStudioProject | ||
ProjectType="Visual C++" | ||
Version="9.00" | ||
Name="BasicImageAndText" | ||
ProjectGUID="{BB9CEBAB-3B95-4B3F-AE43-83AE711637D7}" | ||
RootNamespace="BasicImageAndText" | ||
Keyword="Win32Proj" | ||
TargetFrameworkVersion="196613" | ||
> | ||
<Platforms> | ||
<Platform | ||
Name="Win32" | ||
/> | ||
</Platforms> | ||
<ToolFiles> | ||
</ToolFiles> | ||
<Configurations> | ||
<Configuration | ||
Name="Debug|Win32" | ||
OutputDirectory="$(SolutionDir)$(ConfigurationName)" | ||
IntermediateDirectory="$(ConfigurationName)" | ||
ConfigurationType="1" | ||
CharacterSet="1" | ||
> | ||
<Tool | ||
Name="VCPreBuildEventTool" | ||
/> | ||
<Tool | ||
Name="VCCustomBuildTool" | ||
/> | ||
<Tool | ||
Name="VCXMLDataGeneratorTool" | ||
/> | ||
<Tool | ||
Name="VCWebServiceProxyGeneratorTool" | ||
/> | ||
<Tool | ||
Name="VCMIDLTool" | ||
/> | ||
<Tool | ||
Name="VCCLCompilerTool" | ||
Optimization="0" | ||
AdditionalIncludeDirectories="..\PDFWriter\Headers\PDFWriter;..\PDFWriter\Headers\freetype;..\PDFWriter\Headers\libtiff;..\PDFWriter\Headers\zlib" | ||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" | ||
MinimalRebuild="true" | ||
BasicRuntimeChecks="3" | ||
RuntimeLibrary="3" | ||
UsePrecompiledHeader="0" | ||
WarningLevel="3" | ||
DebugInformationFormat="4" | ||
/> | ||
<Tool | ||
Name="VCManagedResourceCompilerTool" | ||
/> | ||
<Tool | ||
Name="VCResourceCompilerTool" | ||
/> | ||
<Tool | ||
Name="VCPreLinkEventTool" | ||
/> | ||
<Tool | ||
Name="VCLinkerTool" | ||
AdditionalDependencies="..\PDFWriter\Binaries\$(PlatformName)\$(ConfigurationName)\PDFWriter.lib ..\PDFWriter\Binaries\$(PlatformName)\$(ConfigurationName)\zlib.lib ..\PDFWriter\Binaries\$(PlatformName)\$(ConfigurationName)\libtiff.lib ..\PDFWriter\Binaries\$(PlatformName)\$(ConfigurationName)\freetype.lib" | ||
LinkIncremental="2" | ||
GenerateDebugInformation="true" | ||
SubSystem="1" | ||
TargetMachine="1" | ||
/> | ||
<Tool | ||
Name="VCALinkTool" | ||
/> | ||
<Tool | ||
Name="VCManifestTool" | ||
/> | ||
<Tool | ||
Name="VCXDCMakeTool" | ||
/> | ||
<Tool | ||
Name="VCBscMakeTool" | ||
/> | ||
<Tool | ||
Name="VCFxCopTool" | ||
/> | ||
<Tool | ||
Name="VCAppVerifierTool" | ||
/> | ||
<Tool | ||
Name="VCPostBuildEventTool" | ||
/> | ||
</Configuration> | ||
<Configuration | ||
Name="Release|Win32" | ||
OutputDirectory="$(SolutionDir)$(ConfigurationName)" | ||
IntermediateDirectory="$(ConfigurationName)" | ||
ConfigurationType="1" | ||
CharacterSet="1" | ||
WholeProgramOptimization="1" | ||
> | ||
<Tool | ||
Name="VCPreBuildEventTool" | ||
/> | ||
<Tool | ||
Name="VCCustomBuildTool" | ||
/> | ||
<Tool | ||
Name="VCXMLDataGeneratorTool" | ||
/> | ||
<Tool | ||
Name="VCWebServiceProxyGeneratorTool" | ||
/> | ||
<Tool | ||
Name="VCMIDLTool" | ||
/> | ||
<Tool | ||
Name="VCCLCompilerTool" | ||
Optimization="2" | ||
EnableIntrinsicFunctions="true" | ||
AdditionalIncludeDirectories="..\PDFWriter\Headers\PDFWriter;..\PDFWriter\Headers\freetype;..\PDFWriter\Headers\libtiff;..\PDFWriter\Headers\zlib" | ||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" | ||
RuntimeLibrary="2" | ||
EnableFunctionLevelLinking="true" | ||
UsePrecompiledHeader="0" | ||
WarningLevel="3" | ||
DebugInformationFormat="3" | ||
/> | ||
<Tool | ||
Name="VCManagedResourceCompilerTool" | ||
/> | ||
<Tool | ||
Name="VCResourceCompilerTool" | ||
/> | ||
<Tool | ||
Name="VCPreLinkEventTool" | ||
/> | ||
<Tool | ||
Name="VCLinkerTool" | ||
AdditionalDependencies="..\PDFWriter\Binaries\$(PlatformName)\$(ConfigurationName)\PDFWriter.lib ..\PDFWriter\Binaries\$(PlatformName)\$(ConfigurationName)\zlib.lib ..\PDFWriter\Binaries\$(PlatformName)\$(ConfigurationName)\libtiff.lib ..\PDFWriter\Binaries\$(PlatformName)\$(ConfigurationName)\freetype.lib" | ||
LinkIncremental="1" | ||
GenerateDebugInformation="true" | ||
SubSystem="1" | ||
OptimizeReferences="2" | ||
EnableCOMDATFolding="2" | ||
TargetMachine="1" | ||
/> | ||
<Tool | ||
Name="VCALinkTool" | ||
/> | ||
<Tool | ||
Name="VCManifestTool" | ||
/> | ||
<Tool | ||
Name="VCXDCMakeTool" | ||
/> | ||
<Tool | ||
Name="VCBscMakeTool" | ||
/> | ||
<Tool | ||
Name="VCFxCopTool" | ||
/> | ||
<Tool | ||
Name="VCAppVerifierTool" | ||
/> | ||
<Tool | ||
Name="VCPostBuildEventTool" | ||
/> | ||
</Configuration> | ||
</Configurations> | ||
<References> | ||
</References> | ||
<Files> | ||
<File | ||
RelativePath=".\BasicImageAndText.cpp" | ||
> | ||
</File> | ||
</Files> | ||
<Globals> | ||
</Globals> | ||
</VisualStudioProject> |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 10.00 | ||
# Visual Studio 2008 | ||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BasicImageAndText", "BasicImageAndText\BasicImageAndText.vcproj", "{BB9CEBAB-3B95-4B3F-AE43-83AE711637D7}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Win32 = Debug|Win32 | ||
Release|Win32 = Release|Win32 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{BB9CEBAB-3B95-4B3F-AE43-83AE711637D7}.Debug|Win32.ActiveCfg = Debug|Win32 | ||
{BB9CEBAB-3B95-4B3F-AE43-83AE711637D7}.Debug|Win32.Build.0 = Debug|Win32 | ||
{BB9CEBAB-3B95-4B3F-AE43-83AE711637D7}.Release|Win32.ActiveCfg = Release|Win32 | ||
{BB9CEBAB-3B95-4B3F-AE43-83AE711637D7}.Release|Win32.Build.0 = Release|Win32 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |