From 50461f0dd478f5f796704a71640a92734e23435c Mon Sep 17 00:00:00 2001 From: bruceh Date: Fri, 26 Aug 2022 16:41:45 -0500 Subject: [PATCH] Update with latest changes Mostly clang formatting --- .../All/All_Datalogics_32Bit.sln | 660 ------------------ CPlusPlus/Sample_Source/All/build_run_all.bat | 393 ----------- .../CreateAnnotations/CreateAnnotations.cpp | 298 ++++---- .../FlattenAnnotations/FlattenAnnotations.cpp | 174 ++--- .../ContentCreation/AddArt/AddArt.cpp | 196 +++--- .../AddAttachments/AddAttachments.cpp | 148 ++-- .../ContentCreation/AddContent/AddContent.cpp | 262 ++++--- .../CreateBookmarks/CreateBookmarks.cpp | 161 ++--- .../CreateLayers/CreateLayers.cpp | 258 ++++--- .../CreateTransparency/CreateTransparency.cpp | 566 ++++++++------- .../CopyContent/CopyContent.cpp | 253 ++++--- .../ExtractAttachments/ExtractAttachments.cpp | 120 ++-- .../ExtractFonts/ExtractFonts.cpp | 143 ++-- .../AddBookmarks/AddBookmarks.cpp | 327 ++++----- .../ContentModification/AddLinks/AddLinks.cpp | 301 ++++---- .../AddPageNumbers/AddPageNumbers.cpp | 68 +- .../EmbedFonts/EmbedFonts.cpp | 367 ++++------ .../ImportPages/ImportPages.cpp | 215 +++--- .../PDFMakeOCGVisible/PDFMakeOCGVisible.cpp | 128 ++-- .../PDFUncompress/PDFUncompress.cpp | 416 +++++------ .../Display/DisplayPDEContent/dpcColor.cpp | 313 ++++----- .../Display/DisplayPDEContent/dpcDict.cpp | 174 +++-- .../Display/DisplayPDEContent/dpcGraphic.cpp | 62 +- .../Display/DisplayPDEContent/dpcImage.cpp | 82 +-- .../Display/DisplayPDEContent/dpcOutput.cpp | 34 +- .../Display/DisplayPDEContent/dpcShading.cpp | 77 +- .../Display/DisplayPDEContent/dpcSupport.cpp | 65 +- .../Display/DisplayPDEContent/dpcText.cpp | 107 ++- .../Display/PDFViewer/PDFViewer.cpp | 2 +- .../ConvertPDFtoPostscript.cpp | 96 ++- .../ConvertToPDFA/ConvertToPDFA.cpp | 292 ++------ .../ConvertToPDFX/ConvertToPDFX.cpp | 143 ++-- .../ConvertToZUGFeRD/ConvertToZUGFeRD.cpp | 2 +- .../DocumentConversion/XPStoPDF/XPStoPDF.cpp | 118 ++-- .../AlternateFileSystem.cpp | 1 - .../AlternateFileSystemTest.cpp | 233 ++++--- .../AddThumbnailsToPDF/AddThumbnailsToPDF.cpp | 97 ++- .../Images/CalcImageDPI/CalcImageDPI.cpp | 297 ++++---- .../CreateImageWithTransparency.cpp | 367 +++++----- .../CreateSeparations/CreateSeparations.cpp | 386 +++++----- .../FindImageResolutions.cpp | 317 ++++----- .../Images/OutputPreview/OutputPreview.cpp | 4 +- .../CountColorsInDoc/CountColorsInDoc.cpp | 356 +++++----- .../CountColorsInDoc/CountColorsInDoc.h | 2 +- .../Printing/PDFPrintGUI/PDFPrintGUI.cpp | 106 ++- .../Security/AESEncryption/AESEncryption.cpp | 13 +- .../Security/AddPassword/AddPassword.cpp | 94 ++- .../Security/AddRedaction/AddRedaction.cpp | 4 +- .../AddTriangularRedaction.cpp | 88 ++- .../EncryptDocument/EncryptDocument.cpp | 156 ++--- .../Security/LockDocument/LockDocument.cpp | 94 ++- .../Security/OpenEncrypted/OpenEncrypted.cpp | 151 ++-- .../SetUniquePermissions.cpp | 175 +++-- .../Sample_Source/Text/AddText/AddText.cpp | 2 +- .../Text/ExtractText/ExtractText.cpp | 370 +++++----- .../Text/HelloJapan/HelloJapan.cpp | 216 +++--- .../Text/InsertHeadFoot/InsertHeadFoot.cpp | 563 +++++++-------- .../Text/TextSearch/TextSearch.cpp | 231 +++--- .../Text/UnicodeText/UnicodeText.cpp | 545 +++++++-------- CPlusPlus/Sample_Source/_Common/APDFLDoc.cpp | 7 +- CPlusPlus/Sample_Source/_Common/APDFLDoc.h | 77 +- .../_Common/APDFLDoc/APDFLDoc.cpp | 267 ------- .../Sample_Source/_Common/APDFLDoc/APDFLDoc.h | 61 -- .../Sample_Source/_Common/InitializeLibrary.h | 127 ++-- .../_Common/SampleCustomExceptions.h | 130 ++-- .../SampleCustomExceptions.h | 130 ++-- .../Sample_Source/_Common/SampleFileUtils.cpp | 102 ++- .../Sample_Source/_Common/SampleFileUtils.h | 2 +- .../SampleFileUtils/SampleFileUtils.cpp | 247 ------- .../_Common/SampleFileUtils/SampleFileUtils.h | 27 - CPlusPlus/Sample_Source/_Common/ScopeGuard.h | 380 ++++------ .../_Common/SetupPrintParams.cpp | 587 ++++++++-------- .../Sample_Source/_Common/SetupPrintParams.h | 2 +- .../_Common/ThirdParty/ScopeGuard.h | 380 ++++------ .../AnnotationCopyPaste.cs | 4 +- .../InkAnnotations/InkAnnotations.cs | 4 +- .../ContentModification/Action/Action.cs | 4 +- .../Display/DotNETViewer/DotNETViewer.cs | 6 +- .../DotNETPrintController.cs | 4 +- .../DotNETPrintDialog.cs | 40 +- .../DotNETViewerComponent/DotNETView.cs | 2 + .../ImageArray2DManager.cs | 5 +- .../TextSearchManager.cs | 7 + .../Images/DrawToBitmap/DrawToBitmap.cs | 53 +- .../PrintPDFGUI/PrintPDFForm.Designer.cs | 20 +- .../Printing/PrintPDFGUI/PrintPDFForm.cs | 204 ++---- .../Printing/PrintPDFGUI/PrintPDFGUI.cs | 25 +- DotNET/Sample_Source/Samples_32Bit.sln | 444 ------------ .../Sample_Source/Text/AddGlyphs/AddGlyphs.cs | 2 +- .../Text/TextExtract/TextExtract.cs | 7 +- .../UnderlinesAndHighlights.cs | 2 +- .../DisplayPDF/PasswordForm.Designer.cs | 4 +- .../Text/TextExtract/TextExtract.cs | 7 +- 93 files changed, 6045 insertions(+), 9214 deletions(-) delete mode 100644 CPlusPlus/Sample_Source/All/All_Datalogics_32Bit.sln delete mode 100644 CPlusPlus/Sample_Source/All/build_run_all.bat delete mode 100644 CPlusPlus/Sample_Source/_Common/APDFLDoc/APDFLDoc.cpp delete mode 100644 CPlusPlus/Sample_Source/_Common/APDFLDoc/APDFLDoc.h delete mode 100644 CPlusPlus/Sample_Source/_Common/SampleFileUtils/SampleFileUtils.cpp delete mode 100644 CPlusPlus/Sample_Source/_Common/SampleFileUtils/SampleFileUtils.h delete mode 100644 DotNET/Sample_Source/Samples_32Bit.sln diff --git a/CPlusPlus/Sample_Source/All/All_Datalogics_32Bit.sln b/CPlusPlus/Sample_Source/All/All_Datalogics_32Bit.sln deleted file mode 100644 index c1e151e4..00000000 --- a/CPlusPlus/Sample_Source/All/All_Datalogics_32Bit.sln +++ /dev/null @@ -1,660 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.40629.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AddContent", "..\ContentCreation\AddContent\AddContent.vcxproj", "{826BF32A-5414-4DF3-8AF4-C65583AA773D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AddDocumentInformation", "..\ContentModification\AddDocumentInformation\AddDocumentInformation.vcxproj", "{B4A82CA7-3133-458E-AA3C-E4808877DCBF}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AddPassword", "..\Security\AddPassword\AddPassword.vcxproj", "{1013E460-05A7-43D2-9E4F-B6366E7D1898}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AddText", "..\Text\AddText\AddText.vcxproj", "{82006940-7ECC-454B-A571-B3854C407D25}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CopyContent", "..\ContentExtraction\CopyContent\CopyContent.vcxproj", "{02D112D7-8B2A-4411-AE07-3F7E6169FF4A}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateDocument", "..\ContentCreation\CreateDocument\CreateDocument.vcxproj", "{82797824-D05B-4230-8211-5E5A09A62C40}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LockDocument", "..\Security\LockDocument\LockDocument.vcxproj", "{60609083-04E5-4635-99F5-25C8C5B818A0}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MergeDocuments", "..\ContentModification\MergeDocuments\MergeDocuments.vcxproj", "{729F3CA8-F868-42B8-B061-446C423DA9A8}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SetUniquePermissions", "..\Security\SetUniquePermissions\SetUniquePermissions.vcxproj", "{6A187553-5DE6-461E-9838-3A3765330451}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SplitPDF", "..\ContentModification\SplitPDF\SplitPDF.vcxproj", "{BF3F5105-EBCC-448A-8262-53DE2A125F54}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebOptimizedPDF", "..\DocumentOptimization\WebOptimizedPDF\WebOptimizedPDF.vcxproj", "{C7F0D2BF-4259-4B2C-BD59-0B7DCD9A15D5}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenEncrypted", "..\Security\OpenEncrypted\OpenEncrypted.vcxproj", "{91EBC49E-1D24-46E9-A465-696C1EBA3F23}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AddArt", "..\ContentCreation\AddArt\AddArt.vcxproj", "{5D04558C-183A-4ECC-80C8-542A9FDD72D2}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AddBookmarks", "..\ContentModification\AddBookmarks\AddBookmarks.vcxproj", "{A2575B7E-CCA9-42E4-8449-330BB89437AA}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AddLinks", "..\ContentModification\AddLinks\AddLinks.vcxproj", "{939FEDCC-E180-47EB-8270-8ED8BD37BCDD}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AddPageNumbers", "..\ContentModification\AddPageNumbers\AddPageNumbers.vcxproj", "{4184B1FF-6865-439F-89B3-7FAAC161E0DF}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AddRedaction", "..\Security\AddRedaction\AddRedaction.vcxproj", "{CB9E6C09-C2F2-4639-A66A-A930B706980C}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EncryptDocument", "..\Security\EncryptDocument\EncryptDocument.vcxproj", "{B8BF52E0-2350-47E4-B2B9-DC429C396DD2}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ExtractAttachments", "..\ContentExtraction\ExtractAttachments\ExtractAttachments.vcxproj", "{36821584-EBF6-4C21-B8D6-C99C245F3912}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TextSearch", "..\Text\TextSearch\TextSearch.vcxproj", "{CA4E530D-DAC1-4CAB-8C14-4B1B7EB4FFC6}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ExtractText", "..\Text\ExtractText\ExtractText.vcxproj", "{2E8F147F-1CB9-4345-9CBE-EE28312F224D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AddWatermark", "..\ContentModification\AddWatermark\AddWatermark.vcxproj", "{CCB809B8-E529-42BA-BD0D-41644CC3AAEF}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateAnnotations", "..\Annotations\CreateAnnotations\CreateAnnotations.vcxproj", "{F3E1C9B0-D3D9-4BE1-AE20-AFAC2C5B9131}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateLayers", "..\ContentCreation\CreateLayers\CreateLayers.vcxproj", "{51C87E29-66CD-4887-AFD7-3F83CB86A306}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateTransparency", "..\ContentCreation\CreateTransparency\CreateTransparency.vcxproj", "{B755F192-1117-415D-B968-B7406D170190}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ExtractDocumentInfo", "..\InformationExtraction\ExtractDocumentInfo\ExtractDocumentInfo.vcxproj", "{660DCD10-7EEB-4550-8E37-D57698FAD152}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FlattenAnnotations", "..\Annotations\FlattenAnnotations\FlattenAnnotations.vcxproj", "{09AA9892-256F-49FD-8C8A-8B35685E6B94}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RenderPage", "..\Images\RenderPage\RenderPage.vcxproj", "{65FB48A9-238C-4B34-ADCB-FF6E549F0B47}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnicodeText", "..\Text\UnicodeText\UnicodeText.vcxproj", "{26B0DAAC-1B6E-4020-BEC0-D47DDBA263C6}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XPStoPDF", "..\DocumentConversion\XPStoPDF\XPStoPDF.vcxproj", "{463169C1-D201-4A98-AEB5-D51E666CAEAF}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E606CC40-638C-466D-B7B0-851F3B1910A4}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FindImageResolutions", "..\Images\FindImageResolutions\FindImageResolutions.vcxproj", "{DA3822A3-6373-4701-A59E-5CE33509EA8B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FlattenTransparency", "..\ContentModification\FlattenTransparency\FlattenTransparency.vcxproj", "{0DA6E459-4717-4971-9126-F699804A7570}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AddAttachments", "..\ContentCreation\AddAttachments\AddAttachments.vcxproj", "{EC3EF969-ABF4-435D-A96F-31CF25F34307}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PDFViewer", "..\Display\PDFViewer\PDFViewer.vcxproj", "{52750764-6821-4DA2-9DB6-79A0AFD5225B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConvertPDFtoEPS", "..\DocumentConversion\ConvertPDFtoEPS\ConvertPDFtoEPS.vcxproj", "{F1B7F67C-A923-41D7-9C99-0AF318DF2198}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConvertPDFtoPostscript", "..\DocumentConversion\ConvertPDFtoPostscript\ConvertPDFtoPostscript.vcxproj", "{A8FC5A39-AC22-424A-AC33-9C6CF190CD6C}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PDFPrintGUI", "..\Printing\PDFPrintGUI\PDFPrintGUI.vcxproj", "{757D7956-3DF0-4657-9F1F-FBA28E12FC19}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PDFOptimizer", "..\DocumentOptimization\PDFOptimizer\PDFOptimizer.vcxproj", "{820700EC-AC15-4F2E-9038-3FB7A0E768F1}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AESEncryption", "..\Security\AESEncryption\AESEncryption.vcxproj", "{14A4AE0F-0FE2-4DF1-895E-EFE26B9884EA}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ValidateSignatures", "..\Security\ValidateSignatures\ValidateSignatures.vcxproj", "{FA60EB13-27C0-4C03-99CD-F40E5EA6A3E9}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateBookmarks", "..\ContentCreation\CreateBookmarks\CreateBookmarks.vcxproj", "{F8DAE1E5-FBB4-4D01-A7D4-780999124B98}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ExtractFonts", "..\ContentExtraction\ExtractFonts\ExtractFonts.vcxproj", "{DFCE18D6-018A-4CB7-B3DE-5AFE98E3C8A8}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AttachMimeToPDF", "..\ContentModification\AttachMimeToPDF\AttachMimeToPDF.vcxproj", "{4D965596-16B1-4CD7-B088-DD886BD97201}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EmbedFonts", "..\ContentModification\EmbedFonts\EmbedFonts.vcxproj", "{80B56AC3-FA76-4020-A2EE-90321444D72D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "importPages", "..\ContentModification\importPages\importPages.vcxproj", "{F3BB9ADB-FF05-47B0-B2F5-17B81F610577}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MergeAcroforms", "..\ContentModification\MergeAcroforms\MergeAcroforms.vcxproj", "{3008810A-36F9-4DAC-B5B9-1D7EA33D39EE}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PDFMakeOCGVisible", "..\ContentModification\PDFMakeOCGVisible\PDFMakeOCGVisible.vcxproj", "{9E5F39EF-C42F-4055-B363-1F2CEDD2B283}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PDFUncompress", "..\ContentModification\PDFUncompress\PDFUncompress.vcxproj", "{E4B88FFF-61AC-41B8-AEC4-144E24BB33BD}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DisplayPDEContent", "..\Display\DisplayPDEContent\DisplayPDEContent.vcxproj", "{3B7D642F-6073-414D-B614-B91DE1F7121A}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AlternateFileSystem", "..\FileSystem\AlternateFileSystem\AlternateFileSystem.vcxproj", "{EAF3D9E2-8831-4EDD-88D3-587F0380933D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AddThumbnailsToPDF", "..\Images\AddThumbnailsToPDF\AddThumbnailsToPDF.vcxproj", "{1D29C4C9-4701-44D3-AC89-1A415832DF93}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CalcImageDPI", "..\Images\CalcImageDPI\CalcImageDPI.vcxproj", "{48B0C39F-29D7-4595-B458-20E36B400C2E}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateImageWithTransparency", "..\Images\CreateImageWithTransparency\CreateImageWithTransparency.vcxproj", "{314BB4FB-91EE-49B8-A18A-8D996E5B75D2}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CountColorsInDoc", "..\InformationExtraction\CountColorsInDoc\CountColorsInDoc.vcxproj", "{23A89145-EE66-47A2-9BAF-2536CD858442}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PostscriptInjection", "..\Printing\PostScriptInjection\PostscriptInjection.vcxproj", "{A7B05FFC-9850-420B-B70F-1C96EF998CEB}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "helloJapan", "..\Text\helloJapan\helloJapan.vcxproj", "{B48E9BE6-B724-4061-8A70-6C2943F752AB}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InsertHeadFoot", "..\Text\InsertHeadFoot\InsertHeadFoot.vcxproj", "{93510DBC-51ED-450E-A45E-ECDF1E853D18}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConvertToPDFA", "..\DocumentConversion\ConvertToPDFA\ConvertToPDFA.vcxproj", "{99CD8B64-8362-4089-A610-D878CD422581}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConvertToPDFX", "..\DocumentConversion\ConvertToPDFX\ConvertToPDFX.vcxproj", "{A51E0247-F7EF-4C7E-96B7-F50752C73D81}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AddTriangularRedaction", "..\Security\AddTriangularRedaction\AddTriangularRedaction.vcxproj", "{7DCC48B1-285D-4653-99AD-B707BEBBCB1C}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OutputPreview", "..\Images\OutputPreview\OutputPreview.vcxproj", "{2E9645DE-DE90-4CCB-9AF6-073032EF73CC}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateSeparations", "..\Images\CreateSeparations\CreateSeparations.vcxproj", "{9E815E2B-9D2E-4814-9FEE-F8919CEB3787}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PDFPrintDefault", "..\Printing\PDFPrintDefault\PDFPrintDefault.vcxproj", "{2DD18C42-8F5F-4741-9B3E-65B48D8C61AA}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TextSelectEnum", "..\Text\TextSelectEnum\TextSelectEnum.vcxproj", "{70DC7A8A-3F4A-43CF-9DE2-A9C477121319}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {826BF32A-5414-4DF3-8AF4-C65583AA773D}.Debug|Win32.ActiveCfg = Debug|Win32 - {826BF32A-5414-4DF3-8AF4-C65583AA773D}.Debug|Win32.Build.0 = Debug|Win32 - {826BF32A-5414-4DF3-8AF4-C65583AA773D}.Debug|x64.ActiveCfg = Debug|x64 - {826BF32A-5414-4DF3-8AF4-C65583AA773D}.Debug|x64.Build.0 = Debug|x64 - {826BF32A-5414-4DF3-8AF4-C65583AA773D}.Release|Win32.ActiveCfg = Release|Win32 - {826BF32A-5414-4DF3-8AF4-C65583AA773D}.Release|Win32.Build.0 = Release|Win32 - {826BF32A-5414-4DF3-8AF4-C65583AA773D}.Release|x64.ActiveCfg = Release|x64 - {826BF32A-5414-4DF3-8AF4-C65583AA773D}.Release|x64.Build.0 = Release|x64 - {B4A82CA7-3133-458E-AA3C-E4808877DCBF}.Debug|Win32.ActiveCfg = Debug|Win32 - {B4A82CA7-3133-458E-AA3C-E4808877DCBF}.Debug|Win32.Build.0 = Debug|Win32 - {B4A82CA7-3133-458E-AA3C-E4808877DCBF}.Debug|x64.ActiveCfg = Debug|x64 - {B4A82CA7-3133-458E-AA3C-E4808877DCBF}.Debug|x64.Build.0 = Debug|x64 - {B4A82CA7-3133-458E-AA3C-E4808877DCBF}.Release|Win32.ActiveCfg = Release|Win32 - {B4A82CA7-3133-458E-AA3C-E4808877DCBF}.Release|Win32.Build.0 = Release|Win32 - {B4A82CA7-3133-458E-AA3C-E4808877DCBF}.Release|x64.ActiveCfg = Release|x64 - {B4A82CA7-3133-458E-AA3C-E4808877DCBF}.Release|x64.Build.0 = Release|x64 - {1013E460-05A7-43D2-9E4F-B6366E7D1898}.Debug|Win32.ActiveCfg = Debug|Win32 - {1013E460-05A7-43D2-9E4F-B6366E7D1898}.Debug|Win32.Build.0 = Debug|Win32 - {1013E460-05A7-43D2-9E4F-B6366E7D1898}.Debug|x64.ActiveCfg = Debug|x64 - {1013E460-05A7-43D2-9E4F-B6366E7D1898}.Debug|x64.Build.0 = Debug|x64 - {1013E460-05A7-43D2-9E4F-B6366E7D1898}.Release|Win32.ActiveCfg = Release|Win32 - {1013E460-05A7-43D2-9E4F-B6366E7D1898}.Release|Win32.Build.0 = Release|Win32 - {1013E460-05A7-43D2-9E4F-B6366E7D1898}.Release|x64.ActiveCfg = Release|x64 - {1013E460-05A7-43D2-9E4F-B6366E7D1898}.Release|x64.Build.0 = Release|x64 - {82006940-7ECC-454B-A571-B3854C407D25}.Debug|Win32.ActiveCfg = Debug|Win32 - {82006940-7ECC-454B-A571-B3854C407D25}.Debug|Win32.Build.0 = Debug|Win32 - {82006940-7ECC-454B-A571-B3854C407D25}.Debug|x64.ActiveCfg = Debug|x64 - {82006940-7ECC-454B-A571-B3854C407D25}.Debug|x64.Build.0 = Debug|x64 - {82006940-7ECC-454B-A571-B3854C407D25}.Release|Win32.ActiveCfg = Release|Win32 - {82006940-7ECC-454B-A571-B3854C407D25}.Release|Win32.Build.0 = Release|Win32 - {82006940-7ECC-454B-A571-B3854C407D25}.Release|x64.ActiveCfg = Release|x64 - {82006940-7ECC-454B-A571-B3854C407D25}.Release|x64.Build.0 = Release|x64 - {02D112D7-8B2A-4411-AE07-3F7E6169FF4A}.Debug|Win32.ActiveCfg = Debug|Win32 - {02D112D7-8B2A-4411-AE07-3F7E6169FF4A}.Debug|Win32.Build.0 = Debug|Win32 - {02D112D7-8B2A-4411-AE07-3F7E6169FF4A}.Debug|x64.ActiveCfg = Debug|x64 - {02D112D7-8B2A-4411-AE07-3F7E6169FF4A}.Debug|x64.Build.0 = Debug|x64 - {02D112D7-8B2A-4411-AE07-3F7E6169FF4A}.Release|Win32.ActiveCfg = Release|Win32 - {02D112D7-8B2A-4411-AE07-3F7E6169FF4A}.Release|Win32.Build.0 = Release|Win32 - {02D112D7-8B2A-4411-AE07-3F7E6169FF4A}.Release|x64.ActiveCfg = Release|x64 - {02D112D7-8B2A-4411-AE07-3F7E6169FF4A}.Release|x64.Build.0 = Release|x64 - {82797824-D05B-4230-8211-5E5A09A62C40}.Debug|Win32.ActiveCfg = Debug|Win32 - {82797824-D05B-4230-8211-5E5A09A62C40}.Debug|Win32.Build.0 = Debug|Win32 - {82797824-D05B-4230-8211-5E5A09A62C40}.Debug|x64.ActiveCfg = Debug|x64 - {82797824-D05B-4230-8211-5E5A09A62C40}.Debug|x64.Build.0 = Debug|x64 - {82797824-D05B-4230-8211-5E5A09A62C40}.Release|Win32.ActiveCfg = Release|Win32 - {82797824-D05B-4230-8211-5E5A09A62C40}.Release|Win32.Build.0 = Release|Win32 - {82797824-D05B-4230-8211-5E5A09A62C40}.Release|x64.ActiveCfg = Release|x64 - {82797824-D05B-4230-8211-5E5A09A62C40}.Release|x64.Build.0 = Release|x64 - {60609083-04E5-4635-99F5-25C8C5B818A0}.Debug|Win32.ActiveCfg = Debug|Win32 - {60609083-04E5-4635-99F5-25C8C5B818A0}.Debug|Win32.Build.0 = Debug|Win32 - {60609083-04E5-4635-99F5-25C8C5B818A0}.Debug|x64.ActiveCfg = Debug|x64 - {60609083-04E5-4635-99F5-25C8C5B818A0}.Debug|x64.Build.0 = Debug|x64 - {60609083-04E5-4635-99F5-25C8C5B818A0}.Release|Win32.ActiveCfg = Release|Win32 - {60609083-04E5-4635-99F5-25C8C5B818A0}.Release|Win32.Build.0 = Release|Win32 - {60609083-04E5-4635-99F5-25C8C5B818A0}.Release|x64.ActiveCfg = Release|x64 - {60609083-04E5-4635-99F5-25C8C5B818A0}.Release|x64.Build.0 = Release|x64 - {729F3CA8-F868-42B8-B061-446C423DA9A8}.Debug|Win32.ActiveCfg = Debug|Win32 - {729F3CA8-F868-42B8-B061-446C423DA9A8}.Debug|Win32.Build.0 = Debug|Win32 - {729F3CA8-F868-42B8-B061-446C423DA9A8}.Debug|x64.ActiveCfg = Debug|x64 - {729F3CA8-F868-42B8-B061-446C423DA9A8}.Debug|x64.Build.0 = Debug|x64 - {729F3CA8-F868-42B8-B061-446C423DA9A8}.Release|Win32.ActiveCfg = Release|Win32 - {729F3CA8-F868-42B8-B061-446C423DA9A8}.Release|Win32.Build.0 = Release|Win32 - {729F3CA8-F868-42B8-B061-446C423DA9A8}.Release|x64.ActiveCfg = Release|x64 - {729F3CA8-F868-42B8-B061-446C423DA9A8}.Release|x64.Build.0 = Release|x64 - {6A187553-5DE6-461E-9838-3A3765330451}.Debug|Win32.ActiveCfg = Debug|Win32 - {6A187553-5DE6-461E-9838-3A3765330451}.Debug|Win32.Build.0 = Debug|Win32 - {6A187553-5DE6-461E-9838-3A3765330451}.Debug|x64.ActiveCfg = Debug|x64 - {6A187553-5DE6-461E-9838-3A3765330451}.Debug|x64.Build.0 = Debug|x64 - {6A187553-5DE6-461E-9838-3A3765330451}.Release|Win32.ActiveCfg = Release|Win32 - {6A187553-5DE6-461E-9838-3A3765330451}.Release|Win32.Build.0 = Release|Win32 - {6A187553-5DE6-461E-9838-3A3765330451}.Release|x64.ActiveCfg = Release|x64 - {6A187553-5DE6-461E-9838-3A3765330451}.Release|x64.Build.0 = Release|x64 - {BF3F5105-EBCC-448A-8262-53DE2A125F54}.Debug|Win32.ActiveCfg = Debug|Win32 - {BF3F5105-EBCC-448A-8262-53DE2A125F54}.Debug|Win32.Build.0 = Debug|Win32 - {BF3F5105-EBCC-448A-8262-53DE2A125F54}.Debug|x64.ActiveCfg = Debug|x64 - {BF3F5105-EBCC-448A-8262-53DE2A125F54}.Debug|x64.Build.0 = Debug|x64 - {BF3F5105-EBCC-448A-8262-53DE2A125F54}.Release|Win32.ActiveCfg = Release|Win32 - {BF3F5105-EBCC-448A-8262-53DE2A125F54}.Release|Win32.Build.0 = Release|Win32 - {BF3F5105-EBCC-448A-8262-53DE2A125F54}.Release|x64.ActiveCfg = Release|x64 - {BF3F5105-EBCC-448A-8262-53DE2A125F54}.Release|x64.Build.0 = Release|x64 - {C7F0D2BF-4259-4B2C-BD59-0B7DCD9A15D5}.Debug|Win32.ActiveCfg = Debug|Win32 - {C7F0D2BF-4259-4B2C-BD59-0B7DCD9A15D5}.Debug|Win32.Build.0 = Debug|Win32 - {C7F0D2BF-4259-4B2C-BD59-0B7DCD9A15D5}.Debug|x64.ActiveCfg = Debug|x64 - {C7F0D2BF-4259-4B2C-BD59-0B7DCD9A15D5}.Debug|x64.Build.0 = Debug|x64 - {C7F0D2BF-4259-4B2C-BD59-0B7DCD9A15D5}.Release|Win32.ActiveCfg = Release|Win32 - {C7F0D2BF-4259-4B2C-BD59-0B7DCD9A15D5}.Release|Win32.Build.0 = Release|Win32 - {C7F0D2BF-4259-4B2C-BD59-0B7DCD9A15D5}.Release|x64.ActiveCfg = Release|x64 - {C7F0D2BF-4259-4B2C-BD59-0B7DCD9A15D5}.Release|x64.Build.0 = Release|x64 - {91EBC49E-1D24-46E9-A465-696C1EBA3F23}.Debug|Win32.ActiveCfg = Debug|Win32 - {91EBC49E-1D24-46E9-A465-696C1EBA3F23}.Debug|Win32.Build.0 = Debug|Win32 - {91EBC49E-1D24-46E9-A465-696C1EBA3F23}.Debug|x64.ActiveCfg = Debug|x64 - {91EBC49E-1D24-46E9-A465-696C1EBA3F23}.Debug|x64.Build.0 = Debug|x64 - {91EBC49E-1D24-46E9-A465-696C1EBA3F23}.Release|Win32.ActiveCfg = Release|Win32 - {91EBC49E-1D24-46E9-A465-696C1EBA3F23}.Release|Win32.Build.0 = Release|Win32 - {91EBC49E-1D24-46E9-A465-696C1EBA3F23}.Release|x64.ActiveCfg = Release|x64 - {91EBC49E-1D24-46E9-A465-696C1EBA3F23}.Release|x64.Build.0 = Release|x64 - {5D04558C-183A-4ECC-80C8-542A9FDD72D2}.Debug|Win32.ActiveCfg = Debug|Win32 - {5D04558C-183A-4ECC-80C8-542A9FDD72D2}.Debug|Win32.Build.0 = Debug|Win32 - {5D04558C-183A-4ECC-80C8-542A9FDD72D2}.Debug|x64.ActiveCfg = Debug|x64 - {5D04558C-183A-4ECC-80C8-542A9FDD72D2}.Debug|x64.Build.0 = Debug|x64 - {5D04558C-183A-4ECC-80C8-542A9FDD72D2}.Release|Win32.ActiveCfg = Release|Win32 - {5D04558C-183A-4ECC-80C8-542A9FDD72D2}.Release|Win32.Build.0 = Release|Win32 - {5D04558C-183A-4ECC-80C8-542A9FDD72D2}.Release|x64.ActiveCfg = Release|x64 - {5D04558C-183A-4ECC-80C8-542A9FDD72D2}.Release|x64.Build.0 = Release|x64 - {A2575B7E-CCA9-42E4-8449-330BB89437AA}.Debug|Win32.ActiveCfg = Debug|Win32 - {A2575B7E-CCA9-42E4-8449-330BB89437AA}.Debug|Win32.Build.0 = Debug|Win32 - {A2575B7E-CCA9-42E4-8449-330BB89437AA}.Debug|x64.ActiveCfg = Debug|x64 - {A2575B7E-CCA9-42E4-8449-330BB89437AA}.Debug|x64.Build.0 = Debug|x64 - {A2575B7E-CCA9-42E4-8449-330BB89437AA}.Release|Win32.ActiveCfg = Release|Win32 - {A2575B7E-CCA9-42E4-8449-330BB89437AA}.Release|Win32.Build.0 = Release|Win32 - {A2575B7E-CCA9-42E4-8449-330BB89437AA}.Release|x64.ActiveCfg = Release|x64 - {A2575B7E-CCA9-42E4-8449-330BB89437AA}.Release|x64.Build.0 = Release|x64 - {939FEDCC-E180-47EB-8270-8ED8BD37BCDD}.Debug|Win32.ActiveCfg = Debug|Win32 - {939FEDCC-E180-47EB-8270-8ED8BD37BCDD}.Debug|Win32.Build.0 = Debug|Win32 - {939FEDCC-E180-47EB-8270-8ED8BD37BCDD}.Debug|x64.ActiveCfg = Debug|x64 - {939FEDCC-E180-47EB-8270-8ED8BD37BCDD}.Debug|x64.Build.0 = Debug|x64 - {939FEDCC-E180-47EB-8270-8ED8BD37BCDD}.Release|Win32.ActiveCfg = Release|Win32 - {939FEDCC-E180-47EB-8270-8ED8BD37BCDD}.Release|Win32.Build.0 = Release|Win32 - {939FEDCC-E180-47EB-8270-8ED8BD37BCDD}.Release|x64.ActiveCfg = Release|x64 - {939FEDCC-E180-47EB-8270-8ED8BD37BCDD}.Release|x64.Build.0 = Release|x64 - {4184B1FF-6865-439F-89B3-7FAAC161E0DF}.Debug|Win32.ActiveCfg = Debug|Win32 - {4184B1FF-6865-439F-89B3-7FAAC161E0DF}.Debug|Win32.Build.0 = Debug|Win32 - {4184B1FF-6865-439F-89B3-7FAAC161E0DF}.Debug|x64.ActiveCfg = Debug|x64 - {4184B1FF-6865-439F-89B3-7FAAC161E0DF}.Debug|x64.Build.0 = Debug|x64 - {4184B1FF-6865-439F-89B3-7FAAC161E0DF}.Release|Win32.ActiveCfg = Release|Win32 - {4184B1FF-6865-439F-89B3-7FAAC161E0DF}.Release|Win32.Build.0 = Release|Win32 - {4184B1FF-6865-439F-89B3-7FAAC161E0DF}.Release|x64.ActiveCfg = Release|x64 - {4184B1FF-6865-439F-89B3-7FAAC161E0DF}.Release|x64.Build.0 = Release|x64 - {CB9E6C09-C2F2-4639-A66A-A930B706980C}.Debug|Win32.ActiveCfg = Debug|Win32 - {CB9E6C09-C2F2-4639-A66A-A930B706980C}.Debug|Win32.Build.0 = Debug|Win32 - {CB9E6C09-C2F2-4639-A66A-A930B706980C}.Debug|x64.ActiveCfg = Debug|x64 - {CB9E6C09-C2F2-4639-A66A-A930B706980C}.Debug|x64.Build.0 = Debug|x64 - {CB9E6C09-C2F2-4639-A66A-A930B706980C}.Release|Win32.ActiveCfg = Release|Win32 - {CB9E6C09-C2F2-4639-A66A-A930B706980C}.Release|Win32.Build.0 = Release|Win32 - {CB9E6C09-C2F2-4639-A66A-A930B706980C}.Release|x64.ActiveCfg = Release|x64 - {CB9E6C09-C2F2-4639-A66A-A930B706980C}.Release|x64.Build.0 = Release|x64 - {B8BF52E0-2350-47E4-B2B9-DC429C396DD2}.Debug|Win32.ActiveCfg = Debug|Win32 - {B8BF52E0-2350-47E4-B2B9-DC429C396DD2}.Debug|Win32.Build.0 = Debug|Win32 - {B8BF52E0-2350-47E4-B2B9-DC429C396DD2}.Debug|x64.ActiveCfg = Debug|x64 - {B8BF52E0-2350-47E4-B2B9-DC429C396DD2}.Debug|x64.Build.0 = Debug|x64 - {B8BF52E0-2350-47E4-B2B9-DC429C396DD2}.Release|Win32.ActiveCfg = Release|Win32 - {B8BF52E0-2350-47E4-B2B9-DC429C396DD2}.Release|Win32.Build.0 = Release|Win32 - {B8BF52E0-2350-47E4-B2B9-DC429C396DD2}.Release|x64.ActiveCfg = Release|x64 - {B8BF52E0-2350-47E4-B2B9-DC429C396DD2}.Release|x64.Build.0 = Release|x64 - {36821584-EBF6-4C21-B8D6-C99C245F3912}.Debug|Win32.ActiveCfg = Debug|Win32 - {36821584-EBF6-4C21-B8D6-C99C245F3912}.Debug|Win32.Build.0 = Debug|Win32 - {36821584-EBF6-4C21-B8D6-C99C245F3912}.Debug|x64.ActiveCfg = Debug|x64 - {36821584-EBF6-4C21-B8D6-C99C245F3912}.Debug|x64.Build.0 = Debug|x64 - {36821584-EBF6-4C21-B8D6-C99C245F3912}.Release|Win32.ActiveCfg = Release|Win32 - {36821584-EBF6-4C21-B8D6-C99C245F3912}.Release|Win32.Build.0 = Release|Win32 - {36821584-EBF6-4C21-B8D6-C99C245F3912}.Release|x64.ActiveCfg = Release|x64 - {36821584-EBF6-4C21-B8D6-C99C245F3912}.Release|x64.Build.0 = Release|x64 - {CA4E530D-DAC1-4CAB-8C14-4B1B7EB4FFC6}.Debug|Win32.ActiveCfg = Debug|Win32 - {CA4E530D-DAC1-4CAB-8C14-4B1B7EB4FFC6}.Debug|Win32.Build.0 = Debug|Win32 - {CA4E530D-DAC1-4CAB-8C14-4B1B7EB4FFC6}.Debug|x64.ActiveCfg = Debug|x64 - {CA4E530D-DAC1-4CAB-8C14-4B1B7EB4FFC6}.Debug|x64.Build.0 = Debug|x64 - {CA4E530D-DAC1-4CAB-8C14-4B1B7EB4FFC6}.Release|Win32.ActiveCfg = Release|Win32 - {CA4E530D-DAC1-4CAB-8C14-4B1B7EB4FFC6}.Release|Win32.Build.0 = Release|Win32 - {CA4E530D-DAC1-4CAB-8C14-4B1B7EB4FFC6}.Release|x64.ActiveCfg = Release|x64 - {CA4E530D-DAC1-4CAB-8C14-4B1B7EB4FFC6}.Release|x64.Build.0 = Release|x64 - {2E8F147F-1CB9-4345-9CBE-EE28312F224D}.Debug|Win32.ActiveCfg = Debug|Win32 - {2E8F147F-1CB9-4345-9CBE-EE28312F224D}.Debug|Win32.Build.0 = Debug|Win32 - {2E8F147F-1CB9-4345-9CBE-EE28312F224D}.Debug|x64.ActiveCfg = Debug|x64 - {2E8F147F-1CB9-4345-9CBE-EE28312F224D}.Debug|x64.Build.0 = Debug|x64 - {2E8F147F-1CB9-4345-9CBE-EE28312F224D}.Release|Win32.ActiveCfg = Release|Win32 - {2E8F147F-1CB9-4345-9CBE-EE28312F224D}.Release|Win32.Build.0 = Release|Win32 - {2E8F147F-1CB9-4345-9CBE-EE28312F224D}.Release|x64.ActiveCfg = Release|x64 - {2E8F147F-1CB9-4345-9CBE-EE28312F224D}.Release|x64.Build.0 = Release|x64 - {CCB809B8-E529-42BA-BD0D-41644CC3AAEF}.Debug|Win32.ActiveCfg = Debug|Win32 - {CCB809B8-E529-42BA-BD0D-41644CC3AAEF}.Debug|Win32.Build.0 = Debug|Win32 - {CCB809B8-E529-42BA-BD0D-41644CC3AAEF}.Debug|x64.ActiveCfg = Debug|x64 - {CCB809B8-E529-42BA-BD0D-41644CC3AAEF}.Debug|x64.Build.0 = Debug|x64 - {CCB809B8-E529-42BA-BD0D-41644CC3AAEF}.Release|Win32.ActiveCfg = Release|Win32 - {CCB809B8-E529-42BA-BD0D-41644CC3AAEF}.Release|Win32.Build.0 = Release|Win32 - {CCB809B8-E529-42BA-BD0D-41644CC3AAEF}.Release|x64.ActiveCfg = Release|x64 - {CCB809B8-E529-42BA-BD0D-41644CC3AAEF}.Release|x64.Build.0 = Release|x64 - {F3E1C9B0-D3D9-4BE1-AE20-AFAC2C5B9131}.Debug|Win32.ActiveCfg = Debug|Win32 - {F3E1C9B0-D3D9-4BE1-AE20-AFAC2C5B9131}.Debug|Win32.Build.0 = Debug|Win32 - {F3E1C9B0-D3D9-4BE1-AE20-AFAC2C5B9131}.Debug|x64.ActiveCfg = Debug|x64 - {F3E1C9B0-D3D9-4BE1-AE20-AFAC2C5B9131}.Debug|x64.Build.0 = Debug|x64 - {F3E1C9B0-D3D9-4BE1-AE20-AFAC2C5B9131}.Release|Win32.ActiveCfg = Release|Win32 - {F3E1C9B0-D3D9-4BE1-AE20-AFAC2C5B9131}.Release|Win32.Build.0 = Release|Win32 - {F3E1C9B0-D3D9-4BE1-AE20-AFAC2C5B9131}.Release|x64.ActiveCfg = Release|x64 - {F3E1C9B0-D3D9-4BE1-AE20-AFAC2C5B9131}.Release|x64.Build.0 = Release|x64 - {51C87E29-66CD-4887-AFD7-3F83CB86A306}.Debug|Win32.ActiveCfg = Debug|Win32 - {51C87E29-66CD-4887-AFD7-3F83CB86A306}.Debug|Win32.Build.0 = Debug|Win32 - {51C87E29-66CD-4887-AFD7-3F83CB86A306}.Debug|x64.ActiveCfg = Debug|x64 - {51C87E29-66CD-4887-AFD7-3F83CB86A306}.Debug|x64.Build.0 = Debug|x64 - {51C87E29-66CD-4887-AFD7-3F83CB86A306}.Release|Win32.ActiveCfg = Release|Win32 - {51C87E29-66CD-4887-AFD7-3F83CB86A306}.Release|Win32.Build.0 = Release|Win32 - {51C87E29-66CD-4887-AFD7-3F83CB86A306}.Release|x64.ActiveCfg = Release|x64 - {51C87E29-66CD-4887-AFD7-3F83CB86A306}.Release|x64.Build.0 = Release|x64 - {B755F192-1117-415D-B968-B7406D170190}.Debug|Win32.ActiveCfg = Debug|Win32 - {B755F192-1117-415D-B968-B7406D170190}.Debug|Win32.Build.0 = Debug|Win32 - {B755F192-1117-415D-B968-B7406D170190}.Debug|x64.ActiveCfg = Debug|x64 - {B755F192-1117-415D-B968-B7406D170190}.Debug|x64.Build.0 = Debug|x64 - {B755F192-1117-415D-B968-B7406D170190}.Release|Win32.ActiveCfg = Release|Win32 - {B755F192-1117-415D-B968-B7406D170190}.Release|Win32.Build.0 = Release|Win32 - {B755F192-1117-415D-B968-B7406D170190}.Release|x64.ActiveCfg = Release|x64 - {B755F192-1117-415D-B968-B7406D170190}.Release|x64.Build.0 = Release|x64 - {660DCD10-7EEB-4550-8E37-D57698FAD152}.Debug|Win32.ActiveCfg = Debug|Win32 - {660DCD10-7EEB-4550-8E37-D57698FAD152}.Debug|Win32.Build.0 = Debug|Win32 - {660DCD10-7EEB-4550-8E37-D57698FAD152}.Debug|x64.ActiveCfg = Debug|x64 - {660DCD10-7EEB-4550-8E37-D57698FAD152}.Debug|x64.Build.0 = Debug|x64 - {660DCD10-7EEB-4550-8E37-D57698FAD152}.Release|Win32.ActiveCfg = Release|Win32 - {660DCD10-7EEB-4550-8E37-D57698FAD152}.Release|Win32.Build.0 = Release|Win32 - {660DCD10-7EEB-4550-8E37-D57698FAD152}.Release|x64.ActiveCfg = Release|x64 - {660DCD10-7EEB-4550-8E37-D57698FAD152}.Release|x64.Build.0 = Release|x64 - {09AA9892-256F-49FD-8C8A-8B35685E6B94}.Debug|Win32.ActiveCfg = Debug|Win32 - {09AA9892-256F-49FD-8C8A-8B35685E6B94}.Debug|Win32.Build.0 = Debug|Win32 - {09AA9892-256F-49FD-8C8A-8B35685E6B94}.Debug|x64.ActiveCfg = Debug|x64 - {09AA9892-256F-49FD-8C8A-8B35685E6B94}.Debug|x64.Build.0 = Debug|x64 - {09AA9892-256F-49FD-8C8A-8B35685E6B94}.Release|Win32.ActiveCfg = Release|Win32 - {09AA9892-256F-49FD-8C8A-8B35685E6B94}.Release|Win32.Build.0 = Release|Win32 - {09AA9892-256F-49FD-8C8A-8B35685E6B94}.Release|x64.ActiveCfg = Release|x64 - {09AA9892-256F-49FD-8C8A-8B35685E6B94}.Release|x64.Build.0 = Release|x64 - {65FB48A9-238C-4B34-ADCB-FF6E549F0B47}.Debug|Win32.ActiveCfg = Debug|Win32 - {65FB48A9-238C-4B34-ADCB-FF6E549F0B47}.Debug|Win32.Build.0 = Debug|Win32 - {65FB48A9-238C-4B34-ADCB-FF6E549F0B47}.Debug|x64.ActiveCfg = Debug|x64 - {65FB48A9-238C-4B34-ADCB-FF6E549F0B47}.Debug|x64.Build.0 = Debug|x64 - {65FB48A9-238C-4B34-ADCB-FF6E549F0B47}.Release|Win32.ActiveCfg = Release|Win32 - {65FB48A9-238C-4B34-ADCB-FF6E549F0B47}.Release|Win32.Build.0 = Release|Win32 - {65FB48A9-238C-4B34-ADCB-FF6E549F0B47}.Release|x64.ActiveCfg = Release|x64 - {65FB48A9-238C-4B34-ADCB-FF6E549F0B47}.Release|x64.Build.0 = Release|x64 - {26B0DAAC-1B6E-4020-BEC0-D47DDBA263C6}.Debug|Win32.ActiveCfg = Debug|Win32 - {26B0DAAC-1B6E-4020-BEC0-D47DDBA263C6}.Debug|Win32.Build.0 = Debug|Win32 - {26B0DAAC-1B6E-4020-BEC0-D47DDBA263C6}.Debug|x64.ActiveCfg = Debug|x64 - {26B0DAAC-1B6E-4020-BEC0-D47DDBA263C6}.Debug|x64.Build.0 = Debug|x64 - {26B0DAAC-1B6E-4020-BEC0-D47DDBA263C6}.Release|Win32.ActiveCfg = Release|Win32 - {26B0DAAC-1B6E-4020-BEC0-D47DDBA263C6}.Release|Win32.Build.0 = Release|Win32 - {26B0DAAC-1B6E-4020-BEC0-D47DDBA263C6}.Release|x64.ActiveCfg = Release|x64 - {26B0DAAC-1B6E-4020-BEC0-D47DDBA263C6}.Release|x64.Build.0 = Release|x64 - {463169C1-D201-4A98-AEB5-D51E666CAEAF}.Debug|Win32.ActiveCfg = Debug|Win32 - {463169C1-D201-4A98-AEB5-D51E666CAEAF}.Debug|Win32.Build.0 = Debug|Win32 - {463169C1-D201-4A98-AEB5-D51E666CAEAF}.Debug|x64.ActiveCfg = Debug|x64 - {463169C1-D201-4A98-AEB5-D51E666CAEAF}.Debug|x64.Build.0 = Debug|x64 - {463169C1-D201-4A98-AEB5-D51E666CAEAF}.Release|Win32.ActiveCfg = Release|Win32 - {463169C1-D201-4A98-AEB5-D51E666CAEAF}.Release|Win32.Build.0 = Release|Win32 - {463169C1-D201-4A98-AEB5-D51E666CAEAF}.Release|x64.ActiveCfg = Release|x64 - {463169C1-D201-4A98-AEB5-D51E666CAEAF}.Release|x64.Build.0 = Release|x64 - {DA3822A3-6373-4701-A59E-5CE33509EA8B}.Debug|Win32.ActiveCfg = Debug|Win32 - {DA3822A3-6373-4701-A59E-5CE33509EA8B}.Debug|Win32.Build.0 = Debug|Win32 - {DA3822A3-6373-4701-A59E-5CE33509EA8B}.Debug|x64.ActiveCfg = Debug|x64 - {DA3822A3-6373-4701-A59E-5CE33509EA8B}.Debug|x64.Build.0 = Debug|x64 - {DA3822A3-6373-4701-A59E-5CE33509EA8B}.Release|Win32.ActiveCfg = Release|Win32 - {DA3822A3-6373-4701-A59E-5CE33509EA8B}.Release|Win32.Build.0 = Release|Win32 - {DA3822A3-6373-4701-A59E-5CE33509EA8B}.Release|x64.ActiveCfg = Release|x64 - {DA3822A3-6373-4701-A59E-5CE33509EA8B}.Release|x64.Build.0 = Release|x64 - {0DA6E459-4717-4971-9126-F699804A7570}.Debug|Win32.ActiveCfg = Debug|Win32 - {0DA6E459-4717-4971-9126-F699804A7570}.Debug|Win32.Build.0 = Debug|Win32 - {0DA6E459-4717-4971-9126-F699804A7570}.Debug|x64.ActiveCfg = Debug|x64 - {0DA6E459-4717-4971-9126-F699804A7570}.Debug|x64.Build.0 = Debug|x64 - {0DA6E459-4717-4971-9126-F699804A7570}.Release|Win32.ActiveCfg = Release|Win32 - {0DA6E459-4717-4971-9126-F699804A7570}.Release|Win32.Build.0 = Release|Win32 - {0DA6E459-4717-4971-9126-F699804A7570}.Release|x64.ActiveCfg = Release|x64 - {0DA6E459-4717-4971-9126-F699804A7570}.Release|x64.Build.0 = Release|x64 - {EC3EF969-ABF4-435D-A96F-31CF25F34307}.Debug|Win32.ActiveCfg = Debug|Win32 - {EC3EF969-ABF4-435D-A96F-31CF25F34307}.Debug|Win32.Build.0 = Debug|Win32 - {EC3EF969-ABF4-435D-A96F-31CF25F34307}.Debug|x64.ActiveCfg = Debug|x64 - {EC3EF969-ABF4-435D-A96F-31CF25F34307}.Debug|x64.Build.0 = Debug|x64 - {EC3EF969-ABF4-435D-A96F-31CF25F34307}.Release|Win32.ActiveCfg = Release|Win32 - {EC3EF969-ABF4-435D-A96F-31CF25F34307}.Release|Win32.Build.0 = Release|Win32 - {EC3EF969-ABF4-435D-A96F-31CF25F34307}.Release|x64.ActiveCfg = Release|x64 - {EC3EF969-ABF4-435D-A96F-31CF25F34307}.Release|x64.Build.0 = Release|x64 - {52750764-6821-4DA2-9DB6-79A0AFD5225B}.Debug|Win32.ActiveCfg = Debug|Win32 - {52750764-6821-4DA2-9DB6-79A0AFD5225B}.Debug|Win32.Build.0 = Debug|Win32 - {52750764-6821-4DA2-9DB6-79A0AFD5225B}.Debug|x64.ActiveCfg = Debug|x64 - {52750764-6821-4DA2-9DB6-79A0AFD5225B}.Debug|x64.Build.0 = Debug|x64 - {52750764-6821-4DA2-9DB6-79A0AFD5225B}.Release|Win32.ActiveCfg = Release|Win32 - {52750764-6821-4DA2-9DB6-79A0AFD5225B}.Release|Win32.Build.0 = Release|Win32 - {52750764-6821-4DA2-9DB6-79A0AFD5225B}.Release|x64.ActiveCfg = Release|x64 - {52750764-6821-4DA2-9DB6-79A0AFD5225B}.Release|x64.Build.0 = Release|x64 - {F1B7F67C-A923-41D7-9C99-0AF318DF2198}.Debug|Win32.ActiveCfg = Debug|Win32 - {F1B7F67C-A923-41D7-9C99-0AF318DF2198}.Debug|Win32.Build.0 = Debug|Win32 - {F1B7F67C-A923-41D7-9C99-0AF318DF2198}.Debug|x64.ActiveCfg = Debug|x64 - {F1B7F67C-A923-41D7-9C99-0AF318DF2198}.Debug|x64.Build.0 = Debug|x64 - {F1B7F67C-A923-41D7-9C99-0AF318DF2198}.Release|Win32.ActiveCfg = Release|Win32 - {F1B7F67C-A923-41D7-9C99-0AF318DF2198}.Release|Win32.Build.0 = Release|Win32 - {F1B7F67C-A923-41D7-9C99-0AF318DF2198}.Release|x64.ActiveCfg = Release|x64 - {F1B7F67C-A923-41D7-9C99-0AF318DF2198}.Release|x64.Build.0 = Release|x64 - {A8FC5A39-AC22-424A-AC33-9C6CF190CD6C}.Debug|Win32.ActiveCfg = Debug|Win32 - {A8FC5A39-AC22-424A-AC33-9C6CF190CD6C}.Debug|Win32.Build.0 = Debug|Win32 - {A8FC5A39-AC22-424A-AC33-9C6CF190CD6C}.Debug|x64.ActiveCfg = Debug|x64 - {A8FC5A39-AC22-424A-AC33-9C6CF190CD6C}.Debug|x64.Build.0 = Debug|x64 - {A8FC5A39-AC22-424A-AC33-9C6CF190CD6C}.Release|Win32.ActiveCfg = Release|Win32 - {A8FC5A39-AC22-424A-AC33-9C6CF190CD6C}.Release|Win32.Build.0 = Release|Win32 - {A8FC5A39-AC22-424A-AC33-9C6CF190CD6C}.Release|x64.ActiveCfg = Release|x64 - {A8FC5A39-AC22-424A-AC33-9C6CF190CD6C}.Release|x64.Build.0 = Release|x64 - {757D7956-3DF0-4657-9F1F-FBA28E12FC19}.Debug|Win32.ActiveCfg = Debug|Win32 - {757D7956-3DF0-4657-9F1F-FBA28E12FC19}.Debug|Win32.Build.0 = Debug|Win32 - {757D7956-3DF0-4657-9F1F-FBA28E12FC19}.Debug|x64.ActiveCfg = Debug|x64 - {757D7956-3DF0-4657-9F1F-FBA28E12FC19}.Debug|x64.Build.0 = Debug|x64 - {757D7956-3DF0-4657-9F1F-FBA28E12FC19}.Release|Win32.ActiveCfg = Release|Win32 - {757D7956-3DF0-4657-9F1F-FBA28E12FC19}.Release|Win32.Build.0 = Release|Win32 - {757D7956-3DF0-4657-9F1F-FBA28E12FC19}.Release|x64.ActiveCfg = Release|x64 - {757D7956-3DF0-4657-9F1F-FBA28E12FC19}.Release|x64.Build.0 = Release|x64 - {820700EC-AC15-4F2E-9038-3FB7A0E768F1}.Debug|Win32.ActiveCfg = Debug|Win32 - {820700EC-AC15-4F2E-9038-3FB7A0E768F1}.Debug|Win32.Build.0 = Debug|Win32 - {820700EC-AC15-4F2E-9038-3FB7A0E768F1}.Debug|x64.ActiveCfg = Debug|x64 - {820700EC-AC15-4F2E-9038-3FB7A0E768F1}.Debug|x64.Build.0 = Debug|x64 - {820700EC-AC15-4F2E-9038-3FB7A0E768F1}.Release|Win32.ActiveCfg = Release|Win32 - {820700EC-AC15-4F2E-9038-3FB7A0E768F1}.Release|Win32.Build.0 = Release|Win32 - {820700EC-AC15-4F2E-9038-3FB7A0E768F1}.Release|x64.ActiveCfg = Release|x64 - {820700EC-AC15-4F2E-9038-3FB7A0E768F1}.Release|x64.Build.0 = Release|x64 - {14A4AE0F-0FE2-4DF1-895E-EFE26B9884EA}.Debug|Win32.ActiveCfg = Debug|Win32 - {14A4AE0F-0FE2-4DF1-895E-EFE26B9884EA}.Debug|Win32.Build.0 = Debug|Win32 - {14A4AE0F-0FE2-4DF1-895E-EFE26B9884EA}.Debug|x64.ActiveCfg = Debug|x64 - {14A4AE0F-0FE2-4DF1-895E-EFE26B9884EA}.Debug|x64.Build.0 = Debug|x64 - {14A4AE0F-0FE2-4DF1-895E-EFE26B9884EA}.Release|Win32.ActiveCfg = Release|Win32 - {14A4AE0F-0FE2-4DF1-895E-EFE26B9884EA}.Release|Win32.Build.0 = Release|Win32 - {14A4AE0F-0FE2-4DF1-895E-EFE26B9884EA}.Release|x64.ActiveCfg = Release|x64 - {14A4AE0F-0FE2-4DF1-895E-EFE26B9884EA}.Release|x64.Build.0 = Release|x64 - {FA60EB13-27C0-4C03-99CD-F40E5EA6A3E9}.Debug|Win32.ActiveCfg = Debug|Win32 - {FA60EB13-27C0-4C03-99CD-F40E5EA6A3E9}.Debug|Win32.Build.0 = Debug|Win32 - {FA60EB13-27C0-4C03-99CD-F40E5EA6A3E9}.Debug|x64.ActiveCfg = Debug|x64 - {FA60EB13-27C0-4C03-99CD-F40E5EA6A3E9}.Debug|x64.Build.0 = Debug|x64 - {FA60EB13-27C0-4C03-99CD-F40E5EA6A3E9}.Release|Win32.ActiveCfg = Release|Win32 - {FA60EB13-27C0-4C03-99CD-F40E5EA6A3E9}.Release|Win32.Build.0 = Release|Win32 - {FA60EB13-27C0-4C03-99CD-F40E5EA6A3E9}.Release|x64.ActiveCfg = Release|x64 - {FA60EB13-27C0-4C03-99CD-F40E5EA6A3E9}.Release|x64.Build.0 = Release|x64 - {F8DAE1E5-FBB4-4D01-A7D4-780999124B98}.Debug|Win32.ActiveCfg = Debug|Win32 - {F8DAE1E5-FBB4-4D01-A7D4-780999124B98}.Debug|Win32.Build.0 = Debug|Win32 - {F8DAE1E5-FBB4-4D01-A7D4-780999124B98}.Debug|x64.ActiveCfg = Debug|x64 - {F8DAE1E5-FBB4-4D01-A7D4-780999124B98}.Debug|x64.Build.0 = Debug|x64 - {F8DAE1E5-FBB4-4D01-A7D4-780999124B98}.Release|Win32.ActiveCfg = Release|Win32 - {F8DAE1E5-FBB4-4D01-A7D4-780999124B98}.Release|Win32.Build.0 = Release|Win32 - {F8DAE1E5-FBB4-4D01-A7D4-780999124B98}.Release|x64.ActiveCfg = Release|x64 - {F8DAE1E5-FBB4-4D01-A7D4-780999124B98}.Release|x64.Build.0 = Release|x64 - {DFCE18D6-018A-4CB7-B3DE-5AFE98E3C8A8}.Debug|Win32.ActiveCfg = Debug|Win32 - {DFCE18D6-018A-4CB7-B3DE-5AFE98E3C8A8}.Debug|Win32.Build.0 = Debug|Win32 - {DFCE18D6-018A-4CB7-B3DE-5AFE98E3C8A8}.Debug|x64.ActiveCfg = Debug|x64 - {DFCE18D6-018A-4CB7-B3DE-5AFE98E3C8A8}.Debug|x64.Build.0 = Debug|x64 - {DFCE18D6-018A-4CB7-B3DE-5AFE98E3C8A8}.Release|Win32.ActiveCfg = Release|Win32 - {DFCE18D6-018A-4CB7-B3DE-5AFE98E3C8A8}.Release|Win32.Build.0 = Release|Win32 - {DFCE18D6-018A-4CB7-B3DE-5AFE98E3C8A8}.Release|x64.ActiveCfg = Release|x64 - {DFCE18D6-018A-4CB7-B3DE-5AFE98E3C8A8}.Release|x64.Build.0 = Release|x64 - {4D965596-16B1-4CD7-B088-DD886BD97201}.Debug|Win32.ActiveCfg = Debug|Win32 - {4D965596-16B1-4CD7-B088-DD886BD97201}.Debug|Win32.Build.0 = Debug|Win32 - {4D965596-16B1-4CD7-B088-DD886BD97201}.Debug|x64.ActiveCfg = Debug|x64 - {4D965596-16B1-4CD7-B088-DD886BD97201}.Debug|x64.Build.0 = Debug|x64 - {4D965596-16B1-4CD7-B088-DD886BD97201}.Release|Win32.ActiveCfg = Release|Win32 - {4D965596-16B1-4CD7-B088-DD886BD97201}.Release|Win32.Build.0 = Release|Win32 - {4D965596-16B1-4CD7-B088-DD886BD97201}.Release|x64.ActiveCfg = Release|x64 - {4D965596-16B1-4CD7-B088-DD886BD97201}.Release|x64.Build.0 = Release|x64 - {80B56AC3-FA76-4020-A2EE-90321444D72D}.Debug|Win32.ActiveCfg = Debug|Win32 - {80B56AC3-FA76-4020-A2EE-90321444D72D}.Debug|Win32.Build.0 = Debug|Win32 - {80B56AC3-FA76-4020-A2EE-90321444D72D}.Debug|x64.ActiveCfg = Debug|x64 - {80B56AC3-FA76-4020-A2EE-90321444D72D}.Debug|x64.Build.0 = Debug|x64 - {80B56AC3-FA76-4020-A2EE-90321444D72D}.Release|Win32.ActiveCfg = Release|Win32 - {80B56AC3-FA76-4020-A2EE-90321444D72D}.Release|Win32.Build.0 = Release|Win32 - {80B56AC3-FA76-4020-A2EE-90321444D72D}.Release|x64.ActiveCfg = Release|x64 - {80B56AC3-FA76-4020-A2EE-90321444D72D}.Release|x64.Build.0 = Release|x64 - {F3BB9ADB-FF05-47B0-B2F5-17B81F610577}.Debug|Win32.ActiveCfg = Debug|Win32 - {F3BB9ADB-FF05-47B0-B2F5-17B81F610577}.Debug|Win32.Build.0 = Debug|Win32 - {F3BB9ADB-FF05-47B0-B2F5-17B81F610577}.Debug|x64.ActiveCfg = Debug|x64 - {F3BB9ADB-FF05-47B0-B2F5-17B81F610577}.Debug|x64.Build.0 = Debug|x64 - {F3BB9ADB-FF05-47B0-B2F5-17B81F610577}.Release|Win32.ActiveCfg = Release|Win32 - {F3BB9ADB-FF05-47B0-B2F5-17B81F610577}.Release|Win32.Build.0 = Release|Win32 - {F3BB9ADB-FF05-47B0-B2F5-17B81F610577}.Release|x64.ActiveCfg = Release|x64 - {F3BB9ADB-FF05-47B0-B2F5-17B81F610577}.Release|x64.Build.0 = Release|x64 - {3008810A-36F9-4DAC-B5B9-1D7EA33D39EE}.Debug|Win32.ActiveCfg = Debug|Win32 - {3008810A-36F9-4DAC-B5B9-1D7EA33D39EE}.Debug|Win32.Build.0 = Debug|Win32 - {3008810A-36F9-4DAC-B5B9-1D7EA33D39EE}.Debug|x64.ActiveCfg = Debug|x64 - {3008810A-36F9-4DAC-B5B9-1D7EA33D39EE}.Debug|x64.Build.0 = Debug|x64 - {3008810A-36F9-4DAC-B5B9-1D7EA33D39EE}.Release|Win32.ActiveCfg = Release|Win32 - {3008810A-36F9-4DAC-B5B9-1D7EA33D39EE}.Release|Win32.Build.0 = Release|Win32 - {3008810A-36F9-4DAC-B5B9-1D7EA33D39EE}.Release|x64.ActiveCfg = Release|x64 - {3008810A-36F9-4DAC-B5B9-1D7EA33D39EE}.Release|x64.Build.0 = Release|x64 - {9E5F39EF-C42F-4055-B363-1F2CEDD2B283}.Debug|Win32.ActiveCfg = Debug|Win32 - {9E5F39EF-C42F-4055-B363-1F2CEDD2B283}.Debug|Win32.Build.0 = Debug|Win32 - {9E5F39EF-C42F-4055-B363-1F2CEDD2B283}.Debug|x64.ActiveCfg = Debug|x64 - {9E5F39EF-C42F-4055-B363-1F2CEDD2B283}.Debug|x64.Build.0 = Debug|x64 - {9E5F39EF-C42F-4055-B363-1F2CEDD2B283}.Release|Win32.ActiveCfg = Release|Win32 - {9E5F39EF-C42F-4055-B363-1F2CEDD2B283}.Release|Win32.Build.0 = Release|Win32 - {9E5F39EF-C42F-4055-B363-1F2CEDD2B283}.Release|x64.ActiveCfg = Release|x64 - {9E5F39EF-C42F-4055-B363-1F2CEDD2B283}.Release|x64.Build.0 = Release|x64 - {E4B88FFF-61AC-41B8-AEC4-144E24BB33BD}.Debug|Win32.ActiveCfg = Debug|Win32 - {E4B88FFF-61AC-41B8-AEC4-144E24BB33BD}.Debug|Win32.Build.0 = Debug|Win32 - {E4B88FFF-61AC-41B8-AEC4-144E24BB33BD}.Debug|x64.ActiveCfg = Debug|x64 - {E4B88FFF-61AC-41B8-AEC4-144E24BB33BD}.Debug|x64.Build.0 = Debug|x64 - {E4B88FFF-61AC-41B8-AEC4-144E24BB33BD}.Release|Win32.ActiveCfg = Release|Win32 - {E4B88FFF-61AC-41B8-AEC4-144E24BB33BD}.Release|Win32.Build.0 = Release|Win32 - {E4B88FFF-61AC-41B8-AEC4-144E24BB33BD}.Release|x64.ActiveCfg = Release|x64 - {E4B88FFF-61AC-41B8-AEC4-144E24BB33BD}.Release|x64.Build.0 = Release|x64 - {3B7D642F-6073-414D-B614-B91DE1F7121A}.Debug|Win32.ActiveCfg = Debug|Win32 - {3B7D642F-6073-414D-B614-B91DE1F7121A}.Debug|Win32.Build.0 = Debug|Win32 - {3B7D642F-6073-414D-B614-B91DE1F7121A}.Debug|x64.ActiveCfg = Debug|x64 - {3B7D642F-6073-414D-B614-B91DE1F7121A}.Debug|x64.Build.0 = Debug|x64 - {3B7D642F-6073-414D-B614-B91DE1F7121A}.Release|Win32.ActiveCfg = Release|Win32 - {3B7D642F-6073-414D-B614-B91DE1F7121A}.Release|Win32.Build.0 = Release|Win32 - {3B7D642F-6073-414D-B614-B91DE1F7121A}.Release|x64.ActiveCfg = Release|x64 - {3B7D642F-6073-414D-B614-B91DE1F7121A}.Release|x64.Build.0 = Release|x64 - {EAF3D9E2-8831-4EDD-88D3-587F0380933D}.Debug|Win32.ActiveCfg = Debug|Win32 - {EAF3D9E2-8831-4EDD-88D3-587F0380933D}.Debug|Win32.Build.0 = Debug|Win32 - {EAF3D9E2-8831-4EDD-88D3-587F0380933D}.Debug|x64.ActiveCfg = Debug|x64 - {EAF3D9E2-8831-4EDD-88D3-587F0380933D}.Debug|x64.Build.0 = Debug|x64 - {EAF3D9E2-8831-4EDD-88D3-587F0380933D}.Release|Win32.ActiveCfg = Release|Win32 - {EAF3D9E2-8831-4EDD-88D3-587F0380933D}.Release|Win32.Build.0 = Release|Win32 - {EAF3D9E2-8831-4EDD-88D3-587F0380933D}.Release|x64.ActiveCfg = Release|x64 - {EAF3D9E2-8831-4EDD-88D3-587F0380933D}.Release|x64.Build.0 = Release|x64 - {1D29C4C9-4701-44D3-AC89-1A415832DF93}.Debug|Win32.ActiveCfg = Debug|Win32 - {1D29C4C9-4701-44D3-AC89-1A415832DF93}.Debug|Win32.Build.0 = Debug|Win32 - {1D29C4C9-4701-44D3-AC89-1A415832DF93}.Debug|x64.ActiveCfg = Debug|x64 - {1D29C4C9-4701-44D3-AC89-1A415832DF93}.Debug|x64.Build.0 = Debug|x64 - {1D29C4C9-4701-44D3-AC89-1A415832DF93}.Release|Win32.ActiveCfg = Release|Win32 - {1D29C4C9-4701-44D3-AC89-1A415832DF93}.Release|Win32.Build.0 = Release|Win32 - {1D29C4C9-4701-44D3-AC89-1A415832DF93}.Release|x64.ActiveCfg = Release|x64 - {1D29C4C9-4701-44D3-AC89-1A415832DF93}.Release|x64.Build.0 = Release|x64 - {48B0C39F-29D7-4595-B458-20E36B400C2E}.Debug|Win32.ActiveCfg = Debug|Win32 - {48B0C39F-29D7-4595-B458-20E36B400C2E}.Debug|Win32.Build.0 = Debug|Win32 - {48B0C39F-29D7-4595-B458-20E36B400C2E}.Debug|x64.ActiveCfg = Debug|x64 - {48B0C39F-29D7-4595-B458-20E36B400C2E}.Debug|x64.Build.0 = Debug|x64 - {48B0C39F-29D7-4595-B458-20E36B400C2E}.Release|Win32.ActiveCfg = Release|Win32 - {48B0C39F-29D7-4595-B458-20E36B400C2E}.Release|Win32.Build.0 = Release|Win32 - {48B0C39F-29D7-4595-B458-20E36B400C2E}.Release|x64.ActiveCfg = Release|x64 - {48B0C39F-29D7-4595-B458-20E36B400C2E}.Release|x64.Build.0 = Release|x64 - {314BB4FB-91EE-49B8-A18A-8D996E5B75D2}.Debug|Win32.ActiveCfg = Debug|Win32 - {314BB4FB-91EE-49B8-A18A-8D996E5B75D2}.Debug|Win32.Build.0 = Debug|Win32 - {314BB4FB-91EE-49B8-A18A-8D996E5B75D2}.Debug|x64.ActiveCfg = Debug|x64 - {314BB4FB-91EE-49B8-A18A-8D996E5B75D2}.Debug|x64.Build.0 = Debug|x64 - {314BB4FB-91EE-49B8-A18A-8D996E5B75D2}.Release|Win32.ActiveCfg = Release|Win32 - {314BB4FB-91EE-49B8-A18A-8D996E5B75D2}.Release|Win32.Build.0 = Release|Win32 - {314BB4FB-91EE-49B8-A18A-8D996E5B75D2}.Release|x64.ActiveCfg = Release|x64 - {314BB4FB-91EE-49B8-A18A-8D996E5B75D2}.Release|x64.Build.0 = Release|x64 - {23A89145-EE66-47A2-9BAF-2536CD858442}.Debug|Win32.ActiveCfg = Debug|Win32 - {23A89145-EE66-47A2-9BAF-2536CD858442}.Debug|Win32.Build.0 = Debug|Win32 - {23A89145-EE66-47A2-9BAF-2536CD858442}.Debug|x64.ActiveCfg = Debug|x64 - {23A89145-EE66-47A2-9BAF-2536CD858442}.Debug|x64.Build.0 = Debug|x64 - {23A89145-EE66-47A2-9BAF-2536CD858442}.Release|Win32.ActiveCfg = Release|Win32 - {23A89145-EE66-47A2-9BAF-2536CD858442}.Release|Win32.Build.0 = Release|Win32 - {23A89145-EE66-47A2-9BAF-2536CD858442}.Release|x64.ActiveCfg = Release|x64 - {23A89145-EE66-47A2-9BAF-2536CD858442}.Release|x64.Build.0 = Release|x64 - {A7B05FFC-9850-420B-B70F-1C96EF998CEB}.Debug|Win32.ActiveCfg = Debug|Win32 - {A7B05FFC-9850-420B-B70F-1C96EF998CEB}.Debug|Win32.Build.0 = Debug|Win32 - {A7B05FFC-9850-420B-B70F-1C96EF998CEB}.Debug|x64.ActiveCfg = Debug|x64 - {A7B05FFC-9850-420B-B70F-1C96EF998CEB}.Debug|x64.Build.0 = Debug|x64 - {A7B05FFC-9850-420B-B70F-1C96EF998CEB}.Release|Win32.ActiveCfg = Release|Win32 - {A7B05FFC-9850-420B-B70F-1C96EF998CEB}.Release|Win32.Build.0 = Release|Win32 - {A7B05FFC-9850-420B-B70F-1C96EF998CEB}.Release|x64.ActiveCfg = Release|x64 - {A7B05FFC-9850-420B-B70F-1C96EF998CEB}.Release|x64.Build.0 = Release|x64 - {B48E9BE6-B724-4061-8A70-6C2943F752AB}.Debug|Win32.ActiveCfg = Debug|Win32 - {B48E9BE6-B724-4061-8A70-6C2943F752AB}.Debug|Win32.Build.0 = Debug|Win32 - {B48E9BE6-B724-4061-8A70-6C2943F752AB}.Debug|x64.ActiveCfg = Debug|x64 - {B48E9BE6-B724-4061-8A70-6C2943F752AB}.Debug|x64.Build.0 = Debug|x64 - {B48E9BE6-B724-4061-8A70-6C2943F752AB}.Release|Win32.ActiveCfg = Release|Win32 - {B48E9BE6-B724-4061-8A70-6C2943F752AB}.Release|Win32.Build.0 = Release|Win32 - {B48E9BE6-B724-4061-8A70-6C2943F752AB}.Release|x64.ActiveCfg = Release|x64 - {B48E9BE6-B724-4061-8A70-6C2943F752AB}.Release|x64.Build.0 = Release|x64 - {93510DBC-51ED-450E-A45E-ECDF1E853D18}.Debug|Win32.ActiveCfg = Debug|Win32 - {93510DBC-51ED-450E-A45E-ECDF1E853D18}.Debug|Win32.Build.0 = Debug|Win32 - {93510DBC-51ED-450E-A45E-ECDF1E853D18}.Debug|x64.ActiveCfg = Debug|x64 - {93510DBC-51ED-450E-A45E-ECDF1E853D18}.Debug|x64.Build.0 = Debug|x64 - {93510DBC-51ED-450E-A45E-ECDF1E853D18}.Release|Win32.ActiveCfg = Release|Win32 - {93510DBC-51ED-450E-A45E-ECDF1E853D18}.Release|Win32.Build.0 = Release|Win32 - {93510DBC-51ED-450E-A45E-ECDF1E853D18}.Release|x64.ActiveCfg = Release|x64 - {93510DBC-51ED-450E-A45E-ECDF1E853D18}.Release|x64.Build.0 = Release|x64 - {99CD8B64-8362-4089-A610-D878CD422581}.Debug|Win32.ActiveCfg = Debug|Win32 - {99CD8B64-8362-4089-A610-D878CD422581}.Debug|Win32.Build.0 = Debug|Win32 - {99CD8B64-8362-4089-A610-D878CD422581}.Debug|x64.ActiveCfg = Debug|x64 - {99CD8B64-8362-4089-A610-D878CD422581}.Debug|x64.Build.0 = Debug|x64 - {99CD8B64-8362-4089-A610-D878CD422581}.Release|Win32.ActiveCfg = Release|Win32 - {99CD8B64-8362-4089-A610-D878CD422581}.Release|Win32.Build.0 = Release|Win32 - {99CD8B64-8362-4089-A610-D878CD422581}.Release|x64.ActiveCfg = Release|x64 - {99CD8B64-8362-4089-A610-D878CD422581}.Release|x64.Build.0 = Release|x64 - {A51E0247-F7EF-4C7E-96B7-F50752C73D81}.Debug|Win32.ActiveCfg = Debug|Win32 - {A51E0247-F7EF-4C7E-96B7-F50752C73D81}.Debug|Win32.Build.0 = Debug|Win32 - {A51E0247-F7EF-4C7E-96B7-F50752C73D81}.Debug|x64.ActiveCfg = Debug|x64 - {A51E0247-F7EF-4C7E-96B7-F50752C73D81}.Debug|x64.Build.0 = Debug|x64 - {A51E0247-F7EF-4C7E-96B7-F50752C73D81}.Release|Win32.ActiveCfg = Release|Win32 - {A51E0247-F7EF-4C7E-96B7-F50752C73D81}.Release|Win32.Build.0 = Release|Win32 - {A51E0247-F7EF-4C7E-96B7-F50752C73D81}.Release|x64.ActiveCfg = Release|x64 - {A51E0247-F7EF-4C7E-96B7-F50752C73D81}.Release|x64.Build.0 = Release|x64 - {7DCC48B1-285D-4653-99AD-B707BEBBCB1C}.Debug|Win32.ActiveCfg = Debug|Win32 - {7DCC48B1-285D-4653-99AD-B707BEBBCB1C}.Debug|Win32.Build.0 = Debug|Win32 - {7DCC48B1-285D-4653-99AD-B707BEBBCB1C}.Debug|x64.ActiveCfg = Debug|x64 - {7DCC48B1-285D-4653-99AD-B707BEBBCB1C}.Debug|x64.Build.0 = Debug|x64 - {7DCC48B1-285D-4653-99AD-B707BEBBCB1C}.Release|Win32.ActiveCfg = Release|Win32 - {7DCC48B1-285D-4653-99AD-B707BEBBCB1C}.Release|Win32.Build.0 = Release|Win32 - {7DCC48B1-285D-4653-99AD-B707BEBBCB1C}.Release|x64.ActiveCfg = Release|x64 - {7DCC48B1-285D-4653-99AD-B707BEBBCB1C}.Release|x64.Build.0 = Release|x64 - {2E9645DE-DE90-4CCB-9AF6-073032EF73CC}.Debug|Win32.ActiveCfg = Debug|Win32 - {2E9645DE-DE90-4CCB-9AF6-073032EF73CC}.Debug|Win32.Build.0 = Debug|Win32 - {2E9645DE-DE90-4CCB-9AF6-073032EF73CC}.Debug|x64.ActiveCfg = Debug|x64 - {2E9645DE-DE90-4CCB-9AF6-073032EF73CC}.Debug|x64.Build.0 = Debug|x64 - {2E9645DE-DE90-4CCB-9AF6-073032EF73CC}.Release|Win32.ActiveCfg = Release|Win32 - {2E9645DE-DE90-4CCB-9AF6-073032EF73CC}.Release|Win32.Build.0 = Release|Win32 - {2E9645DE-DE90-4CCB-9AF6-073032EF73CC}.Release|x64.ActiveCfg = Release|x64 - {2E9645DE-DE90-4CCB-9AF6-073032EF73CC}.Release|x64.Build.0 = Release|x64 - {9E815E2B-9D2E-4814-9FEE-F8919CEB3787}.Debug|Win32.ActiveCfg = Debug|Win32 - {9E815E2B-9D2E-4814-9FEE-F8919CEB3787}.Debug|Win32.Build.0 = Debug|Win32 - {9E815E2B-9D2E-4814-9FEE-F8919CEB3787}.Debug|x64.ActiveCfg = Debug|x64 - {9E815E2B-9D2E-4814-9FEE-F8919CEB3787}.Debug|x64.Build.0 = Debug|x64 - {9E815E2B-9D2E-4814-9FEE-F8919CEB3787}.Release|Win32.ActiveCfg = Release|Win32 - {9E815E2B-9D2E-4814-9FEE-F8919CEB3787}.Release|Win32.Build.0 = Release|Win32 - {9E815E2B-9D2E-4814-9FEE-F8919CEB3787}.Release|x64.ActiveCfg = Release|x64 - {9E815E2B-9D2E-4814-9FEE-F8919CEB3787}.Release|x64.Build.0 = Release|x64 - {2DD18C42-8F5F-4741-9B3E-65B48D8C61AA}.Debug|Win32.ActiveCfg = Debug|Win32 - {2DD18C42-8F5F-4741-9B3E-65B48D8C61AA}.Debug|Win32.Build.0 = Debug|Win32 - {2DD18C42-8F5F-4741-9B3E-65B48D8C61AA}.Debug|x64.ActiveCfg = Debug|x64 - {2DD18C42-8F5F-4741-9B3E-65B48D8C61AA}.Debug|x64.Build.0 = Debug|x64 - {2DD18C42-8F5F-4741-9B3E-65B48D8C61AA}.Release|Win32.ActiveCfg = Release|Win32 - {2DD18C42-8F5F-4741-9B3E-65B48D8C61AA}.Release|Win32.Build.0 = Release|Win32 - {2DD18C42-8F5F-4741-9B3E-65B48D8C61AA}.Release|x64.ActiveCfg = Release|x64 - {2DD18C42-8F5F-4741-9B3E-65B48D8C61AA}.Release|x64.Build.0 = Release|x64 - {70DC7A8A-3F4A-43CF-9DE2-A9C477121319}.Debug|Win32.ActiveCfg = Debug|Win32 - {70DC7A8A-3F4A-43CF-9DE2-A9C477121319}.Debug|Win32.Build.0 = Debug|Win32 - {70DC7A8A-3F4A-43CF-9DE2-A9C477121319}.Debug|x64.ActiveCfg = Debug|x64 - {70DC7A8A-3F4A-43CF-9DE2-A9C477121319}.Debug|x64.Build.0 = Debug|x64 - {70DC7A8A-3F4A-43CF-9DE2-A9C477121319}.Release|Win32.ActiveCfg = Release|Win32 - {70DC7A8A-3F4A-43CF-9DE2-A9C477121319}.Release|Win32.Build.0 = Release|Win32 - {70DC7A8A-3F4A-43CF-9DE2-A9C477121319}.Release|x64.ActiveCfg = Release|x64 - {70DC7A8A-3F4A-43CF-9DE2-A9C477121319}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/CPlusPlus/Sample_Source/All/build_run_all.bat b/CPlusPlus/Sample_Source/All/build_run_all.bat deleted file mode 100644 index 4d14dc3d..00000000 --- a/CPlusPlus/Sample_Source/All/build_run_all.bat +++ /dev/null @@ -1,393 +0,0 @@ -@ECHO OFF -REM *** -REM *** Copyright (c) 2015, Datalogics, Inc. All rights reserved. -REM *** - -REM ********************************************************************************************************************** -REM *** Sample: All - Builds and runs each APDFL sample, and outputs the results. -REM *** -REM *** By default, this occurs with the debug configuration. -REM *** Pass in "release" as an argument to use the release configuration. -REM *** It is important to note that this program assumes: -REM *** 1. A sample was built successfully <-> Its exe is located in ///.exe -REM *** 2. Above, is equal to . -REM *** -REM *** MAINTENANCE: -REM *** Step 3 is where you want to be if you want to add or remove samples from this script. -REM *** Add or remove items from DL_SAMPLE_LIST, making sure to update NUM_SAMPLES, -REM *** NUM_DL_SAMPLES accordingly. Bear in mind that each item in the list must -REM *** be, simultaneously, the name of the sample's folder in ../, the name of the sample's .sln, -REM *** and the name of the executable it builds... -REM *** If necessary, you can also specify arguments for samples. Follow the examples therein. -REM *** -REM *** USAGE: -REM *** All arguments are case-insensitive. -REM *** -REM *** ARGUMENT EFFECT -REM *** -noRun Don't run the samples, just build them. -REM *** -release Build Release configuration instead of Debug configuration. -REM *** -REM *** Steps: -REM *** 1) Initialize. -REM *** 2) Build each sample. -REM *** 3) Decide which samples to run. -REM *** 4) Run the samples. -REM *** 4) Output the results. -REM ********************************************************************************************************************** - -REM *** This agreement is between Datalogics, Inc. 101 N. Wacker Drive, Suite 1800, -REM *** Chicago, IL 60606 ("Datalogics") and you, an end user who downloads -REM *** source code examples for integrating to the Adobe PDF Library -REM *** ("the Example Code"). By accepting this agreement you agree to be bound -REM *** by the following terms of use for the Example Code. -REM *** -REM *** LICENSE -REM *** ------- -REM *** Datalogics hereby grants you a royalty-free, non-exclusive license to -REM *** download and use the Example Code for any lawful purpose. There is no charge -REM *** for use of Example Code. -REM *** -REM *** OWNERSHIP -REM *** --------- -REM *** The Example Code and any related documentation and trademarks are and shall -REM *** remain the sole and exclusive property of Datalogics and are protected by -REM *** the laws of copyright in the U.S. and other countries. -REM *** -REM *** Datalogics is a trademark of Datalogics, Inc. -REM *** -REM *** TERM -REM *** ---- -REM *** This license is effective until terminated. You may terminate it at any -REM *** other time by destroying the Example Code. -REM *** -REM *** WARRANTY DISCLAIMER -REM *** ------------------- -REM *** THE EXAMPLE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER -REM *** EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES -REM *** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -REM *** -REM *** DATALOGICS DISCLAIM ALL OTHER WARRANTIES, CONDITIONS, UNDERTAKINGS OR -REM *** TERMS OF ANY KIND, EXPRESS OR IMPLIED, WRITTEN OR ORAL, BY OPERATION OF -REM *** LAW, ARISING BY STATUTE, COURSE OF DEALING, USAGE OF TRADE OR OTHERWISE, -REM *** INCLUDING, WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR A -REM *** PARTICULAR PURPOSE, SATISFACTORY QUALITY, LACK OF VIRUSES, TITLE, -REM *** NON-INFRINGEMENT, ACCURACY OR COMPLETENESS OF RESPONSES, RESULTS, AND/OR -REM *** LACK OF WORKMANLIKE EFFORT. THE PROVISIONS OF THIS SECTION SET FORTH -REM *** SUBLICENSEE'S SOLEREMEDY AND DATALOGICS'S SOLE LIABILITY WITH RESPECT -REM *** TO THE WARRANTY SET FORTH HEREIN. NO REPRESENTATION OR OTHER AFFIRMATION -REM *** OF FACT, INCLUDING STATEMENTS REGARDING PERFORMANCE OF THE EXAMPLE CODE, -REM *** WHICH IS NOT CONTAINED IN THIS AGREEMENT, SHALL BE BINDING ON DATALOGICS. -REM *** NEITHER DATALOGICS WARRANT AGAINST ANY BUG, ERROR, OMISSION, DEFECT, -REM *** DEFICIENCY, OR NONCONFORMITY IN ANY EXAMPLE CODE. -REM *** - -REM ************************************************* -REM *** 1) Initialize. -REM ************************************************* - -REM *** Initialize environment variables, enable delayed expansion. -SETLOCAL EnableDelayedExpansion -REM *** Filename of All project. -IF EXIST "All_Datalogics_32Bit.sln" ( - REM Do a 32-bit build - SET ALL_DL_SLN=All_Datalogics_32Bit.sln - SET ARCH=Win32 -) ELSE ( - REM Do a 64-bit build - SET ALL_DL_SLN=All_Datalogics_64Bit.sln - SET ARCH=x64 -) - -REM ************* Initialize variables which track our progress ****************** -REM *** The number of samples that failed to build. -SET /A "NUM_FAIL_BUILD=0" -REM *** A list of the failed builds. -SET DESC_FAIL_BUILD= -REM *** The number of samples that successfully ran. -SET /A "NUM_SUCCEED_RUN=0" -REM *** The return code with failure information -SET /A "RETURN_CODE=0" -REM *** A list of the successful runs. -SET DESC_SUCCEED_RUN= -REM *** The number of samples that failed to run. -SET /A "NUM_FAIL_RUN=0" -REM *** A list of the failed runs. -SET DESC_FAIL_RUN= - -REM *** Assume default settings. - -REM *** The configuration to use. -SET STAGE=Debug -REM *** Only build the samples, don't run them. -SET ONLY_BUILD=N - -:AcceptCommands -REM *** Iterate through arguments, changing settings when needed. -IF /i "%1"=="" ( - GOTO ArgumentsEnd -) -IF /i "%1"=="-release" ( - SET STAGE=Release -) -IF /i "%1"=="-noRun" ( - SET ONLY_BUILD=Y -) -SHIFT -GOTO AcceptCommands - -:ArgumentsEnd - -REM *** Set up the visual studio environment. -IF "%VS120COMNTOOLS%" == "" GOTO Usage -CALL "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat" x86 -IF "%VSINSTALLDIR%" == "" GOTO Usage - -REM ************************************************* -REM *** 2) Build each sample. -REM ************************************************* - -ECHO #Building Datalogics samples... -devenv %ALL_DL_SLN% /rebuild "%STAGE%|%ARCH%" -ECHO. - -REM ************************************************* -REM *** 3) Decide which samples to run. -REM ************************************************* - -REM *** The total number of samples. This must be accurate! -SET /A "NUM_SAMPLES=55" - -REM *** Datalogics Samples. -SET "DL_SAMPLE_LIST=(" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% Annotations\CreateAnnotations" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% Annotations\FlattenAnnotations" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% Printing\PostScriptInjection" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% DocumentOptimization\PDFOptimizer" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% DocumentOptimization\WebOptimizedPDF" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% ContentModification\AddBookmarks" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% ContentModification\AddDocumentInformation" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% ContentModification\AddLinks" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% ContentModification\AddPageNumbers" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% ContentModification\AttachMimeToPDF" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% ContentModification\FlattenTransparency" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% ContentModification\MergeAcroforms" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% ContentModification\MergeDocuments" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% ContentModification\PDFMakeOCGVisible" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% ContentModification\PDFUncompress" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% ContentModification\SplitPDF" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% ContentModification\ImportPages" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% ContentModification\AddWatermark" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% ContentModification\EmbedFonts" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% DocumentConversion\ConvertPDFtoEPS" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% DocumentConversion\ConvertToPDFA" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% DocumentConversion\ConvertToPDFX" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% DocumentConversion\ConvertPDFtoPostscript" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% DocumentConversion\XPStoPDF" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% Images\AddThumbnailsToPDF" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% Images\RenderPage" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% Images\CreateImageWithTransparency" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% Images\CreateSeparations" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% Images\CalcImageDPI" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% Images\FindImageResolutions" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% Images\OutputPreview" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% Text\InsertHeadFoot" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% Text\ExtractText" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% Text\AddText" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% Text\UnicodeText" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% Text\HelloJapan" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% Text\TextSearch" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% Text\TextSelectEnum" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% ContentCreation\AddArt" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% ContentCreation\AddAttachments" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% ContentCreation\AddContent" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% ContentCreation\CreateBookmarks" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% ContentCreation\CreateDocument" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% ContentCreation\CreateLayers" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% ContentCreation\CreateTransparency" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% Security\AESEncryption" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% Security\AddPassword" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% Security\AddRedaction" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% Security\AddTriangularRedaction" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% Security\EncryptDocument" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% Security\LockDocument" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% Security\SetUniquePermissions" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% Security\OpenEncrypted" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% Security\ValidateSignatures" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% ContentExtraction\CopyContent" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% ContentExtraction\ExtractAttachments" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% ContentExtraction\ExtractFonts" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% InformationExtraction\CountColorsInDoc" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% InformationExtraction\ExtractDocumentInfo" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST% FileSystem\AlternateFileSystem" -SET "DL_SAMPLE_LIST=%DL_SAMPLE_LIST%)" -REM *** The total number of DL samples. This must be accurate! -SET /A "NUM_DL_SAMPLES=55" - -REM *** Di iterates over Datalogics samples. Do not change this value. -SET /A "Di=0" - -REM *** Some samples require arguments. The variable name before "_args" -REM *** is the name of the sample. - -REM ************************************************* -REM *** 4) Run the samples. -REM ************************************************* - -REM ** Prepare to go through all the samples. -CD .. -REM *** The directory in which the sample folders are located. -SET SAMPLEDIR=%CD% -REM *** Necessary for running. -SET PATH=..\..\..\Binaries;%PATH% -SET CURRENT_SAMPLE= - -REM ************************************************************ -REM ******************** MAIN LOOP ***************************** -REM ************************************************************ -:RunSampleLoop_START -REM *** If we've run all the samples, end. -REM *** PL samples are always done last.) -IF %Di% GEQ %NUM_DL_SAMPLES% GOTO RunSampleLoop_END -ECHO. - -REM *** Retrieve the next sample. -GOTO GetNextSample -:GotNextSample - -CD %SAMPLEDIR%\%CURRENT_SAMPLE%\%ARCH%\%STAGE% - -REM Isolate the actual name fromt the group name -for %%F in ("%CURRENT_SAMPLE%") do ( set "EXE_NAME=%%~nxF") - -REM *** If the directory could not be found. -IF %ERRORLEVEL% NEQ 0 (GOTO CantFindExe) -REM *** If the exe file could not be found. -IF NOT EXIST %EXE_NAME%.exe (GOTO CantFindExe) - -If %ONLY_BUILD% == Y GOTO RunSampleLoop_Call_End - -:RunSampleLoop_Call - ECHO #Run %CURRENT_SAMPLE%. - REM *** If the exe file could not be found. - IF NOT EXIST %EXE_NAME%.exe (GOTO CantFindExe) - - REM *** Call the sample with its arguments, if any. - REM *** (undefined variables expand to nothing.) - CD ../../ - %ARCH%\%STAGE%\!EXE_NAME!.exe %!EXE_NAME!_args% - - REM *** If it failed to run. - IF %ERRORLEVEL% NEQ 0 (GOTO FailedRun) - REM *** Otherwise, it succeeded! - GOTO SuccessfulRun -:RunSampleLoop_Call_End - -:RunSampleLoop_NEXT_ITER -GOTO RunSampleLoop_START - -REM ************************************************************ -REM ************************************************************ -REM ************************************************************ - -REM ******************************** -REM ******* SUBROUTINES ************ -REM ******************************** -:GetNextSample -SET /A "n=0" - -IF %Di% LSS %NUM_DL_SAMPLES% GOTO NextDLSample - -:NextDLSample -FOR %%S IN %DL_SAMPLE_LIST% DO ( - IF !n! EQU !Di! SET CURRENT_SAMPLE=%%S - SET /A "n+=1" -) -SET /A "Di+=1" -GOTO GotNextSample - -REM ******************************** -:SuccessfulRun - -SET /A "NUM_SUCCEED_RUN+=1" -ECHO #Ran successfully. -SET "DESC_SUCCEED_RUN=!DESC_SUCCEED_RUN!^*!CURRENT_SAMPLE! ^& ECHO." - -GOTO RunSampleLoop_NEXT_ITER -REM ******************************** -:FailedRun - -SET /A "NUM_FAIL_RUN+=1" -ECHO #Failed ^(%ERRORLEVEL%^) -SET "DESC_FAIL_RUN=!DESC_FAIL_RUN!^*!CURRENT_SAMPLE! !ERRORLEVEL! ^& ECHO." - -GOTO RunSampleLoop_NEXT_ITER -REM ******************************** -:CantFindExe - -ECHO #%CURRENT_SAMPLE% failed to build. -SET /A "NUM_FAIL_BUILD+=1" -SET "DESC_FAIL_BUILD=!DESC_FAIL_BUILD!^*!CURRENT_SAMPLE! ^& ECHO." - -GOTO RunSampleLoop_NEXT_ITER -REM ******************************** -REM ******************************** -REM ******************************** -:RunSampleLoop_END - - - -REM ************************************************* -REM *** 5) Print the results. -REM ************************************************* - - -SET /A "NUM_SAMPLES=0" -SET /A "NUM_SAMPLES+=%NUM_DL_SAMPLES%" - -ECHO ===================================== -IF %ONLY_BUILD% == N ( -ECHO =========Build/Run complete. -) ELSE ( -ECHO =========Build complete. -) -ECHO =========Total samples^: %NUM_SAMPLES% -ECHO ===================================== - -IF %NUM_SUCCEED_RUN% EQU %NUM_SAMPLES% ( - ECHO All samples built and ran successfuly. - ECHO %DESC_SUCCEED_RUN% -) ELSE ( - IF %NUM_FAIL_BUILD% GTR 0 ( - ECHO Failed builds^: %NUM_FAIL_BUILD% - ECHO %DESC_FAIL_BUILD% - ) ELSE ( - ECHO All samples built successfuly. - ) - IF %NUM_FAIL_RUN% GTR 0 ( - ECHO Failed runs^: %NUM_FAIL_RUN% - ECHO %DESC_FAIL_RUN% - ) - IF %NUM_SUCCEED_RUN% GTR 0 ( - ECHO Successful runs^: %NUM_SUCCEED_RUN% - ECHO %DESC_SUCCEED_RUN% - ) -) -ECHO ===================================== -ECHO ===================================== -GOTO End - -:Usage -ECHO You must have Visual Studio 2013 installed to use this executable. -GOTO End - -:MustIncludeFiles -ECHO You must choose to run the DL or the Adobe samples^! -GOTO End - -:End - -REM Return NUM_FAIL_BUILDx100 + NUM_FAIL_RUN -REM e.g. 203 means 2 failed build and 3 failed run -SET /A "RETURN_CODE=NUM_FAIL_BUILD*100+NUM_FAIL_RUN" -ECHO RETURN_CODE %RETURN_CODE% -EXIT /b %RETURN_CODE% diff --git a/CPlusPlus/Sample_Source/Annotations/CreateAnnotations/CreateAnnotations.cpp b/CPlusPlus/Sample_Source/Annotations/CreateAnnotations/CreateAnnotations.cpp index 6b835033..9df41dc3 100644 --- a/CPlusPlus/Sample_Source/Annotations/CreateAnnotations/CreateAnnotations.cpp +++ b/CPlusPlus/Sample_Source/Annotations/CreateAnnotations/CreateAnnotations.cpp @@ -9,10 +9,9 @@ // // Command-line: (All are optional) // -// For more detail see the description of the CreateAnnotations sample program on our Developer’s site, +// For more detail see the description of the CreateAnnotations sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#createannotations - #include #include #include @@ -35,86 +34,81 @@ #define DEF_OUTPUT_ANNOT "CreateAnnotations-out.pdf" #define DEF_OUTPUT_TEXT "CreateAnnotations-out-text.txt" -static void extractPDEElements ( PDEContent c, std::vector& list ); -static void SetAnnotationQuads ( PDAnnot annot, ASFixedQuad *quads, ASArraySize numQuads ); -static PDColorValue SelectColor ( bool textAnnotation ); +static void extractPDEElements(PDEContent c, std::vector &list); +static void SetAnnotationQuads(PDAnnot annot, ASFixedQuad *quads, ASArraySize numQuads); +static PDColorValue SelectColor(bool textAnnotation); -int main(int argc, char** argv) -{ +int main(int argc, char **argv) { APDFLib libInit; ASErrorCode errCode = 0; - if (libInit.isValid() == false) - { + if (libInit.isValid() == false) { errCode = libInit.getInitError(); std::cout << "Initialization failed with code " << errCode << std::endl; return libInit.getInitError(); } - - std::string csInputFileName ( argc > 1 ? argv[1] : DIR_LOC DEF_INPUT ); - std::string csOutputFileName ( argc > 2 ? argv[2] : DEF_OUTPUT_ANNOT ); - std::string csOutputTextFileName ( argc > 3 ? argv[3] : DEF_OUTPUT_TEXT ); + + std::string csInputFileName(argc > 1 ? argv[1] : DIR_LOC DEF_INPUT); + std::string csOutputFileName(argc > 2 ? argv[2] : DEF_OUTPUT_ANNOT); + std::string csOutputTextFileName(argc > 3 ? argv[3] : DEF_OUTPUT_TEXT); std::cout << "Opening " << csInputFileName.c_str() << " and adding annotations to " - << "all elements on the first page;" << std::endl << "Will save to " << csOutputFileName.c_str() - << ", then we will reopen that file and extract all annotations to " + << "all elements on the first page;" << std::endl + << "Will save to " << csOutputFileName.c_str() + << ", then we will reopen that file and extract all annotations to " << csOutputTextFileName.c_str() << std::endl; - std::ofstream ofText ( csOutputTextFileName.c_str() ); + std::ofstream ofText(csOutputTextFileName.c_str()); ofText << "Results from file " << csOutputFileName.c_str() << ":" << std::endl; -DURING + DURING - APDFLDoc doc( csInputFileName.c_str(), true); //Open the input document, repairing it if necessary. + APDFLDoc doc(csInputFileName.c_str(), true); // Open the input document, repairing it if necessary. - PDPage inPage = doc.getPage(0); - PDEContent inPageContent = PDPageAcquirePDEContent(inPage, 0); + PDPage inPage = doc.getPage(0); + PDEContent inPageContent = PDPageAcquirePDEContent(inPage, 0); -// Step 0) Retrieve all the PDEElements on the page. + // Step 0) Retrieve all the PDEElements on the page. - std::vector pageElements; - extractPDEElements ( inPageContent, pageElements ); + std::vector pageElements; + extractPDEElements(inPageContent, pageElements); -// Step 1) Annotate them all + // Step 1) Annotate them all - // An annotation with descriptive content will be placed in the same location as each PDEElement. - // For text elements, we will create a red, blue, or green highlight annotation. - // For other elements, we will create a yellow text annotation. + // An annotation with descriptive content will be placed in the same location as each + // PDEElement. For text elements, we will create a red, blue, or green highlight annotation. + // For other elements, we will create a yellow text annotation. - ASAtom atHighlight ( ASAtomFromString ( "Highlight" ) ); - ASAtom atText ( ASAtomFromString ( "Text" ) ); + ASAtom atHighlight(ASAtomFromString("Highlight")); + ASAtom atText(ASAtomFromString("Text")); - std::vector::iterator itElem, itElemEnd = pageElements.end(); - for ( itElem = pageElements.begin(); itElem != itElemEnd; ++itElem ) - { - // Retrieve the element's location. We will place the annotation where the - // original page element was found. - ASFixedRect elementLoc; - PDEElementGetBBox( *itElem, &elementLoc); - - // Fetch the annotation's type - ASInt32 elementType = PDEObjectGetType ( (PDEObject)*itElem ); - ASAtom annotationType = ( elementType == kPDEText ) ? atText : atHighlight; - - // Create the new annotation. Set the appearance and content. - PDAnnot annot = PDPageAddNewAnnot ( inPage, kPDEAfterLast, annotationType, &elementLoc ); - - std::wstringstream annotContent; - annotContent << L"This is a "; - switch ( elementType ) - { + std::vector::iterator itElem, itElemEnd = pageElements.end(); + for (itElem = pageElements.begin(); itElem != itElemEnd; ++itElem) { + // Retrieve the element's location. We will place the annotation where the + // original page element was found. + ASFixedRect elementLoc; + PDEElementGetBBox(*itElem, &elementLoc); + + // Fetch the annotation's type + ASInt32 elementType = PDEObjectGetType((PDEObject)*itElem); + ASAtom annotationType = (elementType == kPDEText) ? atText : atHighlight; + + // Create the new annotation. Set the appearance and content. + PDAnnot annot = PDPageAddNewAnnot(inPage, kPDEAfterLast, annotationType, &elementLoc); + + std::wstringstream annotContent; + annotContent << L"This is a "; + switch (elementType) { case kPDEContainer: - annotContent << L"container containing " << - PDEContentGetNumElems ( PDEContainerGetContent ( (PDEContainer)*itElem ) ) - << L" elements"; + annotContent << L"container containing " + << PDEContentGetNumElems(PDEContainerGetContent((PDEContainer)*itElem)) + << L" elements"; break; case kPDEForm: - annotContent << L"form containing " << - PDEContentGetNumElems ( PDEFormGetContent ( (PDEForm)*itElem ) ) - << L" elements"; + annotContent << L"form containing " + << PDEContentGetNumElems(PDEFormGetContent((PDEForm)*itElem)) << L" elements"; break; case kPDEGroup: - annotContent << L"group containing " << - PDEContentGetNumElems ( PDEGroupGetContent ( (PDEGroup)*itElem ) ) - << L" elements"; + annotContent << L"group containing " + << PDEContentGetNumElems(PDEGroupGetContent((PDEGroup)*itElem)) << L" elements"; break; case kPDEImage: annotContent << L"image"; @@ -131,128 +125,118 @@ DURING case kPDEXObject: annotContent << L"XObject"; break; + } + + annotContent << L". It is situated at: " << std::endl + << L"\ttop: " << ASFixedToFloat(elementLoc.top) << std::endl + << L"\tbottom: " << ASFixedToFloat(elementLoc.bottom) << std::endl + << L"\tleft: " << ASFixedToFloat(elementLoc.left) << std::endl + << L"\tright: " << ASFixedToFloat(elementLoc.right); + + // The content string is ready. Now make its ASText to add it to the annotation. + ASText annotContentAST = ASTextFromUnicode((ASUTF16Val *)annotContent.str().c_str(), + APDFLDoc::GetHostUnicodeFormat()); + + // The annotation must be cast to a TextAnnot to set its text content. + PDTextAnnot textAnnot = CastToPDTextAnnot(annot); + PDTextAnnotSetContentsASText(textAnnot, annotContentAST); + ASTextDestroy(annotContentAST); + + // The annotation's title. + const char *annotTitleStr = "Page Element"; + PDAnnotSetTitle(annot, annotTitleStr, strlen(annotTitleStr)); + + // Set the annotation's quadrilateral values. This will properly + // position a highlight annotation, and have no effect on the text annotation. + ASFixedQuad annotLocQuad = {{elementLoc.left, elementLoc.bottom}, + {elementLoc.right, elementLoc.bottom}, + {elementLoc.left, elementLoc.top}, + {elementLoc.right, elementLoc.top}}; + SetAnnotationQuads(annot, &annotLocQuad, 1); + + // The annotation will be locked so that it cannot be edited again later. + PDAnnotSetFlags(annot, PDAnnotGetFlags(annot) | pdAnnotLock | pdAnnotLockContents); + + // Set its color + PDAnnotSetColor(annot, SelectColor(annotationType == atText)); } - annotContent << L". It is situated at: " << std::endl - << L"\ttop: " << ASFixedToFloat(elementLoc.top) << std::endl - << L"\tbottom: " << ASFixedToFloat(elementLoc.bottom) << std::endl - << L"\tleft: " << ASFixedToFloat(elementLoc.left) << std::endl - << L"\tright: " << ASFixedToFloat(elementLoc.right); - - //The content string is ready. Now make its ASText to add it to the annotation. - ASText annotContentAST = ASTextFromUnicode ( - (ASUTF16Val*)annotContent.str().c_str(), - APDFLDoc::GetHostUnicodeFormat() ); - - //The annotation must be cast to a TextAnnot to set its text content. - PDTextAnnot textAnnot = CastToPDTextAnnot ( annot ); - PDTextAnnotSetContentsASText ( textAnnot, annotContentAST ); - ASTextDestroy ( annotContentAST ); - - //The annotation's title. - const char* annotTitleStr = "Page Element"; - PDAnnotSetTitle ( annot, annotTitleStr, strlen(annotTitleStr) ); - - //Set the annotation's quadrilateral values. This will properly - // position a highlight annotation, and have no effect on the text annotation. - ASFixedQuad annotLocQuad = { { elementLoc.left, elementLoc.bottom }, - { elementLoc.right, elementLoc.bottom }, - { elementLoc.left, elementLoc.top }, - { elementLoc.right, elementLoc.top } }; - SetAnnotationQuads(annot, &annotLocQuad, 1); - - //The annotation will be locked so that it cannot be edited again later. - PDAnnotSetFlags ( annot, PDAnnotGetFlags(annot) | pdAnnotLock | pdAnnotLockContents ); - - // Set its color - PDAnnotSetColor ( annot, SelectColor ( annotationType == atText ) ); - } + // Step 2) Save the document and close it. -// Step 2) Save the document and close it. + doc.saveDoc(csOutputFileName.c_str()); + PDPageRelease(inPage); + // Close the document and release resources + doc.~APDFLDoc(); - doc.saveDoc ( csOutputFileName.c_str() ); - PDPageRelease(inPage); - // Close the document and release resources - doc.~APDFLDoc(); + // Step 3) Reopen the document we created and Extract the annotations' text -// Step 3) Reopen the document we created and Extract the annotations' text + APDFLDoc annotDoc(csOutputFileName.c_str(), true); + PDPage annotPage = annotDoc.getPage(0); - APDFLDoc annotDoc ( csOutputFileName.c_str(), true); - PDPage annotPage = annotDoc.getPage(0); + int numAnnots = PDPageGetNumAnnots(annotPage); + int numTextAnnots = 0; + int numBlankAnnots = 0; - int numAnnots = PDPageGetNumAnnots(annotPage); - int numTextAnnots = 0; - int numBlankAnnots = 0; + ofText << "The input page has " << numAnnots << " annotations." << std::endl; - ofText << "The input page has " << numAnnots << " annotations." << std::endl; + // Extract each annotation's text content (if any) + const size_t buffersize = 1000; + static char contentBuffer[buffersize]; + for (int i = 0; i < numAnnots; ++i) { + PDAnnot annotation = PDPageGetAnnot(annotPage, i); - //Extract each annotation's text content (if any) - const size_t buffersize = 1000; - static char contentBuffer[buffersize]; - for (int i = 0; i < numAnnots; ++i) - { - PDAnnot annotation = PDPageGetAnnot(annotPage, i); - - PDTextAnnot nextAsText = CastToPDTextAnnot( annotation ); - PDTextAnnotGetContents(nextAsText, contentBuffer, buffersize); - if (contentBuffer[0] != '\0') - { - numTextAnnots++; - ofText << "Annotation no. " << numTextAnnots << ": " << contentBuffer << std::endl; + PDTextAnnot nextAsText = CastToPDTextAnnot(annotation); + PDTextAnnotGetContents(nextAsText, contentBuffer, buffersize); + if (contentBuffer[0] != '\0') { + numTextAnnots++; + ofText << "Annotation no. " << numTextAnnots << ": " << contentBuffer << std::endl; + } else { + ++numBlankAnnots; + } } - else - { - ++numBlankAnnots; - } - } - PDPageRelease ( annotPage ); + PDPageRelease(annotPage); - ofText << numBlankAnnots << " annotations on the page did not have text content." << std::endl; + ofText << numBlankAnnots << " annotations on the page did not have text content." << std::endl; -HANDLER - errCode = ERRORCODE; - libInit.displayError(errCode); -END_HANDLER + HANDLER + errCode = ERRORCODE; + libInit.displayError(errCode); + END_HANDLER return errCode; } // Walk the PDEContent tree (recursively) and save a reference to every element found -/* static */ void extractPDEElements ( PDEContent c, std::vector& elements ) -{ - ASInt32 numElems = PDEContentGetNumElems ( c ); - for ( ASInt32 i = 0; i < numElems; ++i ) - { +/* static */ void extractPDEElements(PDEContent c, std::vector &elements) { + ASInt32 numElems = PDEContentGetNumElems(c); + for (ASInt32 i = 0; i < numElems; ++i) { // Track each element found - PDEElement elem = PDEContentGetElem ( c, i ); - elements.push_back( elem ); + PDEElement elem = PDEContentGetElem(c, i); + elements.push_back(elem); // ...and recurse into the aggregate element types - switch ( PDEObjectGetType ( (PDEObject)elem ) ) - { + switch (PDEObjectGetType((PDEObject)elem)) { case kPDEContainer: - extractPDEElements ( PDEContainerGetContent ( (PDEContainer)elem ), elements ); + extractPDEElements(PDEContainerGetContent((PDEContainer)elem), elements); break; case kPDEForm: - extractPDEElements ( PDEFormGetContent ( (PDEForm)elem ), elements ); + extractPDEElements(PDEFormGetContent((PDEForm)elem), elements); break; case kPDEGroup: - extractPDEElements ( PDEGroupGetContent ( (PDEGroup)elem ), elements ); + extractPDEElements(PDEGroupGetContent((PDEGroup)elem), elements); break; } } } -// Helper function to add quads in BL, BR, TL, TR order to get correct output. -/* static */ void SetAnnotationQuads(PDAnnot annot, ASFixedQuad *quads, ASArraySize numQuads) -{ - CosObj coAnnot = PDAnnotGetCosObj(annot); //Acquire the annotation's cos object. - CosDoc coDoc = CosObjGetDoc(coAnnot); //Get the CosDoc containing the annotation. - CosObj coQuads = CosNewArray(coDoc, false, numQuads * 8); //Create a cos array to hold the quadpoints. +// Helper function to add quads in BL, BR, TL, TR order to get correct output. +/* static */ void SetAnnotationQuads(PDAnnot annot, ASFixedQuad *quads, ASArraySize numQuads) { + CosObj coAnnot = PDAnnotGetCosObj(annot); // Acquire the annotation's cos object. + CosDoc coDoc = CosObjGetDoc(coAnnot); // Get the CosDoc containing the annotation. + CosObj coQuads = CosNewArray(coDoc, false, numQuads * 8); // Create a cos array to hold the quadpoints. - for (ASUns32 i = 0, n = 0; i < numQuads; ++i) - { + for (ASUns32 i = 0, n = 0; i < numQuads; ++i) { // Bottom left CosArrayPut(coQuads, n++, CosNewFixed(coDoc, false, quads[i].bl.h)); CosArrayPut(coQuads, n++, CosNewFixed(coDoc, false, quads[i].bl.v)); @@ -269,25 +253,21 @@ END_HANDLER CosDictPut(coAnnot, ASAtomFromString("QuadPoints"), coQuads); } -/* static */ PDColorValue SelectColor ( bool textAnnotation ) -{ - static PDColorValueRec colorRec; +/* static */ PDColorValue SelectColor(bool textAnnotation) { + static PDColorValueRec colorRec; colorRec.space = PDDeviceRGB; - static int counter ( 0 ); + static int counter(0); - if ( !textAnnotation ) - { - //Cycle between R/G/B for highlight annotations. + if (!textAnnotation) { + // Cycle between R/G/B for highlight annotations. colorRec.value[0] = 0 == counter ? fixedOne : fixedHalf; colorRec.value[1] = 1 == counter ? fixedOne : fixedHalf; colorRec.value[2] = 2 == counter ? fixedOne : fixedHalf; ++counter %= 3; - } - else - { - //Text annotations will be yellow. + } else { + // Text annotations will be yellow. colorRec.value[0] = fixedOne; colorRec.value[1] = fixedOne; colorRec.value[2] = fixedZero; @@ -295,8 +275,6 @@ END_HANDLER return &colorRec; } - - #if 0 //Prepare the text object which will hold all the extracted text. PDEText annotationsText = PDETextCreate(); //This will hold all the extracted text. diff --git a/CPlusPlus/Sample_Source/Annotations/FlattenAnnotations/FlattenAnnotations.cpp b/CPlusPlus/Sample_Source/Annotations/FlattenAnnotations/FlattenAnnotations.cpp index 5e7a782f..aa53b370 100644 --- a/CPlusPlus/Sample_Source/Annotations/FlattenAnnotations/FlattenAnnotations.cpp +++ b/CPlusPlus/Sample_Source/Annotations/FlattenAnnotations/FlattenAnnotations.cpp @@ -8,7 +8,7 @@ // // Command-line: (Both optional) // -// For more detail see the description of the FlattenAnnotations sample program on our Developer’s site, +// For more detail see the description of the FlattenAnnotations sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#flattenannotations #include "InitializeLibrary.h" @@ -23,124 +23,110 @@ #define DEF_INPUT "FlattenAnnotations.pdf" #define DEF_OUTPUT "FlattenAnnotations-out.pdf" -static CosObj FindAppearanceResourceEntry ( CosObj strm, PDPage page ); -static CosObj FindAnnotAppearanceStream ( CosObj annotCos ); +static CosObj FindAppearanceResourceEntry(CosObj strm, PDPage page); +static CosObj FindAnnotAppearanceStream(CosObj annotCos); -int main(int argc, char** argv) -{ +int main(int argc, char **argv) { APDFLib libInit; ASErrorCode errCode = 0; - if (libInit.isValid() == false) - { + if (libInit.isValid() == false) { errCode = libInit.getInitError(); std::cout << "Initialization failed with code " << errCode << std::endl; return libInit.getInitError(); } - - std::string csInputFileName ( argc > 1 ? argv[1] : DIR_LOC DEF_INPUT ); - std::string csOutputFileName ( argc > 2 ? argv[2] : DEF_OUTPUT ); -DURING + std::string csInputFileName(argc > 1 ? argv[1] : DIR_LOC DEF_INPUT); + std::string csOutputFileName(argc > 2 ? argv[2] : DEF_OUTPUT); - APDFLDoc doc ( csInputFileName.c_str(), true); + DURING - PDPage page = doc.getPage(0); - PDEContent pageContent = PDPageAcquirePDEContent(page, 0); + APDFLDoc doc(csInputFileName.c_str(), true); -// Step 1) Convert each Annotation into a Form Xobject, and remove the annotation. + PDPage page = doc.getPage(0); + PDEContent pageContent = PDPageAcquirePDEContent(page, 0); - ASInt32 nAnnotations = PDPageGetNumAnnots ( page ); + // Step 1) Convert each Annotation into a Form Xobject, and remove the annotation. - std::cout << "Flattening " << nAnnotations << " from " << csInputFileName.c_str() - << " and writing to " << csOutputFileName.c_str() << std::endl; + ASInt32 nAnnotations = PDPageGetNumAnnots(page); - // We need to iterate through the annotations in "reverse" order, since PDPageRemoveAnnot - // updates the array of annotations with each removal. - for ( ASInt32 i = nAnnotations - 1; i >= 0; --i ) - { - // Get the next annotation. - PDAnnot next = PDPageGetAnnot(page, i); - CosObj annotCos = PDAnnotGetCosObj(next); + std::cout << "Flattening " << nAnnotations << " from " << csInputFileName.c_str() + << " and writing to " << csOutputFileName.c_str() << std::endl; - CosObj appearanceStrm = FindAnnotAppearanceStream ( annotCos ); - CosObj resource = FindAppearanceResourceEntry ( appearanceStrm, page ); + // We need to iterate through the annotations in "reverse" order, since PDPageRemoveAnnot + // updates the array of annotations with each removal. + for (ASInt32 i = nAnnotations - 1; i >= 0; --i) { + // Get the next annotation. + PDAnnot next = PDPageGetAnnot(page, i); + CosObj annotCos = PDAnnotGetCosObj(next); - if (CosObjGetType(resource) != CosNull) - { - // Place the annotation's resources in the page's content - ASFixedRect nextLoc; - PDAnnotGetRect(next, &nextLoc); - ASDoubleMatrix unity; - unity.a = unity.d = 1.0; - unity.b = unity.c = 0.0; - unity.h = (ASDouble)ASFixedToFloat(nextLoc.left); - unity.v = (ASDouble)ASFixedToFloat(nextLoc.bottom); + CosObj appearanceStrm = FindAnnotAppearanceStream(annotCos); + CosObj resource = FindAppearanceResourceEntry(appearanceStrm, page); - //Create and add the form xobject. - PDEForm formXObject = PDEFormCreateFromCosObjEx(&appearanceStrm, &resource, &unity); - PDEContentAddElem(pageContent, kPDEAfterLast, (PDEElement)formXObject); + if (CosObjGetType(resource) != CosNull) { + // Place the annotation's resources in the page's content + ASFixedRect nextLoc; + PDAnnotGetRect(next, &nextLoc); + ASDoubleMatrix unity; + unity.a = unity.d = 1.0; + unity.b = unity.c = 0.0; + unity.h = (ASDouble)ASFixedToFloat(nextLoc.left); + unity.v = (ASDouble)ASFixedToFloat(nextLoc.bottom); - PDERelease((PDEObject)formXObject); - } - else - { - //This annotation has no appearance. - std::cout << "Warning: The " << i << "th annotation, a " - << ASAtomGetString(PDAnnotGetSubtype(next)) - << ", has no contained or inherited resources entry, so has no appearance. " - << "It will still be removed." << std::endl; - } + // Create and add the form xobject. + PDEForm formXObject = PDEFormCreateFromCosObjEx(&appearanceStrm, &resource, &unity); + PDEContentAddElem(pageContent, kPDEAfterLast, (PDEElement)formXObject); - PDPageRemoveAnnot(page, i); + PDERelease((PDEObject)formXObject); + } else { + // This annotation has no appearance. + std::cout << "Warning: The " << i << "th annotation, a " + << ASAtomGetString(PDAnnotGetSubtype(next)) + << ", has no contained or inherited resources entry, so has no " + "appearance. " + << "It will still be removed." << std::endl; + } - } + PDPageRemoveAnnot(page, i); + } PDPageSetPDEContentCanRaise(page, 0); -// Step 2) Save and close. + // Step 2) Save and close. - //Release resources. - PDPageReleasePDEContent(page, 0); - PDPageRelease(page); + // Release resources. + PDPageReleasePDEContent(page, 0); + PDPageRelease(page); - doc.saveDoc ( csOutputFileName.c_str() ); + doc.saveDoc(csOutputFileName.c_str()); -HANDLER - errCode = ERRORCODE; - libInit.displayError(errCode); -END_HANDLER + HANDLER + errCode = ERRORCODE; + libInit.displayError(errCode); + END_HANDLER return errCode; } -// Try to find an annotation's appearance stream, which may contain the resource's CosObj +// Try to find an annotation's appearance stream, which may contain the resource's CosObj // that we will need to create the PDEForm of its appearance. // -CosObj FindAnnotAppearanceStream ( CosObj annotCos ) -{ +CosObj FindAnnotAppearanceStream(CosObj annotCos) { CosObj retObj = CosNewNull(); // The appearance dictionary of our annotation. - if (CosDictKnownKeyString(annotCos, "AP")) - { + if (CosDictKnownKeyString(annotCos, "AP")) { // The appearance dictionary of this annotation CosObj APDict = CosDictGetKeyString(annotCos, "AP"); - if (CosDictKnownKeyString(APDict, "N")) - { - //The normal appearance of our annotation. - CosObj normal = CosDictGetKeyString(APDict, "N"); - - //The normal appearance is either a stream or a dictionary. If the appearance is a dictionary, - //we will need to get the appearance stream from the appearance state ("AS"). - if (CosObjGetType(normal) == CosStream) - { + if (CosDictKnownKeyString(APDict, "N")) { + // The normal appearance of our annotation. + CosObj normal = CosDictGetKeyString(APDict, "N"); + + // The normal appearance is either a stream or a dictionary. If the appearance is a dictionary, + // we will need to get the appearance stream from the appearance state ("AS"). + if (CosObjGetType(normal) == CosStream) { retObj = normal; - } - else - { - if (CosDictKnownKeyString(annotCos, "AS")) - { + } else { + if (CosDictKnownKeyString(annotCos, "AS")) { ASAtom appearanceName = CosNameValue(CosDictGetKeyString(annotCos, "AS")); - if (CosDictKnown(normal, appearanceName)) - { + if (CosDictKnown(normal, appearanceName)) { retObj = CosDictGet(normal, appearanceName); } } @@ -152,31 +138,23 @@ CosObj FindAnnotAppearanceStream ( CosObj annotCos ) // If we found an appearance stream, we must find its resources entry. Otherwise the annotation has no appearance. // -CosObj FindAppearanceResourceEntry ( CosObj strm, PDPage page ) -{ +CosObj FindAppearanceResourceEntry(CosObj strm, PDPage page) { CosObj retObj = CosNewNull(); - if (CosObjGetType ( strm ) != CosNull) - { - retObj = CosDictGetKeyString( strm, "Resources"); + if (CosObjGetType(strm) != CosNull) { + retObj = CosDictGetKeyString(strm, "Resources"); // If the appearance stream doesn't have a Resources entry, we must look for an appearance // that might have been inherited from a parent page in the page tree. - if ( CosObjGetType ( retObj ) == CosNull) - { + if (CosObjGetType(retObj) == CosNull) { CosObj pageObj = PDPageGetCosObj(page); - while (CosObjGetType( retObj ) == CosNull) - { + while (CosObjGetType(retObj) == CosNull) { retObj = CosDictGetKeyString(pageObj, "Resources"); - if (CosObjGetType( retObj ) == CosNull) - { + if (CosObjGetType(retObj) == CosNull) { pageObj = CosDictGetKeyString(pageObj, "Parent"); - if (CosObjGetType(pageObj) == CosNull) - { + if (CosObjGetType(pageObj) == CosNull) { break; } - } - else - { + } else { break; } } diff --git a/CPlusPlus/Sample_Source/ContentCreation/AddArt/AddArt.cpp b/CPlusPlus/Sample_Source/ContentCreation/AddArt/AddArt.cpp index 402fd719..9f7c38cd 100644 --- a/CPlusPlus/Sample_Source/ContentCreation/AddArt/AddArt.cpp +++ b/CPlusPlus/Sample_Source/ContentCreation/AddArt/AddArt.cpp @@ -8,7 +8,7 @@ // // The AddArt sample demonstrates drawing a graphic image on a PDF page by manipulating PDEPath objects. // -// For more detail see the description of the AddArt sample program on our Developer’s site, +// For more detail see the description of the AddArt sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#addart #include @@ -22,127 +22,124 @@ #define DEF_OUTPUT "AddArt-out.pdf" -int main(int argc, char** argv) -{ - APDFLib libInit; +int main(int argc, char **argv) { + APDFLib libInit; ASErrorCode errCode = 0; - if (libInit.isValid() == false) - { + if (libInit.isValid() == false) { errCode = libInit.getInitError(); std::cout << "Initialization failed with code " << errCode << std::endl; return errCode; } - std::string csOutputFileName ( argc > 1 ? argv[1] : DEF_OUTPUT ); + std::string csOutputFileName(argc > 1 ? argv[1] : DEF_OUTPUT); DURING -//Step 1: Create a PDF document with one 10"x10" page, acquire a page and it's content + // Step 1: Create a PDF document with one 10"x10" page, acquire a page and it's content APDFLDoc document; - document.insertPage(Int32ToFixed((72 * 10)), Int32ToFixed((72 * 10)), PDBeforeFirstPage); - - PDPage pdPage = document.getPage(0); - - PDEContent pdeContent = PDPageAcquirePDEContent(pdPage, 0); - -// Step 2: Set the graphics state for the first shape. This PDEGraphicsState object -// contains attributes about how a PDEElement will be displayed. - - PDEPath pdePath = PDEPathCreate(); - - //PDEPath will be stroked, but not filled. - PDEPathSetPaintOp(pdePath, kPDEStroke); - - //Struct that will hold display attributes. - PDEGraphicState gState; - - //Set graphics state to default values. - PDEDefaultGState(&gState, sizeof(PDEGraphicState)); - - //Release the stroke color space before modifiying it. - PDERelease(reinterpret_cast(gState.strokeColorSpec.space)); - - ASFixed red = ASFloatToFixed(.6); //Red Intensity range is [0.0 - 1.0]. - ASFixed green = ASFloatToFixed(.2); //Green Intensity range is [0.0 - 1.0]. - ASFixed blue = ASFloatToFixed(1.0); //Blue Intensity range is [0.0 - 1.0]. - - //We are using the RGB color space in this case. Default value is "DeviceGray". + document.insertPage(Int32ToFixed((72 * 10)), Int32ToFixed((72 * 10)), PDBeforeFirstPage); + + PDPage pdPage = document.getPage(0); + + PDEContent pdeContent = PDPageAcquirePDEContent(pdPage, 0); + + // Step 2: Set the graphics state for the first shape. This PDEGraphicsState object + // contains attributes about how a PDEElement will be displayed. + + PDEPath pdePath = PDEPathCreate(); + + // PDEPath will be stroked, but not filled. + PDEPathSetPaintOp(pdePath, kPDEStroke); + + // Struct that will hold display attributes. + PDEGraphicState gState; + + // Set graphics state to default values. + PDEDefaultGState(&gState, sizeof(PDEGraphicState)); + + // Release the stroke color space before modifiying it. + PDERelease(reinterpret_cast(gState.strokeColorSpec.space)); + + ASFixed red = ASFloatToFixed(.6); // Red Intensity range is [0.0 - 1.0]. + ASFixed green = ASFloatToFixed(.2); // Green Intensity range is [0.0 - 1.0]. + ASFixed blue = ASFloatToFixed(1.0); // Blue Intensity range is [0.0 - 1.0]. + + // We are using the RGB color space in this case. Default value is "DeviceGray". gState.strokeColorSpec.space = PDEColorSpaceCreateFromName(ASAtomFromString("DeviceRGB")); - gState.strokeColorSpec.value.color[0] = red; //Initially value = 0 (Black.) - gState.strokeColorSpec.value.color[1] = green; //In this case the object will be painted purple. + gState.strokeColorSpec.value.color[0] = red; // Initially value = 0 (Black.) + gState.strokeColorSpec.value.color[1] = green; // In this case the object will be painted purple. gState.strokeColorSpec.value.color[2] = blue; - gState.lineWidth = Int32ToFixed(3); //Line width is set to a thickness of 3. - gState.lineCap = 1; //Using rounded line caps. - gState.lineJoin = 1; //Using rounded line joins. + gState.lineWidth = Int32ToFixed(3); // Line width is set to a thickness of 3. + gState.lineCap = 1; // Using rounded line caps. + gState.lineJoin = 1; // Using rounded line joins. - //Set the PDEPath's graphic state. + // Set the PDEPath's graphic state. PDEElementSetGState(reinterpret_cast(pdePath), &gState, sizeof(PDEGraphicState)); - //Release the PDEColorSpace objects. - PDERelease(reinterpret_cast(gState.strokeColorSpec.space)); + // Release the PDEColorSpace objects. + PDERelease(reinterpret_cast(gState.strokeColorSpec.space)); PDERelease(reinterpret_cast(gState.fillColorSpec.space)); -//Step 3: Draw the arrow using a list of coordinates and calling PDEPathAddSegment to -// join the (x, y) coordinates with straight lines. + // Step 3: Draw the arrow using a list of coordinates and calling PDEPathAddSegment to + // join the (x, y) coordinates with straight lines. const unsigned numberOfPoints = 7; // Set up (x, y) coordinates for points of the arrow. Note: 72 pixels in one inch. - ASInt32 arrowXCoordinates[numberOfPoints] = - {(72 * 7), (72 * 6), (72 * 6), (72 * 4), (72 * 4), (72 * 3), (72 * 5)}; - ASInt32 arrowYCoordinates[numberOfPoints] = - {(72 * 7), (72 * 7), (72 * 3), (72 * 3), (72 * 7), (72 * 7), (72 * 9)}; - ASFixedPoint pointToInsert; + ASInt32 arrowXCoordinates[numberOfPoints] = {(72 * 7), (72 * 6), (72 * 6), (72 * 4), + (72 * 4), (72 * 3), (72 * 5)}; + ASInt32 arrowYCoordinates[numberOfPoints] = {(72 * 7), (72 * 7), (72 * 3), (72 * 3), + (72 * 7), (72 * 7), (72 * 9)}; + ASFixedPoint pointToInsert; - //Move to start point at the tip of the arrow before drawing lines. + // Move to start point at the tip of the arrow before drawing lines. pointToInsert.h = ASInt32ToFixed(72 * 5); pointToInsert.v = ASInt32ToFixed(72 * 9); - PDEPathAddSegment(pdePath, kPDEMoveTo, pointToInsert.h, pointToInsert.v, - fixedZero, fixedZero, fixedZero, fixedZero); + PDEPathAddSegment(pdePath, kPDEMoveTo, pointToInsert.h, pointToInsert.v, fixedZero, + fixedZero, fixedZero, fixedZero); - //Loop through the coordinates and draw lines connecting each (x, y) pair. - for (unsigned i = 0; i < numberOfPoints; ++i) - { + // Loop through the coordinates and draw lines connecting each (x, y) pair. + for (unsigned i = 0; i < numberOfPoints; ++i) { pointToInsert.h = ASInt32ToFixed(arrowXCoordinates[i]); pointToInsert.v = ASInt32ToFixed(arrowYCoordinates[i]); - PDEPathAddSegment(pdePath, kPDELineTo, pointToInsert.h, pointToInsert.v, - fixedZero, fixedZero, fixedZero, fixedZero); + PDEPathAddSegment(pdePath, kPDELineTo, pointToInsert.h, pointToInsert.v, fixedZero, + fixedZero, fixedZero, fixedZero); } - //Insert the PDEPath into the PDEContent that was acquired. + // Insert the PDEPath into the PDEContent that was acquired. PDEContentAddElem(pdeContent, kPDEAfterLast, reinterpret_cast(pdePath)); - //Set the PDEContent back into the PDPage's Cos object. + // Set the PDEContent back into the PDPage's Cos object. PDPageSetPDEContentCanRaise(pdPage, 0); - //Release the path object. + // Release the path object. PDERelease(reinterpret_cast(pdePath)); -// Step 4: Draw a second arrow and apply transformations: create a new PDEPath object and apply -// some transformations to it using a transformation matrix. We will add a fill color of yellow -// to this object to differentiate between the objects. For more information on translations, -// rotations, scaling, and skews, see "Coordinate Systems" (section 8.3) in -// "ISO 32000-1:2008, Document Management-Portable Document Format-Part 1: PDF 1.7, page 114" at -// http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#page=122 - - //Second path object that will be drawn to the page. - PDEPath pdePath2 = PDEPathCreate(); + // Step 4: Draw a second arrow and apply transformations: create a new PDEPath object and apply + // some transformations to it using a transformation matrix. We will add a fill color of yellow + // to this object to differentiate between the objects. For more information on translations, + // rotations, scaling, and skews, see "Coordinate Systems" (section 8.3) in + // "ISO 32000-1:2008, Document Management-Portable Document Format-Part 1: PDF 1.7, page 114" at + // http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#page=122 - //This arrow will be stroked and filled with color. - PDEPathSetPaintOp(pdePath2, kPDEStroke | kPDEFill); + // Second path object that will be drawn to the page. + PDEPath pdePath2 = PDEPathCreate(); - //Fill color is yellow + // This arrow will be stroked and filled with color. + PDEPathSetPaintOp(pdePath2, kPDEStroke | kPDEFill); + + // Fill color is yellow red = ASFloatToFixed(1.0); blue = ASFloatToFixed(0.0); green = ASFloatToFixed(1.0); - - //Set the Graphics state color space to RGB. + + // Set the Graphics state color space to RGB. gState.fillColorSpec.space = PDEColorSpaceCreateFromName(ASAtomFromString("DeviceRGB")); gState.strokeColorSpec.space = PDEColorSpaceCreateFromName(ASAtomFromString("DeviceRGB")); - gState.fillColorSpec.value.color[0] = red; //Assign RGB color values. + gState.fillColorSpec.value.color[0] = red; // Assign RGB color values. gState.fillColorSpec.value.color[1] = green; gState.fillColorSpec.value.color[2] = blue; @@ -151,54 +148,53 @@ int main(int argc, char** argv) PDERelease(reinterpret_cast(gState.strokeColorSpec.space)); PDERelease(reinterpret_cast(gState.fillColorSpec.space)); - //Redraw the exact same arrow we created in step 3. + // Redraw the exact same arrow we created in step 3. pointToInsert.h = ASInt32ToFixed(72 * 5); pointToInsert.v = ASInt32ToFixed(72 * 9); - PDEPathAddSegment(pdePath2, kPDEMoveTo, pointToInsert.h, pointToInsert.v, - fixedZero, fixedZero, fixedZero, fixedZero); + PDEPathAddSegment(pdePath2, kPDEMoveTo, pointToInsert.h, pointToInsert.v, fixedZero, + fixedZero, fixedZero, fixedZero); - for (unsigned i = 0; i < numberOfPoints; ++i) - { + for (unsigned i = 0; i < numberOfPoints; ++i) { pointToInsert.h = ASInt32ToFixed(arrowXCoordinates[i]); pointToInsert.v = ASInt32ToFixed(arrowYCoordinates[i]); - PDEPathAddSegment(pdePath2, kPDELineTo, pointToInsert.h, - pointToInsert.v, fixedZero, fixedZero, fixedZero, fixedZero); + PDEPathAddSegment(pdePath2, kPDELineTo, pointToInsert.h, pointToInsert.v, fixedZero, + fixedZero, fixedZero, fixedZero); } - //Move the arrow 4 inches right and 2 inches down. - ASDoubleMatrix translationMatrix = { 1, 0.0, 0.0, 1, (72.0 * 4.0), (-72.0 * 2.0) }; - //Scale it to 75% of its original size. - ASDoubleMatrix scalingMatrix = { 0.75, 0.0, 0.0, 0.75, 0.0, 0.0 }; - //Holds result of multiplying the last two matrices. + // Move the arrow 4 inches right and 2 inches down. + ASDoubleMatrix translationMatrix = {1, 0.0, 0.0, 1, (72.0 * 4.0), (-72.0 * 2.0)}; + // Scale it to 75% of its original size. + ASDoubleMatrix scalingMatrix = {0.75, 0.0, 0.0, 0.75, 0.0, 0.0}; + // Holds result of multiplying the last two matrices. ASDoubleMatrix translateAndScale; - //IMPORTANT NOTE! If applying multiple transformations to a matrix you must concatenate - // the matrices before applying transformations. - //DO NOT attempt to call PDEElementSetMatrixEx() more than one time on the same PDEElement. - ASDoubleMatrixConcat(&translateAndScale, &translationMatrix, &scalingMatrix); + // IMPORTANT NOTE! If applying multiple transformations to a matrix you must concatenate + // the matrices before applying transformations. + // DO NOT attempt to call PDEElementSetMatrixEx() more than one time on the same PDEElement. + ASDoubleMatrixConcat(&translateAndScale, &translationMatrix, &scalingMatrix); - //Apply the transformation matrix. + // Apply the transformation matrix. PDEElementSetMatrixEx(reinterpret_cast(pdePath2), &translateAndScale); - //Insert the PDEPath into the PDEContent that was acquired. + // Insert the PDEPath into the PDEContent that was acquired. PDEContentAddElem(pdeContent, kPDEAfterLast, reinterpret_cast(pdePath2)); - - //Set the PDEContent back into the PDPage's Cos object. + + // Set the PDEContent back into the PDPage's Cos object. PDPageSetPDEContentCanRaise(pdPage, 0); -//Step 5) Release resources and save the PDF document. + // Step 5) Release resources and save the PDF document. PDERelease(reinterpret_cast(pdePath2)); PDPageReleasePDEContent(pdPage, 0); PDPageRelease(pdPage); - document.saveDoc( csOutputFileName.c_str(), PDSaveFull | PDSaveLinearized); + document.saveDoc(csOutputFileName.c_str(), PDSaveFull | PDSaveLinearized); HANDLER errCode = ERRORCODE; libInit.displayError(errCode); END_HANDLER - return errCode; //APDFLib's destructor terminates the library. + return errCode; // APDFLib's destructor terminates the library. } diff --git a/CPlusPlus/Sample_Source/ContentCreation/AddAttachments/AddAttachments.cpp b/CPlusPlus/Sample_Source/ContentCreation/AddAttachments/AddAttachments.cpp index e4864e0c..1839a936 100644 --- a/CPlusPlus/Sample_Source/ContentCreation/AddAttachments/AddAttachments.cpp +++ b/CPlusPlus/Sample_Source/ContentCreation/AddAttachments/AddAttachments.cpp @@ -8,7 +8,7 @@ // // Command-line arguments: (All optional) // -// For more detail see the description of the AddAttachments sample program on our Developer’s site, +// For more detail see the description of the AddAttachments sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#addattachments #include @@ -18,132 +18,130 @@ #include "CosCalls.h" -#define INPUT_LOC "../../../../Resources/Sample_Input/" +#define INPUT_LOC "../../../../Resources/Sample_Input/" #define DEF_INPUT "noattachment.pdf" #define DEF_ATT_1 "attachment1.xlsx" #define DEF_ATT_2 "attachment2.docx" #define DEF_OUTPUT "AddAttachments-out.pdf" -//Returns a newly opened ASFile, given the file's path. -ASFile openASFile(wchar_t* filepath); +// Returns a newly opened ASFile, given the file's path. +ASFile openASFile(wchar_t *filepath); -int main(int argc, char** argv) -{ +int main(int argc, char **argv) { ASErrorCode errCode = 0; - - //Initialize the Adobe PDF Library. Termination will be automatic when "lib" goes out of scope - APDFLib lib; - if (lib.isValid() == false) - { + // Initialize the Adobe PDF Library. Termination will be automatic when "lib" goes out of scope + APDFLib lib; + + if (lib.isValid() == false) { errCode = lib.getInitError(); std::cout << "Initialization failed with code " << errCode << std::endl; return errCode; } - std::string csInputFileName ( argc > 1 ? argv[1] : INPUT_LOC DEF_INPUT ); - std::string csOutputFileName ( argc > 2 ? argv[2] : DEF_OUTPUT ); - std::string csAttachment1Name ( argc > 3 ? argv[3] : INPUT_LOC DEF_ATT_1 ); - std::string csAttachment2Name ( argc > 4 ? argv[4] : INPUT_LOC DEF_ATT_2 ); + std::string csInputFileName(argc > 1 ? argv[1] : INPUT_LOC DEF_INPUT); + std::string csOutputFileName(argc > 2 ? argv[2] : DEF_OUTPUT); + std::string csAttachment1Name(argc > 3 ? argv[3] : INPUT_LOC DEF_ATT_1); + std::string csAttachment2Name(argc > 4 ? argv[4] : INPUT_LOC DEF_ATT_2); DURING std::cout << "Opening the input file " << csInputFileName.c_str() << std::endl; - APDFLDoc inputAPDoc( csInputFileName.c_str(), true); //Opens the input PDF document. - PDDoc inputDoc = inputAPDoc.getPDDoc(); //The input PDF's PDDoc reference. - CosDoc inputDocCD = PDDocGetCosDoc(inputDoc); //The PDDoc's COS representation. + APDFLDoc inputAPDoc(csInputFileName.c_str(), true); // Opens the input PDF document. + PDDoc inputDoc = inputAPDoc.getPDDoc(); // The input PDF's PDDoc reference. + CosDoc inputDocCD = PDDocGetCosDoc(inputDoc); // The PDDoc's COS representation. -// 1) Create the first PDFileAttachment. + // 1) Create the first PDFileAttachment. std::cout << "Opening attachment 1, " << csAttachment1Name.c_str() << std::endl; - ASFile attach1ASFile = APDFLDoc::OpenFlatFile ( csAttachment1Name.c_str() ); + ASFile attach1ASFile = APDFLDoc::OpenFlatFile(csAttachment1Name.c_str()); - PDFileAttachment attach1PDFA = PDFileAttachmentNewFromFile ( - inputDocCD, //The PDF the file attachment will be referenced from. - attach1ASFile, //The file we want to attach. - NULL, 0, //No filters for the file attachment stream. - CosNewNull(), //No filter parameters. - NULL, NULL, NULL); //No progress monitoring. + PDFileAttachment attach1PDFA = + PDFileAttachmentNewFromFile(inputDocCD, // The PDF the file attachment will be referenced from. + attach1ASFile, // The file we want to attach. + NULL, 0, // No filters for the file attachment stream. + CosNewNull(), // No filter parameters. + NULL, NULL, NULL); // No progress monitoring. - //Get the CosObj representation of the file attachment. - CosObj attach1CO = PDFileAttachmentGetCosObj(attach1PDFA); + // Get the CosObj representation of the file attachment. + CosObj attach1CO = PDFileAttachmentGetCosObj(attach1PDFA); - ASFileClose(attach1ASFile); //We can release the ASFile at this point. + ASFileClose(attach1ASFile); // We can release the ASFile at this point. -// 2) Embed it to the document's name tree. + // 2) Embed it to the document's name tree. - //Retrieve the document's "EmbeddedFiles" name tree. + // Retrieve the document's "EmbeddedFiles" name tree. // (This name tree has not yet been used, so we must "create" it) PDNameTree filesTree = PDDocCreateNameTree(inputDoc, ASAtomFromString("EmbeddedFiles")); - //The KEY to add to the inputDocCD CosDoc. Totally arbitrary. + // The KEY to add to the inputDocCD CosDoc. Totally arbitrary. CosObj EmbedKey = CosNewString(inputDocCD, true, "TheSpreadsheet", 14); - //Adding a key/value pair to the EmbeddedFiles name tree, where the value is - //a CosObj of a PDFileAttachment, embeds the file in the PDDoc. - PDNameTreePut(filesTree, //The tree to add the Key/Value pair to. - EmbedKey, //the KEY. - attach1CO); //The VALUE: the attachment's file specification + // Adding a key/value pair to the EmbeddedFiles name tree, where the value is + // a CosObj of a PDFileAttachment, embeds the file in the PDDoc. + PDNameTreePut(filesTree, // The tree to add the Key/Value pair to. + EmbedKey, // the KEY. + attach1CO); // The VALUE: the attachment's file specification -// 3) Create the second PDFileAttachment. + // 3) Create the second PDFileAttachment. std::cout << "Opening attachment 2, " << csAttachment2Name.c_str() << std::endl; - ASFile attach2ASFile = APDFLDoc::OpenFlatFile ( csAttachment2Name.c_str() ); + ASFile attach2ASFile = APDFLDoc::OpenFlatFile(csAttachment2Name.c_str()); - PDFileAttachment attach2PDFA = PDFileAttachmentNewFromFile ( - inputDocCD, //The PDDoc CosDict that the file attachment will be referenced from. - attach2ASFile, //The file we want to attach. - NULL, 0, //No filters for the file attachment stream. - CosNewNull(), //No filter parameters. - NULL, NULL, NULL); //No progress monitoring. + PDFileAttachment attach2PDFA = PDFileAttachmentNewFromFile( + inputDocCD, // The PDDoc CosDict that the file attachment will be referenced from. + attach2ASFile, // The file we want to attach. + NULL, 0, // No filters for the file attachment stream. + CosNewNull(), // No filter parameters. + NULL, NULL, NULL); // No progress monitoring. - //Get the CosObject representation of the file attachment. - CosObj attach2CO = PDFileAttachmentGetCosObj(attach2PDFA); + // Get the CosObject representation of the file attachment. + CosObj attach2CO = PDFileAttachmentGetCosObj(attach2PDFA); - ASFileClose(attach2ASFile); //We can release the ASFile at this point + ASFileClose(attach2ASFile); // We can release the ASFile at this point -// 4) Create an annotation. + // 4) Create an annotation. - //This rectangle determines the annotation's placement on the page. + // This rectangle determines the annotation's placement on the page. ASFixedRect annotLocation; - annotLocation.left = ASFloatToFixed(2.50 * 72); //There are 72 pixels per inch. - annotLocation.right = ASFloatToFixed(3.00 * 72); - annotLocation.top = ASFloatToFixed(8.40 * 72); + annotLocation.left = ASFloatToFixed(2.50 * 72); // There are 72 pixels per inch. + annotLocation.right = ASFloatToFixed(3.00 * 72); + annotLocation.top = ASFloatToFixed(8.40 * 72); annotLocation.bottom = ASFloatToFixed(8.90 * 72); - PDPage page1 = PDDocAcquirePage(inputDoc, 0); //The annotation will go on page 1. + PDPage page1 = PDDocAcquirePage(inputDoc, 0); // The annotation will go on page 1. - //This method just creates an annotation. - PDAnnot newAnnot = PDPageCreateAnnot ( - page1, //The page the annotation will go on. - ASAtomFromString("FileAttachment"), //The type of annotation we're creating. - &annotLocation); //The annotation's location on the page. + // This method just creates an annotation. + PDAnnot newAnnot = + PDPageCreateAnnot(page1, // The page the annotation will go on. + ASAtomFromString("FileAttachment"), // The type of annotation we're creating. + &annotLocation); // The annotation's location on the page. - PDPageAddAnnot(page1, -2, newAnnot); //Add the annotation as the first annotation on the page. + PDPageAddAnnot(page1, -2, newAnnot); // Add the annotation as the first annotation on the page. - CosObj newAnnotCO = PDAnnotGetCosObj(newAnnot); //The annotation's CosObject representation. + CosObj newAnnotCO = PDAnnotGetCosObj(newAnnot); // The annotation's CosObject representation. -// 5) Embed the second PDFileAttachment to the annotation. + // 5) Embed the second PDFileAttachment to the annotation. - //Like embedding to a PDDoc's name tree, adding a key/Value pair to - //the annotation's CosDict, where the key is "FS" (the File Specification key) - //and the value is the a PDFileAttachment cos object, will embed the file to - //the annotation. - CosDictPutKeyString(newAnnotCO, //The dictionary we want to add to. - "FS", //The KEY: we're changing the File Specification. - attach2CO); //The VALUE: The file spec we want the annot to open + // Like embedding to a PDDoc's name tree, adding a key/Value pair to + // the annotation's CosDict, where the key is "FS" (the File Specification key) + // and the value is the a PDFileAttachment cos object, will embed the file to + // the annotation. + CosDictPutKeyString(newAnnotCO, // The dictionary we want to add to. + "FS", // The KEY: we're changing the File Specification. + attach2CO); // The VALUE: The file spec we want the annot to open -// 6) Save and close. + // 6) Save and close. - //PDPages must be released before closing the document. - PDPageRelease(page1); - inputAPDoc.saveDoc( csOutputFileName.c_str() ); // inputAPDoc's destructor will close the document. + // PDPages must be released before closing the document. + PDPageRelease(page1); + inputAPDoc.saveDoc(csOutputFileName.c_str()); // inputAPDoc's destructor will close the document. - std::cout << "Attached both attachements to input file, saved output as " << - csOutputFileName.c_str() << std::endl; + std::cout << "Attached both attachements to input file, saved output as " + << csOutputFileName.c_str() << std::endl; HANDLER errCode = ERRORCODE; diff --git a/CPlusPlus/Sample_Source/ContentCreation/AddContent/AddContent.cpp b/CPlusPlus/Sample_Source/ContentCreation/AddContent/AddContent.cpp index 5c9c815b..8282f617 100644 --- a/CPlusPlus/Sample_Source/ContentCreation/AddContent/AddContent.cpp +++ b/CPlusPlus/Sample_Source/ContentCreation/AddContent/AddContent.cpp @@ -8,7 +8,7 @@ // // Command-line: (both optional) // -// For more detail see the description of the AddContent sample program on our Developer’s site, +// For more detail see the description of the AddContent sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#addcontent #include @@ -30,189 +30,181 @@ // Helper function used to create a rectangle, parameter description in function definition. static PDEPath PathRect(ASFixed, ASFixed, ASFixed, ASFixed, int, ASFixed, ASFixed, ASFixed); -int main(int argc, char** argv) -{ - APDFLib libInit; // Initialize the Adobe PDF Library. (Going out of scope will terminate.) +int main(int argc, char **argv) { + APDFLib libInit; // Initialize the Adobe PDF Library. (Going out of scope will terminate.) ASErrorCode errCode = 0; - if (libInit.isValid() == false) - { + if (libInit.isValid() == false) { errCode = libInit.getInitError(); std::cout << "Initialization failed with code " << errCode << std::endl; return errCode; } -DURING - - std::string csInputFileName ( argc > 1 ? argv[1] : DIR_LOC DEF_INPUT ); - std::string csOutputFileName ( argc > 2 ? argv[2] : DEF_OUTPUT ); - std::cout << "Adding some PDE Elements to file " << csInputFileName.c_str() - << " and saving as " << csOutputFileName.c_str() << std::endl; - - APDFLDoc document( csInputFileName.c_str(), true ); - -// Step 1) Set up the font for the text to be displayed. - - PDEFontAttrs attrs; - memset(&attrs, 0, sizeof(attrs)); - attrs.name = ASAtomFromString("CourierStd"); - attrs.type = ASAtomFromString("Type1"); - //Get the corresponding system font. - PDSysFont sysFont = PDFindSysFont(&attrs, sizeof(attrs), kPDSysFontMatchFontType); - - PDSysFontGetAttrs(sysFont, &attrs, sizeof(PDEFontAttrs)); - - //Check if font is embeddable. - PDEFont courierStdFont = NULL; - if (attrs.cantEmbed != 0) - { - std::cerr << "Font " << ASAtomGetString(attrs.name) << " can not be embedded"; - } - else - { - //Create font from the system font and embed. - courierStdFont = PDEFontCreateFromSysFont(sysFont, kPDEFontCreateEmbedded); - } - -// Step 2) Set up the content to be added to the document. Elements are added to the page at -// X and Y values starting from the bottom left corner. - - //Text that will be displayed on page - std::string textToDisplay = "Here is some text in the CourierStd font, using both PDEText and PDEFont."; - - PDEGraphicState gState; - memset(&gState, NULL, sizeof(gState)); - - PDEDefaultGState(&gState, sizeof(gState)); //Set the graphics state to default values - - PDETextState tState; - memset(&tState, NULL, sizeof(tState)); - - //Transformation matrix for text which determines location of the text on page. - ASDoubleMatrix textMatrix; - - memset(&textMatrix, 0, sizeof(textMatrix)); - textMatrix.a = 10; //Set font width and height. - textMatrix.d = 10; //Set font point size. - textMatrix.h = 72 * 0.6; //x coordinate on page (72 pixels = 1 inch). - textMatrix.v = 72 * 8; //y coordinate on page. - - PDEText pdeText = PDETextCreate(); //Create a new text run. - - //Adding the text run to the PDE text object - PDETextAddEx ( - pdeText, //Text container to add to - kPDETextRun, //kPDETextRun or kPDETextChar as appropriate - 0, //The index after which to add the text run - (Uns8 *)textToDisplay.c_str(), //Text to add - textToDisplay.length(), //Length of text - courierStdFont, //Font to apply to text - &gState, sizeof(gState), //Graphic state and its size - &tState, sizeof(tState), //Text state and its size - &textMatrix, //Transformation matrix for text - NULL); //Stroke matrix for the line width when stroking text - - textMatrix.v = 72 * 7; //y coordinate on page. - textToDisplay = "Below is a PDEPath rectangle. "; - - //Adding the text run to the PDE text object - PDETextAddEx ( - pdeText, //Text container to add to. - kPDETextRun, //kPDETextRun or kPDETextChar as appropriate - 0, //The index after which to add the text run. - (Uns8 *)textToDisplay.c_str(), //Text to add. - textToDisplay.length(), //Length of text - courierStdFont, //Font to apply to text. - &gState, sizeof(gState), //Graphic state and its size. - &tState, sizeof(tState), //Text state and its size. - &textMatrix, //Transformation matrix for text. - NULL); //Stroke matrix for the line width when stroking text. - - //Determine the needed flags for embedding and call the appropriate routines for doing so. - PDEFontEmbedNow(courierStdFont, PDDocGetCosDoc(document.pdDoc)); - - // Cook up a blue rectangle... - PDEPath rect = PathRect ( ASFloatToFixed(72 * 3.25), ASInt32ToFixed(72 * 4), - ASInt32ToFixed(72 * 2), ASInt32ToFixed(72 * 2), 46, - fixedZero, fixedZero, fixedOne); - -//Step 3) Acquire PDEContent and add elements to the page. + DURING + + std::string csInputFileName(argc > 1 ? argv[1] : DIR_LOC DEF_INPUT); + std::string csOutputFileName(argc > 2 ? argv[2] : DEF_OUTPUT); + std::cout << "Adding some PDE Elements to file " << csInputFileName.c_str() + << " and saving as " << csOutputFileName.c_str() << std::endl; + + APDFLDoc document(csInputFileName.c_str(), true); + + // Step 1) Set up the font for the text to be displayed. + + PDEFontAttrs attrs; + memset(&attrs, 0, sizeof(attrs)); + attrs.name = ASAtomFromString("CourierStd"); + attrs.type = ASAtomFromString("Type1"); + // Get the corresponding system font. + PDSysFont sysFont = PDFindSysFont(&attrs, sizeof(attrs), kPDSysFontMatchFontType); + + PDSysFontGetAttrs(sysFont, &attrs, sizeof(PDEFontAttrs)); + + // Check if font is embeddable. + PDEFont courierStdFont = NULL; + if (attrs.cantEmbed != 0) { + std::cerr << "Font " << ASAtomGetString(attrs.name) << " can not be embedded"; + } else { + // Create font from the system font and embed. + courierStdFont = PDEFontCreateFromSysFont(sysFont, kPDEFontCreateEmbedded); + } + + // Step 2) Set up the content to be added to the document. Elements are added to the page at + // X and Y values starting from the bottom left corner. + + // Text that will be displayed on page + std::string textToDisplay = "Here is some text in the CourierStd font, using both PDEText " + "and PDEFont."; + + PDEGraphicState gState; + memset(&gState, 0, sizeof(gState)); + + PDEDefaultGState(&gState, sizeof(gState)); // Set the graphics state to default values + + PDETextState tState; + memset(&tState, 0, sizeof(tState)); + + // Transformation matrix for text which determines location of the text on page. + ASDoubleMatrix textMatrix; + + memset(&textMatrix, 0, sizeof(textMatrix)); + textMatrix.a = 10; // Set font width and height. + textMatrix.d = 10; // Set font point size. + textMatrix.h = 72 * 0.6; // x coordinate on page (72 pixels = 1 inch). + textMatrix.v = 72 * 8; // y coordinate on page. + + PDEText pdeText = PDETextCreate(); // Create a new text run. + + // Adding the text run to the PDE text object + PDETextAddEx(pdeText, // Text container to add to + kPDETextRun, // kPDETextRun or kPDETextChar as appropriate + 0, // The index after which to add the text run + (Uns8 *)textToDisplay.c_str(), // Text to add + textToDisplay.length(), // Length of text + courierStdFont, // Font to apply to text + &gState, sizeof(gState), // Graphic state and its size + &tState, sizeof(tState), // Text state and its size + &textMatrix, // Transformation matrix for text + NULL); // Stroke matrix for the line width when stroking text + + textMatrix.v = 72 * 7; // y coordinate on page. + textToDisplay = "Below is a PDEPath rectangle. "; + + // Adding the text run to the PDE text object + PDETextAddEx(pdeText, // Text container to add to. + kPDETextRun, // kPDETextRun or kPDETextChar as appropriate + 0, // The index after which to add the text run. + (Uns8 *)textToDisplay.c_str(), // Text to add. + textToDisplay.length(), // Length of text + courierStdFont, // Font to apply to text. + &gState, sizeof(gState), // Graphic state and its size. + &tState, sizeof(tState), // Text state and its size. + &textMatrix, // Transformation matrix for text. + NULL); // Stroke matrix for the line width when stroking text. + + // Determine the needed flags for embedding and call the appropriate routines for doing so. + PDEFontEmbedNow(courierStdFont, PDDocGetCosDoc(document.pdDoc)); + + // Cook up a blue rectangle... + PDEPath rect = PathRect(ASFloatToFixed(72 * 3.25), ASInt32ToFixed(72 * 4), ASInt32ToFixed(72 * 2), + ASInt32ToFixed(72 * 2), 46, fixedZero, fixedZero, fixedOne); + + // Step 3) Acquire PDEContent and add elements to the page. PDPage pdPage = PDDocAcquirePage(document.pdDoc, 0); PDEContent pdeContent = PDPageAcquirePDEContent(pdPage, 0); - //Add the rectangle to the page content. - PDEContentAddElem(pdeContent, kPDEAfterLast, (PDEElement)rect); - //Add the text into page content. + // Add the rectangle to the page content. + PDEContentAddElem(pdeContent, kPDEAfterLast, (PDEElement)rect); + // Add the text into page content. PDEContentAddElem(pdeContent, kPDEAfterLast, (PDEElement)pdeText); - //Set the content back into the page - PDPageSetPDEContentCanRaise(pdPage, NULL); - document.saveDoc ( csOutputFileName.c_str(), PDSaveFull | PDSaveLinearized); + // Set the content back into the page + PDPageSetPDEContentCanRaise(pdPage, NULL); + document.saveDoc(csOutputFileName.c_str(), PDSaveFull | PDSaveLinearized); - //Release all objects + // Release all objects PDPageReleasePDEContent(pdPage, NULL); PDPageRelease(pdPage); PDERelease((PDEObject)pdeText); PDERelease((PDEObject)rect); PDERelease((PDEObject)courierStdFont); - PDERelease(reinterpret_cast(gState.strokeColorSpec.space)); + PDERelease(reinterpret_cast(gState.strokeColorSpec.space)); PDERelease(reinterpret_cast(gState.fillColorSpec.space)); - -HANDLER - errCode = ERRORCODE; + + HANDLER + errCode = ERRORCODE; libInit.displayError(errCode); -END_HANDLER + END_HANDLER - return errCode; + return errCode; } // Helper function: Creates a PDEPath object from supplied parameters -PDEPath PathRect(ASFixed x, ASFixed y, ASFixed width, ASFixed height, - int lineWidth, ASFixed r, ASFixed g, ASFixed b) -{ - //Create the PDEPath object that will be used to draw a rectangle. - PDEPath rectangle = PDEPathCreate(); - - //Set the paint operation to Stroke for the path. +PDEPath PathRect(ASFixed x, ASFixed y, ASFixed width, ASFixed height, int lineWidth, ASFixed r, + ASFixed g, ASFixed b) { + // Create the PDEPath object that will be used to draw a rectangle. + PDEPath rectangle = PDEPathCreate(); + + // Set the paint operation to Stroke for the path. PDEPathSetPaintOp(rectangle, kPDEStroke); - //PDEColorValue color components for the RGB color space. + // PDEColorValue color components for the RGB color space. PDEColorValue strokeClrValue; - memset(&strokeClrValue, 0, sizeof (PDEColorValue)); + memset(&strokeClrValue, 0, sizeof(PDEColorValue)); strokeClrValue.color[0] = ASInt32ToFixed(r); strokeClrValue.color[1] = ASInt32ToFixed(g); strokeClrValue.color[2] = ASInt32ToFixed(b); - //Use RGB color space + // Use RGB color space PDEColorSpace clrSpace; - clrSpace = PDEColorSpaceCreateFromName(ASAtomFromString("DeviceRGB")); + clrSpace = PDEColorSpaceCreateFromName(ASAtomFromString("DeviceRGB")); - //Assign fill/stroke values to the appropriate PDEColorSpec. + // Assign fill/stroke values to the appropriate PDEColorSpec. PDEColorSpec strokeClrSpec; - strokeClrSpec.space = clrSpace; + strokeClrSpec.space = clrSpace; strokeClrSpec.value = strokeClrValue; // Create the graphics state object as per specs PDEGraphicState gState; - memset(&gState, 0, sizeof (PDEGraphicState)); + memset(&gState, 0, sizeof(PDEGraphicState)); gState.strokeColorSpec = strokeClrSpec; gState.lineWidth = ASInt32ToFixed(lineWidth); gState.miterLimit = fixedTen; gState.flatness = fixedOne; // Set graphics state to the path to give it the color and size of the rectange. - PDEElementSetGState((PDEElement)rectangle, &gState, sizeof (PDEGraphicState)); + PDEElementSetGState((PDEElement)rectangle, &gState, sizeof(PDEGraphicState)); // Prepare Array structure for pathData, and assign to object - ASFixed pathData[5]; + ASFixed pathData[5]; pathData[0] = kPDERect; pathData[1] = x; pathData[2] = y; pathData[3] = width; pathData[4] = height; - PDEPathSetData(rectangle, pathData, sizeof (pathData)); - - //Released objects - PDERelease((PDEObject)clrSpace); - + PDEPathSetData(rectangle, pathData, sizeof(pathData)); + + // Released objects + PDERelease((PDEObject)clrSpace); + return rectangle; } diff --git a/CPlusPlus/Sample_Source/ContentCreation/CreateBookmarks/CreateBookmarks.cpp b/CPlusPlus/Sample_Source/ContentCreation/CreateBookmarks/CreateBookmarks.cpp index d3852250..dda3d0aa 100644 --- a/CPlusPlus/Sample_Source/ContentCreation/CreateBookmarks/CreateBookmarks.cpp +++ b/CPlusPlus/Sample_Source/ContentCreation/CreateBookmarks/CreateBookmarks.cpp @@ -4,14 +4,14 @@ // For complete copyright information, see: // http://dev.datalogics.com/adobe-pdf-library/adobe-pdf-library-c-language-interface/license-for-downloaded-pdf-samples/ // -// A bookmark in a PDF document labels a place within the PDF document to serve as a destination, often a -// heading or a graphic. If you manually add a bookmark to a PDF, you can create a link elsewhere in the same -// PDF document and connect it to that bookmark. When the reader clicks on that link the viewer will take the -// reader to the place in the PDF where that bookmark is found. +// A bookmark in a PDF document labels a place within the PDF document to serve as a destination, +// often a heading or a graphic. If you manually add a bookmark to a PDF, you can create a link +// elsewhere in the same PDF document and connect it to that bookmark. When the reader clicks on +// that link the viewer will take the reader to the place in the PDF where that bookmark is found. // -// This sample demonstrates how to add a bookmark to a PDF documnent. It creates a parent bookmark in Korean -// via Unicode (bookmark 1), and then creates a child bookmark under that (bookmark 1.1). The program saves -// the PDF document as an output file in the current directory. +// This sample demonstrates how to add a bookmark to a PDF documnent. It creates a parent bookmark +// in Korean via Unicode (bookmark 1), and then creates a child bookmark under that (bookmark 1.1). +// The program saves the PDF document as an output file in the current directory. // #include @@ -20,105 +20,98 @@ #include "APDFLDoc.h" #define INPUT_DIR "../../../../Resources/Sample_Input/" -#define INPUT_FILE "SixPages.pdf" +#define INPUT_FILE "SixPages.pdf" #define OUTPUT_FILE "CreateBookmarks-out.pdf" #define PARENTBOOKMARK "bookmark 1" #define CHILDBOOKMARK "bookmark 1.1" -#define dstPageNumParent 0 -#define dstPageNumChild 1 +#define dstPageNumParent 0 +#define dstPageNumChild 1 -int main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { // Initialize the library APDFLib libInit; - if (libInit.isValid() == false) - { + if (libInit.isValid() == false) { ASErrorCode errCode = libInit.getInitError(); - APDFLib::displayError ( errCode ); + APDFLib::displayError(errCode); return errCode; } std::string csInputFileName(argc > 1 ? argv[1] : INPUT_DIR INPUT_FILE); std::string csOutputFileName(argc > 2 ? argv[2] : OUTPUT_FILE); - std::cout << "Adding bookmarks to " << csInputFileName.c_str() << ", writing to " << csOutputFileName.c_str() << std::endl; - -DURING - - // Open the input document - APDFLDoc apdflDoc ( csInputFileName.c_str(), true ); - PDDoc pdDoc1 = apdflDoc.getPDDoc(); - - // Get bookmark root. Return value is valid even if bookmark root is empty. - // Then add new child or siblings. - PDBookmark rootBm = PDDocGetBookmarkRoot(pdDoc1); - - // Set the parent title in Unicode - unsigned char korTitle[] = {0xFE, 0xFF, 0xB3, 0x00, 0xD5, 0x5C, 0xBB, 0xFC, 0xAD, 0x6D, 0x00, 0x00}; - - // Use reinterpret_cast to allow korTitle to be 'unsigned', necessary to avoid the C4309 warning - PDBookmark parentBm = PDBookmarkAddNewChild (rootBm, reinterpret_cast(korTitle) ); - - // Acquire PDPage of the bookmark destination from PDDoc - PDPage dstPageParent = PDDocAcquirePage(pdDoc1, dstPageNumParent); - - // Initialize parameters for the destination PDPage - ASAtom fitType = ASAtomFromString("Fit"); - ASFixed zoom = 2; - ASFixedRect destRect = { 0, Int16ToFixed(5 * 72), Int16ToFixed(8 * 72), 0 }; - - // Create view of the destination PDPage - PDViewDestination destParent = PDViewDestCreate(pdDoc1, dstPageParent, fitType, &destRect, zoom, dstPageNumParent); - - // Create new PDAction and set bookmark action - if(PDViewDestIsValid(destParent)) - { - PDAction pdActionParent = PDActionNewFromDest(pdDoc1, destParent, pdDoc1); - if (PDActionIsValid(pdActionParent)) - { - PDBookmarkSetAction(parentBm, pdActionParent); + std::cout << "Adding bookmarks to " << csInputFileName.c_str() << ", writing to " + << csOutputFileName.c_str() << std::endl; + + DURING + + // Open the input document + APDFLDoc apdflDoc(csInputFileName.c_str(), true); + PDDoc pdDoc1 = apdflDoc.getPDDoc(); + + // Get bookmark root. Return value is valid even if bookmark root is empty. + // Then add new child or siblings. + PDBookmark rootBm = PDDocGetBookmarkRoot(pdDoc1); + + // Set the parent title in Unicode + unsigned char korTitle[] = {0xFE, 0xFF, 0xB3, 0x00, 0xD5, 0x5C, + 0xBB, 0xFC, 0xAD, 0x6D, 0x00, 0x00}; + + // Use reinterpret_cast to allow korTitle to be 'unsigned', necessary to avoid the C4309 warning + PDBookmark parentBm = PDBookmarkAddNewChild(rootBm, reinterpret_cast(korTitle)); + + // Acquire PDPage of the bookmark destination from PDDoc + PDPage dstPageParent = PDDocAcquirePage(pdDoc1, dstPageNumParent); + + // Initialize parameters for the destination PDPage + ASAtom fitType = ASAtomFromString("Fit"); + ASFixed zoom = 2; + ASFixedRect destRect = {0, Int16ToFixed(5 * 72), Int16ToFixed(8 * 72), 0}; + + // Create view of the destination PDPage + PDViewDestination destParent = + PDViewDestCreate(pdDoc1, dstPageParent, fitType, &destRect, zoom, dstPageNumParent); + + // Create new PDAction and set bookmark action + if (PDViewDestIsValid(destParent)) { + PDAction pdActionParent = PDActionNewFromDest(pdDoc1, destParent, pdDoc1); + if (PDActionIsValid(pdActionParent)) { + PDBookmarkSetAction(parentBm, pdActionParent); + } else { + std::cout << "PDAction not valid" << std::endl; + return -1; + } } - else - { - std::cout << "PDAction not valid" << std::endl; - return -1; - } - } - // Now create a child bookmark for this parent - PDBookmark childBm = PDBookmarkAddNewChild (parentBm, CHILDBOOKMARK); - PDPage dstPageChild = PDDocAcquirePage(pdDoc1, dstPageNumChild); + // Now create a child bookmark for this parent + PDBookmark childBm = PDBookmarkAddNewChild(parentBm, CHILDBOOKMARK); + PDPage dstPageChild = PDDocAcquirePage(pdDoc1, dstPageNumChild); - fitType = ASAtomFromString ("FitH"); - zoom = 5; + fitType = ASAtomFromString("FitH"); + zoom = 5; - PDViewDestination destChild = PDViewDestCreate(pdDoc1, dstPageChild, fitType, &destRect, zoom, dstPageNumChild); + PDViewDestination destChild = + PDViewDestCreate(pdDoc1, dstPageChild, fitType, &destRect, zoom, dstPageNumChild); - if(PDViewDestIsValid(destChild)) - { - PDAction pdActionChild = PDActionNewFromDest(pdDoc1, destChild, pdDoc1); - if (PDActionIsValid(pdActionChild)) - { - PDBookmarkSetAction(childBm, pdActionChild); + if (PDViewDestIsValid(destChild)) { + PDAction pdActionChild = PDActionNewFromDest(pdDoc1, destChild, pdDoc1); + if (PDActionIsValid(pdActionChild)) { + PDBookmarkSetAction(childBm, pdActionChild); + } else { + std::cout << "PDAction not valid (child)" << std::endl; + return -2; + } } - else - { - std::cout << "PDAction not valid (child)" << std::endl; - return -2; - } - } - // Save document to output file - apdflDoc.saveDoc ( csOutputFileName.c_str() ); - PDPageRelease(dstPageParent); - PDPageRelease(dstPageChild); + // Save document to output file + apdflDoc.saveDoc(csOutputFileName.c_str()); + PDPageRelease(dstPageParent); + PDPageRelease(dstPageChild); -HANDLER - APDFLib::displayError(ERRORCODE); - return ERRORCODE; -END_HANDLER + HANDLER + APDFLib::displayError(ERRORCODE); + return ERRORCODE; + END_HANDLER return 0; } - diff --git a/CPlusPlus/Sample_Source/ContentCreation/CreateLayers/CreateLayers.cpp b/CPlusPlus/Sample_Source/ContentCreation/CreateLayers/CreateLayers.cpp index 4d786874..ad3982e6 100644 --- a/CPlusPlus/Sample_Source/ContentCreation/CreateLayers/CreateLayers.cpp +++ b/CPlusPlus/Sample_Source/ContentCreation/CreateLayers/CreateLayers.cpp @@ -9,7 +9,7 @@ // // Command-line: (Both optional) // -// For more detail see the description of the CreateLayers sample program on our Developer’s site, +// For more detail see the description of the CreateLayers sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#createlayers #include @@ -25,181 +25,180 @@ #define DEF_OUTPUT "CreateLayers-out.pdf" -//A function that places text onto a given position in a PDF. +// A function that places text onto a given position in a PDF. /* static */ PDEText textMaker(std::string displayText, double xPos, double yPos); -int main(int argc, char** argv) -{ +int main(int argc, char **argv) { APDFLib libInit; ASErrorCode errCode = 0; - if (libInit.isValid() == false) - { + if (libInit.isValid() == false) { errCode = libInit.getInitError(); std::cout << "Initialization failed with code " << errCode << std::endl; return libInit.getInitError(); } - std::string csOutputFileName ( argc > 1 ? argv[1] : DEF_OUTPUT ); - std::cout << "Creating new document " << csOutputFileName.c_str() << - " and inserting 2 layers..." << std::endl; + std::string csOutputFileName(argc > 1 ? argv[1] : DEF_OUTPUT); + std::cout << "Creating new document " << csOutputFileName.c_str() + << " and inserting 2 layers..." << std::endl; -DURING + DURING -// Step 1) Create a pdf document and obtain a reference to it's first page, and its' content + // Step 1) Create a pdf document and obtain a reference to it's first page, and its' content - APDFLDoc doc; + APDFLDoc doc; - //Insert a standard 8.5 inch x 11 inch page into the document. - doc.insertPage ( ASFloatToFixed ( 8.5 * 72 ), ASFloatToFixed ( 11 * 72 ), PDBeforeFirstPage ); - PDPage page = doc.getPage(0); - PDEContent pageContent = PDPageAcquirePDEContent(page, NULL); + // Insert a standard 8.5 inch x 11 inch page into the document. + doc.insertPage(ASFloatToFixed(8.5 * 72), ASFloatToFixed(11 * 72), PDBeforeFirstPage); + PDPage page = doc.getPage(0); + PDEContent pageContent = PDPageAcquirePDEContent(page, NULL); -// Step 2) Set up the optional content groups, commonly referred to as layers. + // Step 2) Set up the optional content groups, commonly referred to as layers. - //Create optional content groups (Layers) for texts and annotations. - PDOCG optionalGroupText = PDOCGCreate(doc.pdDoc, ASTextFromPDText("TextLayer")); - PDOCG optionalGroupAnnot = PDOCGCreate(doc.pdDoc, ASTextFromPDText("AnnotationLayer")); + // Create optional content groups (Layers) for texts and annotations. + PDOCG optionalGroupText = PDOCGCreate(doc.pdDoc, ASTextFromPDText("TextLayer")); + PDOCG optionalGroupAnnot = PDOCGCreate(doc.pdDoc, ASTextFromPDText("AnnotationLayer")); - //Set the their initial state to visible. - PDOCConfig ocConfig = PDDocGetOCConfig(doc.pdDoc); - PDOCGSetInitialState(optionalGroupText, ocConfig, true); - PDOCGSetInitialState(optionalGroupAnnot, ocConfig, true); + // Set the their initial state to visible. + PDOCConfig ocConfig = PDDocGetOCConfig(doc.pdDoc); + PDOCGSetInitialState(optionalGroupText, ocConfig, true); + PDOCGSetInitialState(optionalGroupAnnot, ocConfig, true); - CosObj order; //The order of the optional content. - PDOCConfigGetOCGOrder(ocConfig, &order); //Find the order. - ASInt32 cosObjectTotal = CosArrayLength(order); //Find the total cosObjects. + CosObj order; // The order of the optional content. + PDOCConfigGetOCGOrder(ocConfig, &order); // Find the order. + ASInt32 cosObjectTotal = CosArrayLength(order); // Find the total cosObjects. - //Insert the layers as a cosObject in the pdf. - CosArrayInsert(order, cosObjectTotal, PDOCGGetCosObj(optionalGroupText)); - CosArrayInsert(order, cosObjectTotal + 1, PDOCGGetCosObj(optionalGroupAnnot)); + // Insert the layers as a cosObject in the pdf. + CosArrayInsert(order, cosObjectTotal, PDOCGGetCosObj(optionalGroupText)); + CosArrayInsert(order, cosObjectTotal + 1, PDOCGGetCosObj(optionalGroupAnnot)); - //Put the new order back as a part of the pdf's configuration. - PDOCConfigSetOCGOrder(ocConfig, order); + // Put the new order back as a part of the pdf's configuration. + PDOCConfigSetOCGOrder(ocConfig, order); - //Create a layer array in order to properly pass the layer into the membership dictionary creation function. - PDOCG pdDocArrayText[2]; - pdDocArrayText[0] = optionalGroupText; - pdDocArrayText[1] = NULL; + // Create a layer array in order to properly pass the layer into the membership dictionary creation function. + PDOCG pdDocArrayText[2]; + pdDocArrayText[0] = optionalGroupText; + pdDocArrayText[1] = NULL; - //Obtain the membership dictionary of the text layer. - PDOCMD optionalGroupMDText = PDOCMDCreate(doc.pdDoc, pdDocArrayText, kOCMDVisibility_AllOn); + // Obtain the membership dictionary of the text layer. + PDOCMD optionalGroupMDText = PDOCMDCreate(doc.pdDoc, pdDocArrayText, kOCMDVisibility_AllOn); - //Create a layer array in order to properly pass the layer into the membership dictionary creation function. - PDOCG pdDocArrayAnnot[2]; - pdDocArrayAnnot[0] = optionalGroupAnnot; - pdDocArrayAnnot[1] = NULL; + // Create a layer array in order to properly pass the layer into the membership dictionary creation function. + PDOCG pdDocArrayAnnot[2]; + pdDocArrayAnnot[0] = optionalGroupAnnot; + pdDocArrayAnnot[1] = NULL; - //Obtain the membership dictionary of the annotation layer. - PDOCMD optionalGroupMDAnnot = PDOCMDCreate(doc.pdDoc, pdDocArrayAnnot, kOCMDVisibility_AllOn); + // Obtain the membership dictionary of the annotation layer. + PDOCMD optionalGroupMDAnnot = PDOCMDCreate(doc.pdDoc, pdDocArrayAnnot, kOCMDVisibility_AllOn); -// Step 3) Add text to the page and set what layer they belong to. + // Step 3) Add text to the page and set what layer they belong to. - //By calling the textMaker function, place the following text at the given location. - PDEText displayText1 = textMaker("All the text on this page will be placed in it's own layer", 72 * 1, 72 * 10); - PDEText displayText2 = textMaker("Whereas the attachments will appear in a separate layer", 72 * 1, 72 * 9.75); - PDEText displayText3 = textMaker("There will be an annotation to the right.", 72 * 1, 72 * 8); - PDEText displayText4 = textMaker("There will be an annotation to the right.", 72 * 1, 72 * 7); + // By calling the textMaker function, place the following text at the given location. + PDEText displayText1 = + textMaker("All the text on this page will be placed in it's own layer", 72 * 1, 72 * 10); + PDEText displayText2 = + textMaker("Whereas the attachments will appear in a separate layer", 72 * 1, 72 * 9.75); + PDEText displayText3 = textMaker("There will be an annotation to the right.", 72 * 1, 72 * 8); + PDEText displayText4 = textMaker("There will be an annotation to the right.", 72 * 1, 72 * 7); - PDEContent texts = PDEContentCreate(); + PDEContent texts = PDEContentCreate(); - //Add the created text objects to the page's content. - PDEContentAddElem(texts, kPDEAfterLast, (PDEElement)displayText1); - PDEContentAddElem(texts, kPDEAfterLast, (PDEElement)displayText2); - PDEContentAddElem(texts, kPDEAfterLast, (PDEElement)displayText3); - PDEContentAddElem(texts, kPDEAfterLast, (PDEElement)displayText4); + // Add the created text objects to the page's content. + PDEContentAddElem(texts, kPDEAfterLast, (PDEElement)displayText1); + PDEContentAddElem(texts, kPDEAfterLast, (PDEElement)displayText2); + PDEContentAddElem(texts, kPDEAfterLast, (PDEElement)displayText3); + PDEContentAddElem(texts, kPDEAfterLast, (PDEElement)displayText4); - //Create an empty container for the text. - PDEContainer textContainer = PDEContainerCreate(ASAtomFromString("Texts"), NULL, false); + // Create an empty container for the text. + PDEContainer textContainer = PDEContainerCreate(ASAtomFromString("Texts"), NULL, false); - // Place them into this container - PDEContainerSetContent(textContainer, texts); + // Place them into this container + PDEContainerSetContent(textContainer, texts); - //Add the text to the page's content - PDEContentAddElem(pageContent, kPDEAfterLast, (PDEElement)textContainer); + // Add the text to the page's content + PDEContentAddElem(pageContent, kPDEAfterLast, (PDEElement)textContainer); - //Set the container's membership dictionary to the text layer. - PDEElementSetOCMD((PDEElement)textContainer, optionalGroupMDText); + // Set the container's membership dictionary to the text layer. + PDEElementSetOCMD((PDEElement)textContainer, optionalGroupMDText); - //Set the content back into the page. - PDPageSetPDEContentCanRaise(page, NULL); + // Set the content back into the page. + PDPageSetPDEContentCanRaise(page, NULL); - //Release used objects - PDERelease(reinterpret_cast(displayText1)); - PDERelease(reinterpret_cast(displayText2)); - PDERelease(reinterpret_cast(displayText3)); - PDERelease(reinterpret_cast(displayText4)); - PDERelease(reinterpret_cast(textContainer)); + // Release used objects + PDERelease(reinterpret_cast(displayText1)); + PDERelease(reinterpret_cast(displayText2)); + PDERelease(reinterpret_cast(displayText3)); + PDERelease(reinterpret_cast(displayText4)); + PDERelease(reinterpret_cast(textContainer)); -// Step 4) Add annotations to the page and set the layer they belong to. + // Step 4) Add annotations to the page and set the layer they belong to. - //Set up the bounds for the first annotation. 72 pixels represents one inch. - ASFixedRect annotLocation; - annotLocation.left = ASFloatToFixed(5.50 * 72); - annotLocation.right = ASFloatToFixed(5.00 * 72); - annotLocation.top = ASFloatToFixed(8.20 * 72); - annotLocation.bottom = ASFloatToFixed(7.70 * 72); + // Set up the bounds for the first annotation. 72 pixels represents one inch. + ASFixedRect annotLocation; + annotLocation.left = ASFloatToFixed(5.50 * 72); + annotLocation.right = ASFloatToFixed(5.00 * 72); + annotLocation.top = ASFloatToFixed(8.20 * 72); + annotLocation.bottom = ASFloatToFixed(7.70 * 72); - //Create the annotation at the location. - PDAnnot newAnnot = PDPageCreateAnnot(page, ASAtomFromString("FileAttachment"), &annotLocation); + // Create the annotation at the location. + PDAnnot newAnnot = PDPageCreateAnnot(page, ASAtomFromString("FileAttachment"), &annotLocation); - //Add the annotation to the page. -2 means to add to the end of the array. - PDPageAddAnnot(page, -2, newAnnot); + // Add the annotation to the page. -2 means to add to the end of the array. + PDPageAddAnnot(page, -2, newAnnot); - //Set the annotation to the annotation layer. - PDAnnotSetOCMD(newAnnot, optionalGroupMDAnnot); + // Set the annotation to the annotation layer. + PDAnnotSetOCMD(newAnnot, optionalGroupMDAnnot); - //Move the bounds for the second annotation. - annotLocation.left = ASFloatToFixed(5.50 * 72); - annotLocation.right = ASFloatToFixed(5.00 * 72); - annotLocation.top = ASFloatToFixed(7.20 * 72); - annotLocation.bottom = ASFloatToFixed(6.70 * 72); + // Move the bounds for the second annotation. + annotLocation.left = ASFloatToFixed(5.50 * 72); + annotLocation.right = ASFloatToFixed(5.00 * 72); + annotLocation.top = ASFloatToFixed(7.20 * 72); + annotLocation.bottom = ASFloatToFixed(6.70 * 72); - //Create the second annotation. - PDAnnot newAnnot2 = PDPageCreateAnnot(page, ASAtomFromString("FileAttachment"), &annotLocation); + // Create the second annotation. + PDAnnot newAnnot2 = PDPageCreateAnnot(page, ASAtomFromString("FileAttachment"), &annotLocation); - //Set the annotation to the annotation layer. - PDAnnotSetOCMD(newAnnot2, optionalGroupMDAnnot); + // Set the annotation to the annotation layer. + PDAnnotSetOCMD(newAnnot2, optionalGroupMDAnnot); - //Add the annotation to the page. - PDPageAddAnnot(page, -2, newAnnot2); + // Add the annotation to the page. + PDPageAddAnnot(page, -2, newAnnot2); -// Step 5) Save the output document and exit. + // Step 5) Save the output document and exit. - //Release objects no longer in use - PDPageReleasePDEContent(page, NULL); - PDPageRelease(page); + // Release objects no longer in use + PDPageReleasePDEContent(page, NULL); + PDPageRelease(page); - doc.saveDoc ( csOutputFileName.c_str(), PDSaveFull | PDSaveLinearized); + doc.saveDoc(csOutputFileName.c_str(), PDSaveFull | PDSaveLinearized); -HANDLER - errCode = ERRORCODE; - libInit.displayError(errCode); -END_HANDLER + HANDLER + errCode = ERRORCODE; + libInit.displayError(errCode); + END_HANDLER return errCode; } // Helper function to create a PDEText object -/* static */ PDEText textMaker(std::string displayText, double xPos, double yPos) -{ +/* static */ PDEText textMaker(std::string displayText, double xPos, double yPos) { PDEFontAttrs fontAttrs; memset(&fontAttrs, 0, sizeof(fontAttrs)); fontAttrs.name = ASAtomFromString("CourierStd"); fontAttrs.type = ASAtomFromString("Type1"); - //Locate the system font that corresponds to the PDEFontAttrs struct we just set. + // Locate the system font that corresponds to the PDEFontAttrs struct we just set. PDSysFont sysFont = PDFindSysFont(&fontAttrs, sizeof(fontAttrs), 0); - //Create the CourierStd Type1 font with embed flag set. + // Create the CourierStd Type1 font with embed flag set. PDEFont courierFont = PDEFontCreateFromSysFont(sysFont, kPDEFontCreateEmbedded); - //Transformation matrix for text which determines location of the text on page. - ASDoubleMatrix textMatrix; + // Transformation matrix for text which determines location of the text on page. + ASDoubleMatrix textMatrix; memset(&textMatrix, 0, sizeof(textMatrix)); - textMatrix.a = 10; // Font width and height. - textMatrix.d = 10; // Font point size. - textMatrix.h = xPos; // x coordinate on page (72 pixels = 1 inch). - textMatrix.v = yPos; // y coordinate on page. + textMatrix.a = 10; // Font width and height. + textMatrix.d = 10; // Font point size. + textMatrix.h = xPos; // x coordinate on page (72 pixels = 1 inch). + textMatrix.v = yPos; // y coordinate on page. // Create a Graphics State object with defaults PDEGraphicState gState; @@ -209,21 +208,20 @@ END_HANDLER PDEText textObj = PDETextCreate(); PDETextState tState; - - //Adding the text run to the PDE text object. - PDETextAddEx ( - textObj, // Text container to add to. - kPDETextRun, // kPDETextRun or kPDETextChar as appropriate - 0, // The index after which to add the text run. - (Uns8 *)displayText.c_str(), // Text to add. - displayText.length(), // Length of text. - courierFont, // Font to apply to text. - &gState, sizeof(gState), // PDEGraphicState and its size. - &tState, 0, // Text state and its size. - &textMatrix, // Matrix containing size and location for the text. - NULL); // Stroke matrix for the line width when stroking text. - - //Release used objects. + + // Adding the text run to the PDE text object. + PDETextAddEx(textObj, // Text container to add to. + kPDETextRun, // kPDETextRun or kPDETextChar as appropriate + 0, // The index after which to add the text run. + (Uns8 *)displayText.c_str(), // Text to add. + displayText.length(), // Length of text. + courierFont, // Font to apply to text. + &gState, sizeof(gState), // PDEGraphicState and its size. + &tState, 0, // Text state and its size. + &textMatrix, // Matrix containing size and location for the text. + NULL); // Stroke matrix for the line width when stroking text. + + // Release used objects. PDERelease(reinterpret_cast(courierFont)); PDERelease(reinterpret_cast(gState.strokeColorSpec.space)); PDERelease(reinterpret_cast(gState.fillColorSpec.space)); diff --git a/CPlusPlus/Sample_Source/ContentCreation/CreateTransparency/CreateTransparency.cpp b/CPlusPlus/Sample_Source/ContentCreation/CreateTransparency/CreateTransparency.cpp index 84d280f5..68ba0541 100644 --- a/CPlusPlus/Sample_Source/ContentCreation/CreateTransparency/CreateTransparency.cpp +++ b/CPlusPlus/Sample_Source/ContentCreation/CreateTransparency/CreateTransparency.cpp @@ -13,7 +13,7 @@ // See ISO 32000, table 136, for more information, available here: // http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#page=332 // -// For more detail see the description of the CreateTransparency sample program on our Developer’s site, +// For more detail see the description of the CreateTransparency sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#createtransparency #include @@ -31,319 +31,311 @@ #define DEF_OUTPUT "CreateTransparency-out.pdf" -//The number of shapes in each color blending group. We've gone with a triad. -#define NUM_BLENDING_SHAPES 3 +// The number of shapes in each color blending group. We've gone with a triad. +#define NUM_BLENDING_SHAPES 3 /* static */ PDEForm contentToForm(PDEContent content, ASInt32 formType, PDDoc document); -int main(int argc, char** argv) -{ +int main(int argc, char **argv) { APDFLib libInit; ASErrorCode errCode = 0; - if (libInit.isValid() == false) - { + if (libInit.isValid() == false) { errCode = libInit.getInitError(); std::cout << "Initialization failed with code " << errCode << std::endl; return libInit.getInitError(); } - - std::string csOutputFileName ( argc > 1 ? argv[1] : DEF_OUTPUT ); + + std::string csOutputFileName(argc > 1 ? argv[1] : DEF_OUTPUT); std::cout << "Creating " << csOutputFileName.c_str() << " with 13 pages demonstrating " << "blending modes" << std::endl; -DURING - -//Step 1) Create and title a page for each color blending mode. - - APDFLDoc doc; - - ASFixed pageLength = ASFloatToFixed(10.0 * 72.0); // 1 inch == 72 pixels - ASFixed pageHeight = ASFloatToFixed(4.25 * 72.0); - - // Compute page center, we'll need these to place the triads later on. - ASFixed pageCenter_X = (pageLength / 2); - ASFixed pageCenter_Y = (pageHeight / 2); - - //The center point of the left half of the page. - ASFixed leftHalfCenter_X = (pageCenter_X / 2); - ASFixed leftHalfCenter_Y = pageCenter_Y; - - //The center point of the right half of the page. - ASFixed rightHalfCenter_X = pageCenter_X + leftHalfCenter_X; - ASFixed rightHalfCenter_Y = pageCenter_Y; - - //All twelve blend modes available in APDFL. - std::vector vBlendModes; - vBlendModes.push_back ( "Opaque (None)" ); - vBlendModes.push_back ( "Normal" ); - vBlendModes.push_back ( "Multiply" ); - vBlendModes.push_back ( "Screen" ); - vBlendModes.push_back ( "Overlay" ); - vBlendModes.push_back ( "Darken" ); - vBlendModes.push_back ( "Lighten" ); - vBlendModes.push_back ( "ColorDodge" ); - vBlendModes.push_back ( "ColorBurn" ); - vBlendModes.push_back ( "HardLight" ); - vBlendModes.push_back ( "SoftLight" ); - vBlendModes.push_back ( "Difference" ); - vBlendModes.push_back ( "Exclusion" ); - - int numPages = vBlendModes.size(); // A page to demonstrate each blend mode - - //Now we will title each page with the name of its associated blending mode. - PDEFontAttrs fontAttrs; - memset(&fontAttrs, 0, sizeof(fontAttrs)); - fontAttrs.name = ASAtomFromString("CourierStd"); - fontAttrs.type = ASAtomFromString("Type1"); - - PDSysFont sysFont = PDFindSysFont(&fontAttrs, sizeof(fontAttrs), 0); - PDEFont pdeFont = PDEFontCreateFromSysFont(sysFont, kPDEFontDoNotEmbed); - - //This matrix will determine how the text is displayed. - ASDoubleMatrix textMatrix; - memset(&textMatrix, 0, sizeof(textMatrix)); - ASDouble fontSize = 24.0; // Font size, in points. - textMatrix.a = textMatrix.d = fontSize; // Character width, height - textMatrix.h = (0.25 * 72.0); // 1/4 of an inch from the left margin. - textMatrix.v = (ASFixedToFloat(pageHeight) - (0.20 * 72.00) - fontSize); // 1/5 of an inch from the top margin, - // adjusting for font size. - - //We create a default graphics state to draw the text with. - PDEGraphicState gState; - PDEDefaultGState(&gState,sizeof(gState)); - - //Now create each page, and place each page title. - for (int i = 0; i < numPages; i++) - { - doc.insertPage(pageLength, pageHeight, PDDocGetNumPages(doc.getPDDoc())-1); - - PDEText textObj = PDETextCreate(); - - std::stringstream title; - title << "Blend Mode: " << vBlendModes[i] << "."; - - // Add the text run - PDETextAddEx ( - textObj, // To this object - kPDETextRun, // kPDETextRun vs. kPDETextChar - 0, // Index - (Uns8*)title.str().c_str(), // The text, - strlen(title.str().c_str()), // and its length. - pdeFont, // The font we want used. - &gState,sizeof(gState), // Default the graphics state. - NULL,0, // Default the text state. - &textMatrix, // The size and location of the text. - NULL); // Default the stroke matrix. - - PDPage outPage = doc.getPage(PDDocGetNumPages(doc.getPDDoc())-1); - PDEContent pagecontent = PDPageAcquirePDEContent(outPage, 0); - - //Add the text element to the page's content. - PDEContentAddElem(pagecontent,kPDEBeforeFirst, (PDEElement)(textObj)); - //We're done with the text element now that we've added it. - PDERelease((PDEObject)(textObj)); - //Set the content back into the page. - PDPageSetPDEContentCanRaise(outPage, NULL); - - //We're now done with this page and its contents. - PDPageReleasePDEContent(outPage, 0); - PDPageRelease(outPage); - } - PDERelease((PDEObject)gState.strokeColorSpec.space); - PDERelease((PDEObject)gState.fillColorSpec.space); - PDERelease((PDEObject)pdeFont); - -// Step 2) Define and create a prototype for the basic shape of each triad. - - // Note: PDEForm objects will be used as prototypes because they can group - // different PDEElements together, and for their cloning ability. - - //First we define the shape we'll use as a base. We'll make circles. - - ASFixed circleDiameter = FloatToASFixed(2.0 * 72.0); - ASFixed radius = circleDiameter / 2; - ASFixed threeFourthsRadius = (ASFloatToFixed(3.0f)*radius) / ASFloatToFixed(4.0f); - ASFixed zero = FloatToASFixed ( 0.0 ); - - // Now we want to define how the shapes will be positioned relative to each - // other, by making position deltas (or vectors, if you prefer) for each. - // They'll come out in a nice triangle. - - // shape 1 shape 2 shape 3 - ASFixed delta_x[NUM_BLENDING_SHAPES] = { radius - threeFourthsRadius, zero, (radius/2) - threeFourthsRadius}; - ASFixed delta_y[NUM_BLENDING_SHAPES] = { zero, zero, -radius }; - - // Now we can create the basic shape's prototype. - // We'll put our circle into this content object, which will be converted into a PDEForm object. - PDEContent singleShapeContent = PDEContentCreate(); - - //Make a circle shape. - PDEPath shapePath = PDEPathCreate(); - ASFixed handleLength = FloatToASFixed (ASFixedToFloat (circleDiameter) * 0.66666); - PDEPathSetPaintOp(shapePath, kPDEFill); - PDEPathAddSegment(shapePath, kPDEMoveTo, -radius, 0, 0, 0, 0, 0); - PDEPathAddSegment(shapePath, kPDECurveTo, -radius, handleLength, radius, handleLength, radius, 0); - PDEPathAddSegment(shapePath, kPDECurveTo, radius, -handleLength, -radius, -handleLength, -radius, 0); - - //Give the circle its graphics state. This graphics state will be re-used for the triads. - PDEGraphicState shapeGState; - PDEDefaultGState(&shapeGState, sizeof(PDEGraphicState)); - //We haven't added anything special to this graphics state yet. - shapeGState.wasSetFlags = 0; - PDEElementSetGState((PDEElement)shapePath, &shapeGState, sizeof(shapeGState)); - - //The circle is complete. Add it to our content object. - PDEContentAddElem(singleShapeContent, kPDEBeforeFirst, (PDEElement)shapePath); - PDERelease((PDEObject)shapePath); - - //Convert the content containing our circle into a PDEForm. - PDDoc pdoc = doc.getPDDoc(); - PDEForm singleShape = contentToForm(singleShapeContent, 1, pdoc); //This is the basic shape prototype. - PDERelease((PDEObject)singleShapeContent); - -// Step 3) Create a prototype for the CMYK and RGB triads by triplicating the basic shape. - - //These containers will hold the shapes the CMYK triad and the RGB triad. - // They'll also be converted to PDEForms to create our prototypes. - PDEContent cmykContent = PDEContentCreate(); - PDEContent rgbContent = PDEContentCreate(); - - PDEContent content[2] = {cmykContent, rgbContent}; - PDEContent nextContent; - for (int i = 0; i < 2 ; i++) - { - nextContent = content[i]; - //Set the color space of the next triad. - const char* colorSpace = (nextContent == cmykContent ? "DeviceCMYK" : "DeviceRGB"); - shapeGState.fillColorSpec.space = PDEColorSpaceCreateFromName(ASAtomFromString((colorSpace))); - shapeGState.wasSetFlags = kPDEFillCSpaceWasSet; - - //Give each triad three shapes of different colors, positioned as specified in delta_x and delta_y. - for (int i = 0; i < NUM_BLENDING_SHAPES; ++i) - { - //Clone the basic shape prototype. - PDEForm nextShape = PDEFormCreateClone(singleShape); - - //Set the position for this shape. - ASFixedMatrix shapePosition = { fixedOne, 0, 0, fixedOne, 0, 0 }; - shapePosition.h = delta_x[i]; - shapePosition.v = delta_y[i]; - - //Set the graphics state of this shape. - // The conditional values are used to easily create three shapes of different colors. - shapeGState.fillColorSpec.value.color[0] = (i == 0 ? fixedOne : fixedZero); //Red/Cyan value. - shapeGState.fillColorSpec.value.color[1] = (i == 1 ? fixedOne : fixedZero); //Green/Magenta value. - shapeGState.fillColorSpec.value.color[2] = (i == 2 ? fixedOne : fixedZero); //Blue/Yellow value. - shapeGState.fillColorSpec.value.color[3] = fixedZero; //Not using CMYK's Black - shapeGState.wasSetFlags |= kPDEFillCValueWasSet; - - //Set the position and graphics state of this triad. - PDEElementSetMatrix((PDEElement)nextShape, &shapePosition); - PDEElementSetGState((PDEElement)nextShape, &shapeGState, sizeof(shapeGState)); - - //Add the triad to its content. - PDEContentAddElem(nextContent, kPDEBeforeFirst, (PDEElement)nextShape); - - PDERelease((PDEObject)nextShape); + DURING + + // Step 1) Create and title a page for each color blending mode. + + APDFLDoc doc; + + ASFixed pageLength = ASFloatToFixed(10.0 * 72.0); // 1 inch == 72 pixels + ASFixed pageHeight = ASFloatToFixed(4.25 * 72.0); + + // Compute page center, we'll need these to place the triads later on. + ASFixed pageCenter_X = (pageLength / 2); + ASFixed pageCenter_Y = (pageHeight / 2); + + // The center point of the left half of the page. + ASFixed leftHalfCenter_X = (pageCenter_X / 2); + ASFixed leftHalfCenter_Y = pageCenter_Y; + + // The center point of the right half of the page. + ASFixed rightHalfCenter_X = pageCenter_X + leftHalfCenter_X; + ASFixed rightHalfCenter_Y = pageCenter_Y; + + // All twelve blend modes available in APDFL. + std::vector vBlendModes; + vBlendModes.push_back("Opaque (None)"); + vBlendModes.push_back("Normal"); + vBlendModes.push_back("Multiply"); + vBlendModes.push_back("Screen"); + vBlendModes.push_back("Overlay"); + vBlendModes.push_back("Darken"); + vBlendModes.push_back("Lighten"); + vBlendModes.push_back("ColorDodge"); + vBlendModes.push_back("ColorBurn"); + vBlendModes.push_back("HardLight"); + vBlendModes.push_back("SoftLight"); + vBlendModes.push_back("Difference"); + vBlendModes.push_back("Exclusion"); + + int numPages = vBlendModes.size(); // A page to demonstrate each blend mode + + // Now we will title each page with the name of its associated blending mode. + PDEFontAttrs fontAttrs; + memset(&fontAttrs, 0, sizeof(fontAttrs)); + fontAttrs.name = ASAtomFromString("CourierStd"); + fontAttrs.type = ASAtomFromString("Type1"); + + PDSysFont sysFont = PDFindSysFont(&fontAttrs, sizeof(fontAttrs), 0); + PDEFont pdeFont = PDEFontCreateFromSysFont(sysFont, kPDEFontDoNotEmbed); + + // This matrix will determine how the text is displayed. + ASDoubleMatrix textMatrix; + memset(&textMatrix, 0, sizeof(textMatrix)); + ASDouble fontSize = 24.0; // Font size, in points. + textMatrix.a = textMatrix.d = fontSize; // Character width, height + textMatrix.h = (0.25 * 72.0); // 1/4 of an inch from the left margin. + textMatrix.v = + (ASFixedToFloat(pageHeight) - (0.20 * 72.00) - fontSize); // 1/5 of an inch from the top margin, + // adjusting for font size. + + // We create a default graphics state to draw the text with. + PDEGraphicState gState; + PDEDefaultGState(&gState, sizeof(gState)); + + // Now create each page, and place each page title. + for (int i = 0; i < numPages; i++) { + doc.insertPage(pageLength, pageHeight, PDDocGetNumPages(doc.getPDDoc()) - 1); + + PDEText textObj = PDETextCreate(); + + std::stringstream title; + title << "Blend Mode: " << vBlendModes[i] << "."; + + // Add the text run + PDETextAddEx(textObj, // To this object + kPDETextRun, // kPDETextRun vs. kPDETextChar + 0, // Index + (Uns8 *)title.str().c_str(), // The text, + strlen(title.str().c_str()), // and its length. + pdeFont, // The font we want used. + &gState, sizeof(gState), // Default the graphics state. + NULL, 0, // Default the text state. + &textMatrix, // The size and location of the text. + NULL); // Default the stroke matrix. + + PDPage outPage = doc.getPage(PDDocGetNumPages(doc.getPDDoc()) - 1); + PDEContent pagecontent = PDPageAcquirePDEContent(outPage, 0); + + // Add the text element to the page's content. + PDEContentAddElem(pagecontent, kPDEBeforeFirst, (PDEElement)(textObj)); + // We're done with the text element now that we've added it. + PDERelease((PDEObject)(textObj)); + // Set the content back into the page. + PDPageSetPDEContentCanRaise(outPage, NULL); + + // We're now done with this page and its contents. + PDPageReleasePDEContent(outPage, 0); + PDPageRelease(outPage); } - PDERelease((PDEObject)shapeGState.fillColorSpec.space); - PDERelease((PDEObject)shapeGState.extGState); - } - - PDERelease((PDEObject)singleShape); - - //The RGB triad prototype. - PDEForm rgbTriad = contentToForm(rgbContent,1,pdoc); - PDERelease((PDEObject)rgbContent); - - //The CMYK triad prototype. - PDEForm cmykTriad = contentToForm(cmykContent,1,pdoc); - PDERelease((PDEObject)cmykContent); - -// Step 4) Copy the triads to each page, with a different blending modes each time. - - for (int i = 0; i < numPages; ++i) - { - PDPage outPage = doc.getPage(i); - PDEContent pagecontent = PDPageAcquirePDEContent(outPage, 0); - - // The first blend mode, "Opaque", is not actually a blend mode, - // but is used to demonstrate the absence of blend modes. - if (i != 0) - { - //The PDEExtGState determines the transparency and blending mode - // of whatever PDEGraphicsState object it is set to. - PDEExtGState shapeExtGState = PDEExtGStateCreateNew(PDDocGetCosDoc(pdoc)); - //Each shape will have 3/4 transparency. - PDEExtGStateSetOpacityFill(shapeExtGState, fixedThreeQuarters); - //This will correspond to the title on the page. - PDEExtGStateSetBlendMode(shapeExtGState, ASAtomFromString(vBlendModes[i].c_str())); - - shapeGState.extGState = shapeExtGState; - shapeGState.wasSetFlags |= kPDEExtGStateWasSet; + PDERelease((PDEObject)gState.strokeColorSpec.space); + PDERelease((PDEObject)gState.fillColorSpec.space); + PDERelease((PDEObject)pdeFont); + + // Step 2) Define and create a prototype for the basic shape of each triad. + + // Note: PDEForm objects will be used as prototypes because they can group + // different PDEElements together, and for their cloning ability. + + // First we define the shape we'll use as a base. We'll make circles. + + ASFixed circleDiameter = FloatToASFixed(2.0 * 72.0); + ASFixed radius = circleDiameter / 2; + ASFixed threeFourthsRadius = (ASFloatToFixed(3.0f) * radius) / ASFloatToFixed(4.0f); + ASFixed zero = FloatToASFixed(0.0); + + // Now we want to define how the shapes will be positioned relative to each + // other, by making position deltas (or vectors, if you prefer) for each. + // They'll come out in a nice triangle. + + // shape 1 shape 2 shape 3 + ASFixed delta_x[NUM_BLENDING_SHAPES] = {radius - threeFourthsRadius, zero, (radius / 2) - threeFourthsRadius}; + ASFixed delta_y[NUM_BLENDING_SHAPES] = {zero, zero, -radius}; + + // Now we can create the basic shape's prototype. + // We'll put our circle into this content object, which will be converted into a PDEForm object. + PDEContent singleShapeContent = PDEContentCreate(); + + // Make a circle shape. + PDEPath shapePath = PDEPathCreate(); + ASFixed handleLength = FloatToASFixed(ASFixedToFloat(circleDiameter) * 0.66666); + PDEPathSetPaintOp(shapePath, kPDEFill); + PDEPathAddSegment(shapePath, kPDEMoveTo, -radius, 0, 0, 0, 0, 0); + PDEPathAddSegment(shapePath, kPDECurveTo, -radius, handleLength, radius, handleLength, radius, 0); + PDEPathAddSegment(shapePath, kPDECurveTo, radius, -handleLength, -radius, -handleLength, -radius, 0); + + // Give the circle its graphics state. This graphics state will be re-used for the triads. + PDEGraphicState shapeGState; + PDEDefaultGState(&shapeGState, sizeof(PDEGraphicState)); + // We haven't added anything special to this graphics state yet. + shapeGState.wasSetFlags = 0; + PDEElementSetGState((PDEElement)shapePath, &shapeGState, sizeof(shapeGState)); + + // The circle is complete. Add it to our content object. + PDEContentAddElem(singleShapeContent, kPDEBeforeFirst, (PDEElement)shapePath); + PDERelease((PDEObject)shapePath); + + // Convert the content containing our circle into a PDEForm. + PDDoc pdoc = doc.getPDDoc(); + PDEForm singleShape = contentToForm(singleShapeContent, 1, pdoc); // This is the basic shape prototype. + PDERelease((PDEObject)singleShapeContent); + + // Step 3) Create a prototype for the CMYK and RGB triads by triplicating the basic shape. + + // These containers will hold the shapes the CMYK triad and the RGB triad. + // They'll also be converted to PDEForms to create our prototypes. + PDEContent cmykContent = PDEContentCreate(); + PDEContent rgbContent = PDEContentCreate(); + + PDEContent content[2] = {cmykContent, rgbContent}; + PDEContent nextContent; + for (int i = 0; i < 2; i++) { + nextContent = content[i]; + // Set the color space of the next triad. + const char *colorSpace = (nextContent == cmykContent ? "DeviceCMYK" : "DeviceRGB"); + shapeGState.fillColorSpec.space = PDEColorSpaceCreateFromName(ASAtomFromString((colorSpace))); + shapeGState.wasSetFlags = kPDEFillCSpaceWasSet; + + // Give each triad three shapes of different colors, positioned as specified in delta_x and delta_y. + for (int i = 0; i < NUM_BLENDING_SHAPES; ++i) { + // Clone the basic shape prototype. + PDEForm nextShape = PDEFormCreateClone(singleShape); + + // Set the position for this shape. + ASFixedMatrix shapePosition = {fixedOne, 0, 0, fixedOne, 0, 0}; + shapePosition.h = delta_x[i]; + shapePosition.v = delta_y[i]; + + // Set the graphics state of this shape. + // The conditional values are used to easily create three shapes of different colors. + shapeGState.fillColorSpec.value.color[0] = (i == 0 ? fixedOne : fixedZero); // Red/Cyan value. + shapeGState.fillColorSpec.value.color[1] = (i == 1 ? fixedOne : fixedZero); // Green/Magenta value. + shapeGState.fillColorSpec.value.color[2] = (i == 2 ? fixedOne : fixedZero); // Blue/Yellow value. + shapeGState.fillColorSpec.value.color[3] = fixedZero; // Not using CMYK's Black + shapeGState.wasSetFlags |= kPDEFillCValueWasSet; + + // Set the position and graphics state of this triad. + PDEElementSetMatrix((PDEElement)nextShape, &shapePosition); + PDEElementSetGState((PDEElement)nextShape, &shapeGState, sizeof(shapeGState)); + + // Add the triad to its content. + PDEContentAddElem(nextContent, kPDEBeforeFirst, (PDEElement)nextShape); + + PDERelease((PDEObject)nextShape); + } + PDERelease((PDEObject)shapeGState.fillColorSpec.space); + PDERelease((PDEObject)shapeGState.extGState); } - PDEElementSetGState((PDEElement)rgbTriad, &shapeGState, sizeof(PDEGraphicState)); - PDEElementSetGState((PDEElement)cmykTriad, &shapeGState, sizeof(PDEGraphicState)); - - //Position and set the RGB triad. - ASFixedMatrix rgbPosition = { fixedOne, 0, 0, fixedOne, 0, 0 }; - rgbPosition.h = rightHalfCenter_X; - rgbPosition.v = rightHalfCenter_Y; - - PDEElementSetMatrix((PDEElement)rgbTriad, &rgbPosition); - PDEContentAddElem(pagecontent, kPDEBeforeFirst, (PDEElement)rgbTriad); - - //Position and set the CMYK triad. - ASFixedMatrix cmykPosition = { fixedOne, 0, 0, fixedOne, 0, 0 }; - cmykPosition.h = leftHalfCenter_X; - cmykPosition.v = leftHalfCenter_Y; - - PDEElementSetMatrix((PDEElement)cmykTriad, &cmykPosition); - PDEContentAddElem(pagecontent, kPDEBeforeFirst, (PDEElement)cmykTriad); - - //Set all the new content into the page and release resources. - PDPageSetPDEContentCanRaise(outPage, 0); - PDPageReleasePDEContent(outPage, 0); - PDPageRelease(outPage); - PDERelease((PDEObject)shapeGState.extGState); - } + PDERelease((PDEObject)singleShape); + + // The RGB triad prototype. + PDEForm rgbTriad = contentToForm(rgbContent, 1, pdoc); + PDERelease((PDEObject)rgbContent); + + // The CMYK triad prototype. + PDEForm cmykTriad = contentToForm(cmykContent, 1, pdoc); + PDERelease((PDEObject)cmykContent); + + // Step 4) Copy the triads to each page, with a different blending modes each time. + + for (int i = 0; i < numPages; ++i) { + PDPage outPage = doc.getPage(i); + PDEContent pagecontent = PDPageAcquirePDEContent(outPage, 0); + + // The first blend mode, "Opaque", is not actually a blend mode, + // but is used to demonstrate the absence of blend modes. + if (i != 0) { + // The PDEExtGState determines the transparency and blending mode + // of whatever PDEGraphicsState object it is set to. + PDEExtGState shapeExtGState = PDEExtGStateCreateNew(PDDocGetCosDoc(pdoc)); + // Each shape will have 3/4 transparency. + PDEExtGStateSetOpacityFill(shapeExtGState, fixedThreeQuarters); + // This will correspond to the title on the page. + PDEExtGStateSetBlendMode(shapeExtGState, ASAtomFromString(vBlendModes[i].c_str())); + + shapeGState.extGState = shapeExtGState; + shapeGState.wasSetFlags |= kPDEExtGStateWasSet; + } + + PDEElementSetGState((PDEElement)rgbTriad, &shapeGState, sizeof(PDEGraphicState)); + PDEElementSetGState((PDEElement)cmykTriad, &shapeGState, sizeof(PDEGraphicState)); + + // Position and set the RGB triad. + ASFixedMatrix rgbPosition = {fixedOne, 0, 0, fixedOne, 0, 0}; + rgbPosition.h = rightHalfCenter_X; + rgbPosition.v = rightHalfCenter_Y; + + PDEElementSetMatrix((PDEElement)rgbTriad, &rgbPosition); + PDEContentAddElem(pagecontent, kPDEBeforeFirst, (PDEElement)rgbTriad); + + // Position and set the CMYK triad. + ASFixedMatrix cmykPosition = {fixedOne, 0, 0, fixedOne, 0, 0}; + cmykPosition.h = leftHalfCenter_X; + cmykPosition.v = leftHalfCenter_Y; + + PDEElementSetMatrix((PDEElement)cmykTriad, &cmykPosition); + PDEContentAddElem(pagecontent, kPDEBeforeFirst, (PDEElement)cmykTriad); + + // Set all the new content into the page and release resources. + PDPageSetPDEContentCanRaise(outPage, 0); + PDPageReleasePDEContent(outPage, 0); + PDPageRelease(outPage); + PDERelease((PDEObject)shapeGState.extGState); + } - //Now we're done with everything except for the document itself. - PDERelease((PDEObject)rgbTriad); - PDERelease((PDEObject)cmykTriad); - PDERelease((PDEObject)shapeGState.strokeColorSpec.space); - PDERelease((PDEObject)shapeGState.fillColorSpec.space); + // Now we're done with everything except for the document itself. + PDERelease((PDEObject)rgbTriad); + PDERelease((PDEObject)cmykTriad); + PDERelease((PDEObject)shapeGState.strokeColorSpec.space); + PDERelease((PDEObject)shapeGState.fillColorSpec.space); - doc.saveDoc ( csOutputFileName.c_str() ); + doc.saveDoc(csOutputFileName.c_str()); -HANDLER - errCode = ERRORCODE; - libInit.displayError(errCode); -END_HANDLER + HANDLER + errCode = ERRORCODE; + libInit.displayError(errCode); + END_HANDLER return errCode; }; -// Helper function to transform the supplied PDEContent into a PDEForm. +// Helper function to transform the supplied PDEContent into a PDEForm. // NOTE: The caller is responsible for releasing the input content. -PDEForm contentToForm(PDEContent content, ASInt32 formType, PDDoc document) -{ - //Determine the attributes of our input content. +PDEForm contentToForm(PDEContent content, ASInt32 formType, PDDoc document) { + // Determine the attributes of our input content. PDEContentAttrs contentAttrs; - memset((char *)&contentAttrs, 0, sizeof (PDEContentAttrs)); - contentAttrs.formType = formType; - - //The bounding box of our output PDEForm will match the bounding box of our input PDEContent. - PDEElementGetBBox ( (PDEElement)content, &contentAttrs.bbox ); + memset((char *)&contentAttrs, 0, sizeof(PDEContentAttrs)); + contentAttrs.formType = formType; + + // The bounding box of our output PDEForm will match the bounding box of our input PDEContent. + PDEElementGetBBox((PDEElement)content, &contentAttrs.bbox); contentAttrs.matrix.a = contentAttrs.matrix.d = fixedOne; - //Convert the PDEContent into CosObjects. + // Convert the PDEContent into CosObjects. CosObj cosContent, cosResources; - PDEContentToCosObj ( content, kPDEContentToForm, &contentAttrs, sizeof(PDEContentAttrs), - PDDocGetCosDoc(document), NULL, &cosContent, &cosResources); + PDEContentToCosObj(content, kPDEContentToForm, &contentAttrs, sizeof(PDEContentAttrs), + PDDocGetCosDoc(document), NULL, &cosContent, &cosResources); - //Convert the CosObjects into a PDEForm. - ASDoubleMatrix unity = { 1.0, 0, 0, 1.0, 0, 0 }; + // Convert the CosObjects into a PDEForm. + ASDoubleMatrix unity = {1.0, 0, 0, 1.0, 0, 0}; return PDEFormCreateFromCosObjEx(&cosContent, &cosResources, &unity); } diff --git a/CPlusPlus/Sample_Source/ContentExtraction/CopyContent/CopyContent.cpp b/CPlusPlus/Sample_Source/ContentExtraction/CopyContent/CopyContent.cpp index 285f26e2..46bb208b 100644 --- a/CPlusPlus/Sample_Source/ContentExtraction/CopyContent/CopyContent.cpp +++ b/CPlusPlus/Sample_Source/ContentExtraction/CopyContent/CopyContent.cpp @@ -9,7 +9,7 @@ // // Command-line: (Both optional) // -// For more detail see the description of the CopyContent sample program on our Developer’s site, +// For more detail see the description of the CopyContent sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#copycontent #include @@ -33,107 +33,103 @@ #define DEF_INPUT "CopyContent.pdf" #define DEF_OUTPUT "CopyContent-out.pdf" -//Copies all elements in "from" into "to". -static void copyElements ( PDEContent to, PDEContent from, const std::set& willCopyList ); +// Copies all elements in "from" into "to". +static void copyElements(PDEContent to, PDEContent from, const std::set &willCopyList); -int main(int argc, char** argv) -{ +int main(int argc, char **argv) { APDFLib lib; ASErrorCode errCode = 0; - if (lib.isValid() == false) - { + if (lib.isValid() == false) { errCode = lib.getInitError(); std::cout << "Initialization failed with code " << errCode << std::endl; return lib.getInitError(); } - - std::string csInputFileName ( argc > 1 ? argv[1] : DIR_LOC DEF_INPUT ); - std::string csOutputFileName ( argc > 2 ? argv[2] : DEF_OUTPUT ); - std::cout << "Copying (selected elements) from " << csInputFileName.c_str() << " and writing to " - << csOutputFileName.c_str() << std::endl; -//Step 1) Determine what kinds of content will be copied. + std::string csInputFileName(argc > 1 ? argv[1] : DIR_LOC DEF_INPUT); + std::string csOutputFileName(argc > 2 ? argv[2] : DEF_OUTPUT); + std::cout << "Copying (selected elements) from " << csInputFileName.c_str() + << " and writing to " << csOutputFileName.c_str() << std::endl; + + // Step 1) Determine what kinds of content will be copied. // All element types in this set will be copied, others will be ignored std::set sContentTypes; - sContentTypes.insert ( kPDEContainer ); - sContentTypes.insert ( kPDEForm ); - sContentTypes.insert ( kPDEGroup ); - sContentTypes.insert ( kPDEImage ); - sContentTypes.insert ( kPDEPath ); - sContentTypes.insert ( kPDEPlace ); - sContentTypes.insert ( kPDEPS ); - sContentTypes.insert ( kPDEShading ); - sContentTypes.insert ( kPDEText ); - sContentTypes.insert ( kPDEUnknown ); - sContentTypes.insert ( kPDEXObject ); + sContentTypes.insert(kPDEContainer); + sContentTypes.insert(kPDEForm); + sContentTypes.insert(kPDEGroup); + sContentTypes.insert(kPDEImage); + sContentTypes.insert(kPDEPath); + sContentTypes.insert(kPDEPlace); + sContentTypes.insert(kPDEPS); + sContentTypes.insert(kPDEShading); + sContentTypes.insert(kPDEText); + sContentTypes.insert(kPDEUnknown); + sContentTypes.insert(kPDEXObject); // Which pages we'll copy: To copy all pages, omit populating this container with any numbers // And don't forget, pages are 0-based in APDDFL! std::set sPagesToCopy; - sPagesToCopy.insert ( 0 ); - sPagesToCopy.insert ( 1 ); - sPagesToCopy.insert ( 3 ); - sPagesToCopy.insert ( 5 ); - -DURING - -//Step 2) Open the input PDF, create the output PDF. - - APDFLDoc inAPDoc ( csInputFileName.c_str(), true ); - PDDoc inDoc = inAPDoc.getPDDoc(); - - int iInDocPages = PDDocGetNumPages(inDoc); - - //Create a blank document. - APDFLDoc outAPDoc; - PDDoc outDoc = outAPDoc.getPDDoc(); - -//Step 3) Copy the specified content from the input PDF into the output PDF. - - for ( int i = 0 ; i < iInDocPages; i++ ) - { - if (!sPagesToCopy.empty() && (sPagesToCopy.find(i) == sPagesToCopy.end())) - { - // Don't copy this page if the page selection set is not empty, and this page number isn't in it! - continue; + sPagesToCopy.insert(0); + sPagesToCopy.insert(1); + sPagesToCopy.insert(3); + sPagesToCopy.insert(5); + + DURING + + // Step 2) Open the input PDF, create the output PDF. + + APDFLDoc inAPDoc(csInputFileName.c_str(), true); + PDDoc inDoc = inAPDoc.getPDDoc(); + + int iInDocPages = PDDocGetNumPages(inDoc); + + // Create a blank document. + APDFLDoc outAPDoc; + PDDoc outDoc = outAPDoc.getPDDoc(); + + // Step 3) Copy the specified content from the input PDF into the output PDF. + + for (int i = 0; i < iInDocPages; i++) { + if (!sPagesToCopy.empty() && (sPagesToCopy.find(i) == sPagesToCopy.end())) { + // Don't copy this page if the page selection set is not empty, and this page number isn't in it! + continue; + } + + // Give the output document a new page with the same size as page i of the input. + PDPage inPage = inAPDoc.getPage(i); + ASFixedRect inPageSize; + PDPageGetSize(inPage, &(inPageSize.right), &(inPageSize.top)); + + // Insert the new blank page and get a reference to it + outAPDoc.insertPage(inPageSize.right, inPageSize.top, PDDocGetNumPages(outDoc) - 1); + PDPage outPage = outAPDoc.getPage(PDDocGetNumPages(outDoc) - 1); + + // Obtain handles to the content of the input and output pages + PDEContent inContent = PDPageAcquirePDEContent(inPage, 0); + PDEContent outContent = PDPageAcquirePDEContent(outPage, 0); + // And now copy the content. + copyElements(outContent, inContent, sContentTypes); + // Set the content into the page. + PDPageSetPDEContentCanRaise(outPage, 0); + + // Release the resources of this iteration. + PDPageReleasePDEContent(outPage, 0); + PDPageRelease(outPage); + PDPageReleasePDEContent(inPage, 0); + PDPageRelease(inPage); } - //Give the output document a new page with the same size as page i of the input. - PDPage inPage = inAPDoc.getPage(i); - ASFixedRect inPageSize; - PDPageGetSize(inPage, &(inPageSize.right), &(inPageSize.top)); - - //Insert the new blank page and get a reference to it - outAPDoc.insertPage(inPageSize.right, inPageSize.top, PDDocGetNumPages(outDoc) - 1); - PDPage outPage = outAPDoc.getPage(PDDocGetNumPages(outDoc) - 1); - - // Obtain handles to the content of the input and output pages - PDEContent inContent = PDPageAcquirePDEContent(inPage, 0); - PDEContent outContent = PDPageAcquirePDEContent(outPage, 0); - // And now copy the content. - copyElements ( outContent, inContent, sContentTypes ); - //Set the content into the page. - PDPageSetPDEContentCanRaise(outPage, 0); - - //Release the resources of this iteration. - PDPageReleasePDEContent(outPage, 0); - PDPageRelease(outPage); - PDPageReleasePDEContent(inPage, 0); - PDPageRelease(inPage); - } - -//Step 4) Save the output PDF and close both PDFs. + // Step 4) Save the output PDF and close both PDFs. - outAPDoc.saveDoc ( csOutputFileName.c_str() ); + outAPDoc.saveDoc(csOutputFileName.c_str()); - // APDFLDoc's destructor will properly close both documents, - // and APDFLib's will shut down the library + // APDFLDoc's destructor will properly close both documents, + // and APDFLib's will shut down the library -HANDLER - errCode = ERRORCODE; - lib.displayError(errCode); -END_HANDLER + HANDLER + errCode = ERRORCODE; + lib.displayError(errCode); + END_HANDLER return errCode; }; @@ -142,103 +138,94 @@ END_HANDLER // // For aggregate element types (PDEContainer, PDEGroup, PDEForm) we will do so recursively; // "scalar" element types are copied directly -void copyElements ( PDEContent to, PDEContent from, const std::set& ElementTypesSet ) -{ -DURING +void copyElements(PDEContent to, PDEContent from, const std::set &ElementTypesSet) { + DURING - ASInt32 i, iNumElems = PDEContentGetNumElems ( from ); + ASInt32 i, iNumElems = PDEContentGetNumElems(from); - for ( i = 0; i < iNumElems; ++i ) - { - // Fetch each element, and get its type - PDEElement nextElem = PDEContentGetElem( from, i ); - ASInt32 type = PDEObjectGetType(reinterpret_cast(nextElem)); + for (i = 0; i < iNumElems; ++i) { + // Fetch each element, and get its type + PDEElement nextElem = PDEContentGetElem(from, i); + ASInt32 type = PDEObjectGetType(reinterpret_cast(nextElem)); - if ( ElementTypesSet.find ( type ) == ElementTypesSet.end() ) - { - continue; - } + if (ElementTypesSet.find(type) == ElementTypesSet.end()) { + continue; + } - switch ( type ) - { - case kPDEContainer: - { + switch (type) { + case kPDEContainer: { // This is a compound container, need to recurse PDEContainer fromContainer = reinterpret_cast(nextElem); PDEContent fromContent = PDEContainerGetContent(fromContainer); - //The new container, to which which we give blank contents, and give to the output document. + // The new container, to which which we give blank contents, and give to the output document. PDEContainer toContainer = PDEContainerCreate(PDEContainerGetMCTag(fromContainer), NULL, true); PDEContent _content = PDEContentCreate(); PDEContainerSetContent(toContainer, _content); PDEContent toContent = PDEContainerGetContent(toContainer); - copyElements( toContent, fromContent, ElementTypesSet); + copyElements(toContent, fromContent, ElementTypesSet); - //Now copy the new container into "to". - PDEContentAddElem( to, kPDEAfterLast, reinterpret_cast(toContainer)); + // Now copy the new container into "to". + PDEContentAddElem(to, kPDEAfterLast, reinterpret_cast(toContainer)); PDERelease(reinterpret_cast(toContainer)); PDERelease(reinterpret_cast(_content)); break; - } + } - case kPDEGroup: - { + case kPDEGroup: { // This is a compound container, need to recurse PDEGroup fromGroup = reinterpret_cast(nextElem); - PDEContent fromContent = PDEGroupGetContent(fromGroup); + PDEContent fromContent = PDEGroupGetContent(fromGroup); - PDEGroup toGroup = PDEGroupCreate(); - PDEGroupSetContent(toGroup, PDEContentCreate()); - PDEContent toContent = PDEGroupGetContent(toGroup); + PDEGroup toGroup = PDEGroupCreate(); + PDEGroupSetContent(toGroup, PDEContentCreate()); + PDEContent toContent = PDEGroupGetContent(toGroup); - copyElements( toContent, fromContent, ElementTypesSet); + copyElements(toContent, fromContent, ElementTypesSet); - //Now copy the new group into "to". - PDEContentAddElem( to, kPDEAfterLast, reinterpret_cast(toGroup)); + // Now copy the new group into "to". + PDEContentAddElem(to, kPDEAfterLast, reinterpret_cast(toGroup)); PDERelease(reinterpret_cast(toGroup)); break; - } + } - case kPDEForm: - { + case kPDEForm: { // This is a compound container, need to recurse PDEForm fromForm = reinterpret_cast(nextElem); PDEContent fromFormContent = PDEFormGetContent(fromForm); - //Note: this also clones the underlying xObject Cos Object(s), for each occurence. + // Note: this also clones the underlying xObject Cos Object(s), for each occurence. PDEForm toForm = PDEFormCreateClone(fromForm); - //Replace the contents of toForm with a new one, with only the elements we want copied + // Replace the contents of toForm with a new one, with only the elements we want copied PDEContent toContent = PDEContentCreate(); - copyElements( toContent, fromFormContent, ElementTypesSet); + copyElements(toContent, fromFormContent, ElementTypesSet); PDEFormSetContent(toForm, toContent); - - //Now copy the new form into "to". - PDEContentAddElem( to, kPDEAfterLast, reinterpret_cast(toForm)); - //Release the containers, since we're done with them. + // Now copy the new form into "to". + PDEContentAddElem(to, kPDEAfterLast, reinterpret_cast(toForm)); + + // Release the containers, since we're done with them. PDERelease(reinterpret_cast(fromFormContent)); PDERelease(reinterpret_cast(toForm)); PDERelease(reinterpret_cast(toContent)); break; - } - default: - { + } + default: { // Must be a "scalar" - just copy it PDEElement copyNextElem = PDEElementCopy(nextElem, kPDEElementCopyClipping); - PDEContentAddElem( to, kPDEAfterLast, copyNextElem ); + PDEContentAddElem(to, kPDEAfterLast, copyNextElem); PDERelease(reinterpret_cast(copyNextElem)); - } - break; + } break; + } } - } -HANDLER - ASRaise(ERRORCODE); //If there was an exception, let the caller handle it. -END_HANDLER + HANDLER + ASRaise(ERRORCODE); // If there was an exception, let the caller handle it. + END_HANDLER return; }; diff --git a/CPlusPlus/Sample_Source/ContentExtraction/ExtractAttachments/ExtractAttachments.cpp b/CPlusPlus/Sample_Source/ContentExtraction/ExtractAttachments/ExtractAttachments.cpp index 5f1117b4..0dea9fe7 100644 --- a/CPlusPlus/Sample_Source/ContentExtraction/ExtractAttachments/ExtractAttachments.cpp +++ b/CPlusPlus/Sample_Source/ContentExtraction/ExtractAttachments/ExtractAttachments.cpp @@ -4,13 +4,13 @@ // For complete copyright information, refer to: // http://dev.datalogics.com/adobe-pdf-library/license-for-downloaded-pdf-samples/ // -// This sample extracts from a PDF input document all of the embedded attachments -// found on the first page, and all attachments in the nametree. +// This sample extracts from a PDF input document all of the embedded attachments +// found on the first page, and all attachments in the nametree. // // To run the program from the command line, enter the input file name and prefix. Both are optional. // To save the attachments with no prefix, type "" (two quotation marks) for the second command-line argument. // -// For more detail see the description of the ExtractAttachments sample program on our Developer’s site, +// For more detail see the description of the ExtractAttachments sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#extractattachments #include "PERCalls.h" @@ -24,105 +24,99 @@ #define DEF_INPUT "extractFrom.pdf" #define DEF_PREFIX "_x_" -ACCB1 ASBool ACCB2 extractor ( CosObj obj, CosObj value, void *clientData ); +ACCB1 ASBool ACCB2 extractor(CosObj obj, CosObj value, void *clientData); -int main(int argc, char** argv) -{ +int main(int argc, char **argv) { APDFLib libInit; ASErrorCode errCode = 0; - if (libInit.isValid() == false) - { + if (libInit.isValid() == false) { errCode = libInit.getInitError(); std::cout << "Initialization failed with code " << errCode << std::endl; return libInit.getInitError(); } - - std::string csInputFileName ( argc > 1 ? argv[1] : DIR_LOC DEF_INPUT ); - std::string csPrefix ( argc > 2 ? argv[2] : DEF_PREFIX ); + + std::string csInputFileName(argc > 1 ? argv[1] : DIR_LOC DEF_INPUT); + std::string csPrefix(argc > 2 ? argv[2] : DEF_PREFIX); std::cout << "Extracting attachments (annotations on the first page) and all nametree-embedded " << "files from " << csInputFileName.c_str() << " and " << "saving with prefix of \"" << csPrefix.c_str() << "\"" << std::endl; -DURING + DURING + + APDFLDoc document(csInputFileName.c_str(), true); + + // Step 1) Iterate through the annotations on a page 0 and extract and save their embedded files - APDFLDoc document ( csInputFileName.c_str(), true); + ASAtom atFileAttachment(ASAtomFromString("FileAttachment")); + PDPage pdPage = document.getPage(0); -// Step 1) Iterate through the annotations on a page 0 and extract and save their embedded files - - ASAtom atFileAttachment ( ASAtomFromString ( "FileAttachment" ) ); - PDPage pdPage = document.getPage(0); - - int annotTotal = PDPageGetNumAnnots(pdPage); + int annotTotal = PDPageGetNumAnnots(pdPage); - for (int i = 0; i < annotTotal; i++) - { - PDAnnot annot = PDPageGetAnnot(pdPage, i); - - // Operate only on "FileAttachment" annotations - if ( atFileAttachment == PDAnnotGetSubtype ( annot ) ) - { - CosObj obj = PDAnnotGetCosObj(annot); + for (int i = 0; i < annotTotal; i++) { + PDAnnot annot = PDPageGetAnnot(pdPage, i); - //Get the cos dictionary object from the CosObj, using the File Specification key - CosObj dictObj = CosDictGet(obj, ASAtomFromString("FS")); + // Operate only on "FileAttachment" annotations + if (atFileAttachment == PDAnnotGetSubtype(annot)) { + CosObj obj = PDAnnotGetCosObj(annot); - //Obtain the accessed attachemnt using the dictionary - PDFileAttachment fileAttachment = PDFileAttachmentFromCosObj(dictObj); + // Get the cos dictionary object from the CosObj, using the File Specification key + CosObj dictObj = CosDictGet(obj, ASAtomFromString("FS")); - //Grab the file's name using the cos object dictionary - ASTCount len = 0; - std::string sFileName ( CosStringValue ( CosDictGet ( dictObj, ASAtomFromString ( "F" ) ), - &len ) ); + // Obtain the accessed attachemnt using the dictionary + PDFileAttachment fileAttachment = PDFileAttachmentFromCosObj(dictObj); - std::cout << "\tAnnotation attachment " << sFileName.c_str() << " --> "; - sFileName.insert ( 0, csPrefix ); - std::cout << sFileName.c_str() << std::endl; + // Grab the file's name using the cos object dictionary + ASTCount len = 0; + std::string sFileName(CosStringValue(CosDictGet(dictObj, ASAtomFromString("F")), &len)); - ASFile outFile = APDFLDoc::OpenFlatFile ( sFileName.c_str(), ASFILE_CREATE ); + std::cout << "\tAnnotation attachment " << sFileName.c_str() << " --> "; + sFileName.insert(0, csPrefix); + std::cout << sFileName.c_str() << std::endl; - PDFileAttachmentSaveToFile(fileAttachment, outFile); + ASFile outFile = APDFLDoc::OpenFlatFile(sFileName.c_str(), ASFILE_CREATE); - //Safely close outFile - ASFileFlush(outFile); - ASFileClose(outFile); + PDFileAttachmentSaveToFile(fileAttachment, outFile); + + // Safely close outFile + ASFileFlush(outFile); + ASFileClose(outFile); + } } - - } - PDPageRelease(pdPage); + PDPageRelease(pdPage); -// Step 2) Iterate through the file's nametree and extract and save its embedded files + // Step 2) Iterate through the file's nametree and extract and save its embedded files - //Create the nametree - PDNameTree nameTree = PDDocCreateNameTree ( document.getPDDoc(), ASAtomFromString("EmbeddedFiles") ); + // Create the nametree + PDNameTree nameTree = PDDocCreateNameTree(document.getPDDoc(), ASAtomFromString("EmbeddedFi" + "les")); - //Apply the enum function to the nametree so it can iterate through, extracting the attachments. - PDNameTreeEnum ( nameTree, &extractor, &csPrefix ); + // Apply the enum function to the nametree so it can iterate through, extracting the attachments. + PDNameTreeEnum(nameTree, &extractor, &csPrefix); -HANDLER - errCode = ERRORCODE; - libInit.displayError(errCode); -END_HANDLER + HANDLER + errCode = ERRORCODE; + libInit.displayError(errCode); + END_HANDLER return errCode; } // Procedure called by PDNameTreeEnum -ACCB1 ASBool ACCB2 extractor(CosObj obj, CosObj value, void *clientData) -{ - std::string* psPrefix = (std::string*)clientData; +ACCB1 ASBool ACCB2 extractor(CosObj obj, CosObj value, void *clientData) { + std::string *psPrefix = (std::string *)clientData; PDFileAttachment fileAttachment = PDFileAttachmentFromCosObj(value); - - //Grab the file's name using the cos object dictionary and the File Specifcation String key. + + // Grab the file's name using the cos object dictionary and the File Specifcation String key. ASTCount len = 0; - std::string sFileName ( CosStringValue ( CosDictGet ( value, ASAtomFromString ( "F" ) ), &len ) ); + std::string sFileName(CosStringValue(CosDictGet(value, ASAtomFromString("F")), &len)); std::cout << "\tName-tree attachment " << sFileName.c_str() << " --> "; - sFileName.insert ( 0, *psPrefix ); + sFileName.insert(0, *psPrefix); std::cout << sFileName.c_str() << std::endl; - ASFile outFile = APDFLDoc::OpenFlatFile ( sFileName.c_str(), ASFILE_CREATE ); + ASFile outFile = APDFLDoc::OpenFlatFile(sFileName.c_str(), ASFILE_CREATE); PDFileAttachmentSaveToFile(fileAttachment, outFile); ASFileFlush(outFile); diff --git a/CPlusPlus/Sample_Source/ContentExtraction/ExtractFonts/ExtractFonts.cpp b/CPlusPlus/Sample_Source/ContentExtraction/ExtractFonts/ExtractFonts.cpp index b41a4366..86587c65 100644 --- a/CPlusPlus/Sample_Source/ContentExtraction/ExtractFonts/ExtractFonts.cpp +++ b/CPlusPlus/Sample_Source/ContentExtraction/ExtractFonts/ExtractFonts.cpp @@ -10,7 +10,7 @@ // // The ExtractFonts sample does not define a default output file. // -// For more information about working with fonts in the Adobe PDF Library, see the description of the EmbedFonts sample program on our Developer’s site, +// For more information about working with fonts in the Adobe PDF Library, see the description of the EmbedFonts sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#embedfonts #include "CosCalls.h" @@ -21,130 +21,111 @@ #define INPUT_DIR "../../../../Resources/Sample_Input/" #define INPUT_FILE "CopyContent.pdf" -ASBool ExtractEmbeddedFonts (CosObj obj, CosObj value, void *clientData); +ASBool ExtractEmbeddedFonts(CosObj obj, CosObj value, void *clientData); -int main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { // Initialize the PDF library APDFLib libInit; - if (libInit.isValid() == false) - { + if (libInit.isValid() == false) { ASErrorCode errCode = libInit.getInitError(); - APDFLib::displayError ( errCode ); + APDFLib::displayError(errCode); return errCode; } std::string csInputFile(argc > 1 ? argv[1] : INPUT_DIR INPUT_FILE); std::cout << "Will extract fonts found in document " << csInputFile.c_str() << std::endl; -DURING - APDFLDoc apdflDoc ( csInputFile.c_str(), true ); - PDDoc pdDoc = apdflDoc.getPDDoc(); - // Enumerate font resources found in document - PDDocEnumResources (pdDoc, 0, PDDocGetNumPages(pdDoc) - 1, ASAtomFromString ("Font"), ExtractEmbeddedFonts, NULL); -HANDLER - APDFLib::displayError(ERRORCODE); - return ERRORCODE; -END_HANDLER + DURING + APDFLDoc apdflDoc(csInputFile.c_str(), true); + PDDoc pdDoc = apdflDoc.getPDDoc(); + // Enumerate font resources found in document + PDDocEnumResources(pdDoc, 0, PDDocGetNumPages(pdDoc) - 1, ASAtomFromString("Font"), + ExtractEmbeddedFonts, NULL); + HANDLER + APDFLib::displayError(ERRORCODE); + return ERRORCODE; + END_HANDLER return 0; } -ASBool ExtractEmbeddedFonts (CosObj obj, CosObj value, void *clientData) -{ - if (CosObjGetType (obj) != CosDict) - { +ASBool ExtractEmbeddedFonts(CosObj obj, CosObj value, void *clientData) { + if (CosObjGetType(obj) != CosDict) { return (true); } - if (CosDictKnown (obj, ASAtomFromString ("DescendantFonts"))) - { + if (CosDictKnown(obj, ASAtomFromString("DescendantFonts"))) { // Only type 0 fonts have a DescendantFonts entry, which is an - // array of other fonts, and it will be recursive. + // array of other fonts, and it will be recursive. // In practice, it will always be a single entry array, pointing to a CID font. - // - // The Type 0/Original Composite Font (OCF) format is a composite font designed - // to support a character set with a large number of glyphs, particularly Asian - // languages like Korean, Japanese, and Mandarin. - // - // Adobe Systems developed the Character Identifier Font (CID) to improve the - // performance the OCF format. - - CosObj descendants = CosDictGet (obj, ASAtomFromString ("DescendantFonts")); - for (int index = 0; index < CosArrayLength (descendants); index++) - { - ExtractEmbeddedFonts (CosArrayGet (descendants, index), CosNewNull(), clientData); + // + // The Type 0/Original Composite Font (OCF) format is a composite font designed + // to support a character set with a large number of glyphs, particularly Asian + // languages like Korean, Japanese, and Mandarin. + // + // Adobe Systems developed the Character Identifier Font (CID) to improve the + // performance the OCF format. + + CosObj descendants = CosDictGet(obj, ASAtomFromString("DescendantFonts")); + for (int index = 0; index < CosArrayLength(descendants); index++) { + ExtractEmbeddedFonts(CosArrayGet(descendants, index), CosNewNull(), clientData); } return (true); } - if (CosDictKnown (obj, ASAtomFromString ("FontDescriptor"))) - { - CosObj descriptor = CosDictGet (obj, ASAtomFromString ("FontDescriptor")); - ASAtom nameAtom = CosNameValue (CosDictGet (descriptor, ASAtomFromString ("FontName"))); - std::string sName ( ASAtomGetString ( nameAtom ) ); + if (CosDictKnown(obj, ASAtomFromString("FontDescriptor"))) { + CosObj descriptor = CosDictGet(obj, ASAtomFromString("FontDescriptor")); + ASAtom nameAtom = CosNameValue(CosDictGet(descriptor, ASAtomFromString("FontName"))); + std::string sName(ASAtomGetString(nameAtom)); - ASAtom subType = CosNameValue (CosDictGet (obj, ASAtomFromString ("Subtype"))); + ASAtom subType = CosNameValue(CosDictGet(obj, ASAtomFromString("Subtype"))); CosObj fontData; - if (CosDictKnown (descriptor, ASAtomFromString ("FontFile"))) - { - fontData = CosDictGet (descriptor, ASAtomFromString ("FontFile")); + if (CosDictKnown(descriptor, ASAtomFromString("FontFile"))) { + fontData = CosDictGet(descriptor, ASAtomFromString("FontFile")); sName += ".pfb"; - } - else - { - if (CosDictKnown (descriptor, ASAtomFromString ("FontFile2"))) - { - fontData = CosDictGet (descriptor, ASAtomFromString ("FontFile2")); - sName += ".ttf"; - } - else - { - if (CosDictKnown (descriptor, ASAtomFromString ("FontFile3"))) - { - fontData = CosDictGet (descriptor, ASAtomFromString ("FontFile3")); - if ((subType == ASAtomFromString ("Type1C")) || - (subType == ASAtomFromString ("Type1")) || - (subType == ASAtomFromString ("CIDFontType0")) || - (subType == ASAtomFromString ("CIDFontType0C"))) - { + } else { + if (CosDictKnown(descriptor, ASAtomFromString("FontFile2"))) { + fontData = CosDictGet(descriptor, ASAtomFromString("FontFile2")); + sName += ".ttf"; + } else { + if (CosDictKnown(descriptor, ASAtomFromString("FontFile3"))) { + fontData = CosDictGet(descriptor, ASAtomFromString("FontFile3")); + if ((subType == ASAtomFromString("Type1C")) || (subType == ASAtomFromString("Type1")) || + (subType == ASAtomFromString("CIDFontType0")) || + (subType == ASAtomFromString("CIDFontType0C"))) { sName += ".pfb"; } - if ((subType == ASAtomFromString ("OpenType")) || - (subType == ASAtomFromString ("CIDFontType2")) || - (subType == ASAtomFromString ("TrueType"))) - { + if ((subType == ASAtomFromString("OpenType")) || + (subType == ASAtomFromString("CIDFontType2")) || + (subType == ASAtomFromString("TrueType"))) { sName += ".otf"; } - } - else - { + } else { return true; } } } - ASPathName fontName = APDFLDoc::makePath ( sName.c_str() ); + ASPathName fontName = APDFLDoc::makePath(sName.c_str()); ASFile fontFile; - ASFileSysOpenFile (NULL, fontName, ASFILE_WRITE | ASFILE_CREATE, &fontFile); - ASFileSysReleasePath (NULL, fontName); + ASFileSysOpenFile(NULL, fontName, ASFILE_WRITE | ASFILE_CREATE, &fontFile); + ASFileSysReleasePath(NULL, fontName); - ASStm fontStm = CosStreamOpenStm (fontData, cosOpenFiltered); - while ( 1 ) - { + ASStm fontStm = CosStreamOpenStm(fontData, cosOpenFiltered); + while (1) { char buffer[4096]; int bytesRead; - bytesRead = ASStmRead (buffer, 1, sizeof(buffer), fontStm); + bytesRead = ASStmRead(buffer, 1, sizeof(buffer), fontStm); if (bytesRead == 0) break; - ASFileWrite (fontFile, buffer, bytesRead); + ASFileWrite(fontFile, buffer, bytesRead); } - ASFileClose (fontFile); - ASStmClose (fontStm); - std::cout << "Extracted the font " << sName.c_str() << std::endl;; + ASFileClose(fontFile); + ASStmClose(fontStm); + std::cout << "Extracted the font " << sName.c_str() << std::endl; + ; } return true; } - diff --git a/CPlusPlus/Sample_Source/ContentModification/AddBookmarks/AddBookmarks.cpp b/CPlusPlus/Sample_Source/ContentModification/AddBookmarks/AddBookmarks.cpp index 3c2b15a0..70125fce 100644 --- a/CPlusPlus/Sample_Source/ContentModification/AddBookmarks/AddBookmarks.cpp +++ b/CPlusPlus/Sample_Source/ContentModification/AddBookmarks/AddBookmarks.cpp @@ -8,7 +8,7 @@ // // Command line: (all optional) // -// For more detail see the description of the AddBookmarks sample program on our Developer’s site, +// For more detail see the description of the AddBookmarks sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#addbookmarks #include @@ -27,188 +27,175 @@ #define DEF_OUTPUT "AddBookmarks-out.pdf" #define DEF_TARGET "before" -typedef struct _WordLocation -{ - ASFixedRect m_loc; // Bounding rectangle (relative to page) - ASInt32 m_page; // Page number - ASText m_text; // Actual text - _WordLocation ( ASInt32 p ) { m_page = p; } +typedef struct _WordLocation { + ASFixedRect m_loc; // Bounding rectangle (relative to page) + ASInt32 m_page; // Page number + ASText m_text; // Actual text + _WordLocation(ASInt32 p) { m_page = p; } } WordLocation; -static bool searchWord(PDWord nextWord, const char* target); +static bool searchWord(PDWord nextWord, const char *target); -int main(int argc, char** argv) -{ +int main(int argc, char **argv) { ASErrorCode errCode = 0; - - //Initialize the Adobe PDF Library. - APDFLib lib; - if (lib.isValid() == false) - { + + // Initialize the Adobe PDF Library. + APDFLib lib; + if (lib.isValid() == false) { errCode = lib.getInitError(); std::cout << "Initialization failed with code " << errCode << std::endl; return errCode; } - std::string csSearchWord ( argc > 1 ? argv[1] : DEF_TARGET ); - std::string csInputFileName ( argc > 2 ? argv[2] : INPUT_LOC DEF_INPUT ); - std::string csOutputFileName ( argc > 3 ? argv[3] : DEF_OUTPUT ); + std::string csSearchWord(argc > 1 ? argv[1] : DEF_TARGET); + std::string csInputFileName(argc > 2 ? argv[2] : INPUT_LOC DEF_INPUT); + std::string csOutputFileName(argc > 3 ? argv[3] : DEF_OUTPUT); - std::cout << "Will search for \"" << csSearchWord.c_str() << "\" in " - << csInputFileName.c_str() << " and write output to " << csOutputFileName.c_str() - << std::endl; + std::cout << "Will search for \"" << csSearchWord.c_str() << "\" in " << csInputFileName.c_str() + << " and write output to " << csOutputFileName.c_str() << std::endl; DURING - APDFLDoc APDoc(csInputFileName.c_str(), true); - PDDoc mydoc = APDoc.getPDDoc(); - - // Step 1) Find each occurrence of target word in the document and record the location and text - - std::vector vWords; - - //We'll use the PDWordFinder class to iterate through our document's words, looking for target word. - PDWordFinder wordFinder = PDDocCreateWordFinderUCS(mydoc, WF_LATEST_VERSION, 0, NULL); - - //Our PDWordFinder will iterate through the words with this. We will not directly access it. - PDWord* wordList = new PDWord(); - ASInt32 numWordsFound ( 0 ); - - // Search all words in each page of the document. It is assumed that no word will span pages. - for (int page = 0; page < PDDocGetNumPages(mydoc); ++page) - { - //Must be called before we call PDWordFinderGetNthWord. - PDWordFinderAcquireWordList(wordFinder, page, wordList, NULL, NULL, &numWordsFound); - - for (int nextWordIndex = 0; nextWordIndex < numWordsFound; ++nextWordIndex) - { - PDWord nextWord = PDWordFinderGetNthWord(wordFinder, nextWordIndex); - if ( searchWord(nextWord, csSearchWord.c_str() ) ) - { - WordLocation wl ( page ); - // The text of the word. - ASText nextWordText = ASTextNew(); - PDWordGetASText(nextWord, 0, nextWordText); - wl.m_text = nextWordText; - // Its quads: The word might be split up into several quads (e.g., if it's - // hyphenated), and we want the last set. - ASInt16 nQuads = PDWordGetNumQuads(nextWord); - ASFixedQuad quad; - PDWordGetNthQuad(nextWord, nQuads - 1, &quad); - ASFixedRect partialWord; - //The left location of the box lines up with the horizontal coordinate of the top-left point. - partialWord.left = quad.tl.h; - //The top location of the box lines up with the vertical coordinate of the top-left pont. - partialWord.top = quad.tl.v; - wl.m_loc = partialWord; - vWords.push_back ( wl ); + APDFLDoc APDoc(csInputFileName.c_str(), true); + PDDoc mydoc = APDoc.getPDDoc(); + + // Step 1) Find each occurrence of target word in the document and record the location and text + + std::vector vWords; + + // We'll use the PDWordFinder class to iterate through our document's words, looking for target word. + PDWordFinder wordFinder = PDDocCreateWordFinderUCS(mydoc, WF_LATEST_VERSION, 0, NULL); + + // Our PDWordFinder will iterate through the words with this. We will not directly access it. + PDWord *wordList = new PDWord(); + ASInt32 numWordsFound(0); + + // Search all words in each page of the document. It is assumed that no word will span pages. + for (int page = 0; page < PDDocGetNumPages(mydoc); ++page) { + // Must be called before we call PDWordFinderGetNthWord. + PDWordFinderAcquireWordList(wordFinder, page, wordList, NULL, NULL, &numWordsFound); + + for (int nextWordIndex = 0; nextWordIndex < numWordsFound; ++nextWordIndex) { + PDWord nextWord = PDWordFinderGetNthWord(wordFinder, nextWordIndex); + if (searchWord(nextWord, csSearchWord.c_str())) { + WordLocation wl(page); + // The text of the word. + ASText nextWordText = ASTextNew(); + PDWordGetASText(nextWord, 0, nextWordText); + wl.m_text = nextWordText; + // Its quads: The word might be split up into several quads (e.g., if it's + // hyphenated), and we want the last set. + ASInt16 nQuads = PDWordGetNumQuads(nextWord); + ASFixedQuad quad; + PDWordGetNthQuad(nextWord, nQuads - 1, &quad); + ASFixedRect partialWord; + // The left location of the box lines up with the horizontal coordinate of the top-left point. + partialWord.left = quad.tl.h; + // The top location of the box lines up with the vertical coordinate of the top-left pont. + partialWord.top = quad.tl.v; + wl.m_loc = partialWord; + vWords.push_back(wl); + } } + // Prepare to iterate over the word list for the next page. + PDWordFinderReleaseWordList(wordFinder, page); } - //Prepare to iterate over the word list for the next page. - PDWordFinderReleaseWordList(wordFinder, page); - } - // Un-comment these lines if you wish to print out the words found - //std::vector::iterator it2, it2End = vWords.end(); - //for ( it2 = vWords.begin(); it2 != it2End; ++it2 ) - //{ - // ASText partialText = it2->m_text; - // ASInt32 wordLen = 0; - // //Unicode text will probably not display correctly. Rest assured it will look fine in the document. - // std::cout << "page " << it2->m_page << " " << ASTextGetPDTextCopy(partialText, &wordLen) << std::endl; - // } - -//Step 2) Create a bookmark for each occurrence of target word with this information. - - // We'll create each bookmark by iterating over the subheadings. - // The bookmark's text will be the subheading's text, - // And the bookmark's action will be to bring the reader to - // the location of that subheading. - - //Bookmarks are added to a document's bookmark root. - PDBookmark bookMarkRoot = PDDocGetBookmarkRoot(mydoc); - - std::vector::iterator it, itEnd = vWords.end(); - for ( it = vWords.begin(); it != itEnd; ++it ) - { - //Get the necessary information. - PDPage nextPage = APDoc.getPage(it->m_page); - - ASFixedRect* nextLocation = &(it->m_loc); - - //Make the bookmark and set its action; they must be created before their action is set. - PDBookmark nextbm = PDBookmarkAddNewChildASText(bookMarkRoot, it->m_text); - - //We create a View Destination pointing to the location of the subheading, and then create an action - //which will take the reader to that destination. - PDViewDestination nextDestination = PDViewDestCreate ( - mydoc, - nextPage, - ASAtomFromString("XYZ"), //View Destination Fit Type - nextLocation, //Pointer to the location rectangle we want. - Int16ToFixed(0), //Zoom factor. 0 means to inherit the current zoom factor - 0); //Unused argument - - //The first and third arguments are the source PDDoc and the destination PDDoc, respectively. - //They must the the same. - PDAction nextDestAct = PDActionNewFromDest(mydoc,nextDestination,mydoc); - - PDBookmarkSetAction(nextbm, nextDestAct); //Give the bookmark its action! - PDPageRelease(nextPage); - } + // Un-comment these lines if you wish to print out the words found + // std::vector::iterator it2, it2End = vWords.end(); + // for ( it2 = vWords.begin(); it2 != it2End; ++it2 ) + //{ + // ASText partialText = it2->m_text; + // ASInt32 wordLen = 0; + // //Unicode text will probably not display correctly. Rest assured it will look fine in the document. + // std::cout << "page " << it2->m_page << " " << ASTextGetPDTextCopy(partialText, &wordLen) << std::endl; + // } + + // Step 2) Create a bookmark for each occurrence of target word with this information. + + // We'll create each bookmark by iterating over the subheadings. + // The bookmark's text will be the subheading's text, + // And the bookmark's action will be to bring the reader to + // the location of that subheading. + + // Bookmarks are added to a document's bookmark root. + PDBookmark bookMarkRoot = PDDocGetBookmarkRoot(mydoc); + + std::vector::iterator it, itEnd = vWords.end(); + for (it = vWords.begin(); it != itEnd; ++it) { + // Get the necessary information. + PDPage nextPage = APDoc.getPage(it->m_page); + + ASFixedRect *nextLocation = &(it->m_loc); + + // Make the bookmark and set its action; they must be created before their action is set. + PDBookmark nextbm = PDBookmarkAddNewChildASText(bookMarkRoot, it->m_text); + + // We create a View Destination pointing to the location of the subheading, and then + // create an action which will take the reader to that destination. + PDViewDestination nextDestination = + PDViewDestCreate(mydoc, nextPage, + ASAtomFromString("XYZ"), // View Destination Fit Type + nextLocation, // Pointer to the location rectangle we want. + Int16ToFixed(0), // Zoom factor. 0 means to inherit the current zoom factor + 0); // Unused argument + + // The first and third arguments are the source PDDoc and the destination PDDoc, + // respectively. They must the the same. + PDAction nextDestAct = PDActionNewFromDest(mydoc, nextDestination, mydoc); + + PDBookmarkSetAction(nextbm, nextDestAct); // Give the bookmark its action! + PDPageRelease(nextPage); + } -//Step 3) Demonstrate different zoom levels. - - ASInt32 numZoomBookmarks ( 0 ); - if ( vWords.size() > 0 ) - { - // We will add a few children bookmarks to the first bookmark (if there was one) - // that we created, which all copy that bookmark at different zoom levels. - - PDBookmark parentBm = PDBookmarkGetFirstChild(PDDocGetBookmarkRoot(mydoc)); - PDBookmark zoom100 = PDBookmarkAddNewChild(parentBm, "100% Zoom"); - PDBookmark zoom200 = PDBookmarkAddNewChild(parentBm, "200% Zoom"); - PDBookmark zoom800 = PDBookmarkAddNewChild(parentBm, "800% Zoom"); - PDBookmark zoom40 = PDBookmarkAddNewChild(parentBm, "40% Zoom"); - - numZoomBookmarks = 4; - PDBookmark zoomBookmarks[] = {zoom100, zoom200, zoom800, zoom40}; - ASFloat zoomFactors[] = {1.0, 2.0, 8.0, 0.40}; - - //Copy the attributes of the parent bookmark. - ASInt32 pageNumber; - ASAtom fitType; - ASFixedRect locationRect; - ASFixed zoomFactor; - PDViewDestination parentViewDestination = PDActionGetDest(PDBookmarkGetAction(parentBm)); - - PDViewDestGetAttr(parentViewDestination, &pageNumber, &fitType, &locationRect, &zoomFactor); - - //Set each bookmark's view destination per the above array. - PDPage parentPage = APDoc.getPage(pageNumber); - for (int i = 0; i < numZoomBookmarks; ++i) - { - PDViewDestination nextView = PDViewDestCreate ( - mydoc, parentPage, fitType, - &locationRect, ASFloatToFixed(zoomFactors[i]), 0 ); - PDAction nextAction = PDActionNewFromDest(mydoc, nextView, mydoc); - PDBookmarkSetAction(zoomBookmarks[i],nextAction); + // Step 3) Demonstrate different zoom levels. + + ASInt32 numZoomBookmarks(0); + if (vWords.size() > 0) { + // We will add a few children bookmarks to the first bookmark (if there was one) + // that we created, which all copy that bookmark at different zoom levels. + + PDBookmark parentBm = PDBookmarkGetFirstChild(PDDocGetBookmarkRoot(mydoc)); + PDBookmark zoom100 = PDBookmarkAddNewChild(parentBm, "100% Zoom"); + PDBookmark zoom200 = PDBookmarkAddNewChild(parentBm, "200% Zoom"); + PDBookmark zoom800 = PDBookmarkAddNewChild(parentBm, "800% Zoom"); + PDBookmark zoom40 = PDBookmarkAddNewChild(parentBm, "40% Zoom"); + + numZoomBookmarks = 4; + PDBookmark zoomBookmarks[] = {zoom100, zoom200, zoom800, zoom40}; + ASFloat zoomFactors[] = {1.0f, 2.0f, 8.0f, 0.40f}; + + // Copy the attributes of the parent bookmark. + ASInt32 pageNumber; + ASAtom fitType; + ASFixedRect locationRect; + ASFixed zoomFactor; + PDViewDestination parentViewDestination = PDActionGetDest(PDBookmarkGetAction(parentBm)); + + PDViewDestGetAttr(parentViewDestination, &pageNumber, &fitType, &locationRect, &zoomFactor); + + // Set each bookmark's view destination per the above array. + PDPage parentPage = APDoc.getPage(pageNumber); + for (int i = 0; i < numZoomBookmarks; ++i) { + PDViewDestination nextView = PDViewDestCreate(mydoc, parentPage, fitType, &locationRect, + ASFloatToFixed(zoomFactors[i]), 0); + PDAction nextAction = PDActionNewFromDest(mydoc, nextView, mydoc); + PDBookmarkSetAction(zoomBookmarks[i], nextAction); + } + + PDPageRelease(parentPage); } - PDPageRelease(parentPage); - } + // Step 5) Save and close the document. -//Step 5) Save and close the document. - - std::cout << " --> Bookmarked " << vWords.size() << " occurrences, and added " - << numZoomBookmarks << " zoom bookmarks\n"; - // Release objects - for ( it = vWords.begin(); it != itEnd; ++it ) - { - ASTextDestroy ( it->m_text ); - } + std::cout << " --> Bookmarked " << vWords.size() << " occurrences, and added " + << numZoomBookmarks << " zoom bookmarks\n"; + // Release objects + for (it = vWords.begin(); it != itEnd; ++it) { + ASTextDestroy(it->m_text); + } - APDoc.saveDoc( csOutputFileName.c_str() ); + APDoc.saveDoc(csOutputFileName.c_str()); HANDLER errCode = ERRORCODE; @@ -219,20 +206,16 @@ int main(int argc, char** argv) }; // The word-matching function. Note that it is case sensitive! -bool searchWord(PDWord nextWord, const char* target) -{ +bool searchWord(PDWord nextWord, const char *target) { ASText nextWordASText = ASTextNew(); PDWordGetASText(nextWord, 0, nextWordASText); ASInt32 wordLen = 0; - char * nextWordChar = ASTextGetPDTextCopy(nextWordASText, &wordLen); - if (strlen(nextWordChar) < strlen(target)) - { - return false; + char *nextWordChar = ASTextGetPDTextCopy(nextWordASText, &wordLen); + if (strlen(nextWordChar) < strlen(target)) { + return false; } - for (unsigned int index = 0; index < strlen(target); index++) - { - if (nextWordChar[index] != target[index]) - { + for (unsigned int index = 0; index < strlen(target); index++) { + if (nextWordChar[index] != target[index]) { return false; } } diff --git a/CPlusPlus/Sample_Source/ContentModification/AddLinks/AddLinks.cpp b/CPlusPlus/Sample_Source/ContentModification/AddLinks/AddLinks.cpp index a5d858be..792f2b7c 100644 --- a/CPlusPlus/Sample_Source/ContentModification/AddLinks/AddLinks.cpp +++ b/CPlusPlus/Sample_Source/ContentModification/AddLinks/AddLinks.cpp @@ -8,7 +8,7 @@ // // Command-line: (Both optional) // -// For more detail see the description of the AddLinks sample program on our Developer’s site, +// For more detail see the description of the AddLinks sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#addlinks #include @@ -29,267 +29,260 @@ // Helper function to create and display the text "Click Me" onto a page given the x and y position. static PDEText clickMeTextMaker(double xPos, double yPos); -int main(int argc, char** argv) -{ +int main(int argc, char **argv) { APDFLib lib; ASErrorCode errCode = 0; - if (lib.isValid() == false) - { + if (lib.isValid() == false) { errCode = lib.getInitError(); std::cout << "Initialization failed with code " << errCode << std::endl; return lib.getInitError(); } - - std::string csInputFileName ( argc > 1 ? argv[1] : DIR_LOC DEF_INPUT ); - std::string csOutputFileName ( argc > 2 ? argv[2] : DEF_OUTPUT ); - std::cout << "Adding 3 hyperlinks to file " << csInputFileName.c_str() - << " and saving to " << csOutputFileName.c_str() << std::endl; -DURING + std::string csInputFileName(argc > 1 ? argv[1] : DIR_LOC DEF_INPUT); + std::string csOutputFileName(argc > 2 ? argv[2] : DEF_OUTPUT); + std::cout << "Adding 3 hyperlinks to file " << csInputFileName.c_str() << " and saving to " + << csOutputFileName.c_str() << std::endl; - // Open document and fetch the first page and its content object - APDFLDoc inDoc ( csInputFileName.c_str(), true); - CosDoc inputDocCosDoc = PDDocGetCosDoc(inDoc.pdDoc); - PDPage page1 = PDDocAcquirePage(inDoc.pdDoc, 0); - PDEContent pageContent = PDPageAcquirePDEContent(page1, NULL); + DURING -// Step 1) Create, set up, and place a link that will open a file. + // Open document and fetch the first page and its content object + APDFLDoc inDoc(csInputFileName.c_str(), true); + CosDoc inputDocCosDoc = PDDocGetCosDoc(inDoc.pdDoc); + PDPage page1 = PDDocAcquirePage(inDoc.pdDoc, 0); + PDEContent pageContent = PDPageAcquirePDEContent(page1, NULL); - //Create a text object which displays "Click Me" at the given location - PDEText clickMeText1 = clickMeTextMaker(72 * 6.48, 72 * 7.1); + // Step 1) Create, set up, and place a link that will open a file. - //Add this text object to the page's content - PDEContentAddElem(pageContent, kPDEAfterLast, (PDEElement)clickMeText1); + // Create a text object which displays "Click Me" at the given location + PDEText clickMeText1 = clickMeTextMaker(72 * 6.48, 72 * 7.1); - //Set up the annotation's bounds. 72 pixels represent one inch. - ASFixedRect annotLocation; - PDETextGetBBox(clickMeText1, kPDETextRun, 0, &annotLocation); + // Add this text object to the page's content + PDEContentAddElem(pageContent, kPDEAfterLast, (PDEElement)clickMeText1); - PDERelease(reinterpret_cast(clickMeText1)); + // Set up the annotation's bounds. 72 pixels represent one inch. + ASFixedRect annotLocation; + PDETextGetBBox(clickMeText1, kPDETextRun, 0, &annotLocation); - //Create a file attachment annotation with the input page and bounds - PDAnnot fileAnnot = PDPageCreateAnnot(page1, ASAtomFromString("FileAttachment"), &annotLocation); + PDERelease(reinterpret_cast(clickMeText1)); - //Add the annotation as the first annotation on the page. - PDPageAddAnnot(page1, 0, fileAnnot); + // Create a file attachment annotation with the input page and bounds + PDAnnot fileAnnot = PDPageCreateAnnot(page1, ASAtomFromString("FileAttachment"), &annotLocation); - //Cast the file attachment annotation as a link. - PDLinkAnnot fileLink = CastToPDLinkAnnot(fileAnnot); + // Add the annotation as the first annotation on the page. + PDPageAddAnnot(page1, 0, fileAnnot); - //Make the link's border invisible - PDLinkAnnotBorder linkBorder; - linkBorder.hCornerRadius = 0; - linkBorder.vCornerRadius = 0; - linkBorder.width = 0; - linkBorder.dashArrayLen = 0; - PDLinkAnnotSetBorder(fileLink, &linkBorder); + // Cast the file attachment annotation as a link. + PDLinkAnnot fileLink = CastToPDLinkAnnot(fileAnnot); - //Create a cos dictionary object to hold attributes of the link. - CosObj fileLinkDict = CosNewDict(inputDocCosDoc, false, 2); + // Make the link's border invisible + PDLinkAnnotBorder linkBorder; + linkBorder.hCornerRadius = 0; + linkBorder.vCornerRadius = 0; + linkBorder.width = 0; + linkBorder.dashArrayLen = 0; + PDLinkAnnotSetBorder(fileLink, &linkBorder); - //Using the file specification key "F" set up the file input path - CosDictPut ( fileLinkDict, - ASAtomFromString("F"), - CosNewString(inputDocCosDoc, false, "../../../../Resources/Sample_Input/DOCXLink.docx", strlen("../../../../Resources/Sample_Input/DOCXLink.docx"))); + // Create a cos dictionary object to hold attributes of the link. + CosObj fileLinkDict = CosNewDict(inputDocCosDoc, false, 2); - //Using the name key "S" set the type to a Launch for opening the file - CosDictPut ( fileLinkDict, - ASAtomFromString("S"), - CosNewName(inputDocCosDoc, false, ASAtomFromString("Launch"))); + // Using the file specification key "F" set up the file input path + CosDictPut(fileLinkDict, ASAtomFromString("F"), + CosNewString(inputDocCosDoc, false, "../../../../Resources/Sample_Input/DOCXLink.docx", + strlen("../../../../Resources/Sample_Input/DOCXLink.docx"))); - PDAction fileLinkAction = PDActionFromCosObj(fileLinkDict); - //Set up an action object with the given attributes from the dictionary. + // Using the name key "S" set the type to a Launch for opening the file + CosDictPut(fileLinkDict, ASAtomFromString("S"), + CosNewName(inputDocCosDoc, false, ASAtomFromString("Launch"))); - //Set the action to the link. - PDLinkAnnotSetAction(fileLink, fileLinkAction); + PDAction fileLinkAction = PDActionFromCosObj(fileLinkDict); + // Set up an action object with the given attributes from the dictionary. - //Get the cos object from the link. - CosObj fileLinkObj = PDAnnotGetCosObj(fileLink); + // Set the action to the link. + PDLinkAnnotSetAction(fileLink, fileLinkAction); - //Set the cos object type to the subtype, link. - CosDictPutKeyString(fileLinkObj, "Subtype", CosNewNameFromString(inputDocCosDoc, false, "Link")); + // Get the cos object from the link. + CosObj fileLinkObj = PDAnnotGetCosObj(fileLink); -// Step 2) Create, set up, and place a link that will move to a new location. + // Set the cos object type to the subtype, link. + CosDictPutKeyString(fileLinkObj, "Subtype", CosNewNameFromString(inputDocCosDoc, false, "Link")); - //Create a text object which displays "Click Me" at the given location + // Step 2) Create, set up, and place a link that will move to a new location. + + // Create a text object which displays "Click Me" at the given location PDEText clickMeText2 = clickMeTextMaker(72 * 6.48, 72 * 6.3); PDEContentAddElem(pageContent, kPDEAfterLast, (PDEElement)clickMeText2); PDERelease(reinterpret_cast(clickMeText2)); - //Set up the annotation's bounds + // Set up the annotation's bounds PDETextGetBBox(clickMeText2, kPDETextRun, 0, &annotLocation); - //Create a new destination annotation with the input page and bounds + // Create a new destination annotation with the input page and bounds PDAnnot newDestAnnot = PDPageCreateAnnot(page1, ASAtomFromString("Text"), &annotLocation); - //Add the annotation as the second annotation on the page. - PDPageAddAnnot(page1, 1, newDestAnnot); + // Add the annotation as the second annotation on the page. + PDPageAddAnnot(page1, 1, newDestAnnot); - //Cast the file attachment annotation as a link. - PDLinkAnnot newDestLink = CastToPDLinkAnnot(newDestAnnot); + // Cast the file attachment annotation as a link. + PDLinkAnnot newDestLink = CastToPDLinkAnnot(newDestAnnot); - //Set the link's border to the previously made invisible border. - PDLinkAnnotSetBorder(newDestLink, &linkBorder); + // Set the link's border to the previously made invisible border. + PDLinkAnnotSetBorder(newDestLink, &linkBorder); - //Create an instance of the page to jump to. - PDPage destPage = PDDocAcquirePage(inDoc.pdDoc, 2); + // Create an instance of the page to jump to. + PDPage destPage = PDDocAcquirePage(inDoc.pdDoc, 2); - //Get the bounds of that page + // Get the bounds of that page ASFixedRect bounds; PDPageGetBBox(destPage, &bounds); - //Create a View Destination pointing to the location desired along with different settings - PDViewDestination nextDestination = PDViewDestCreate ( - inDoc.pdDoc, destPage, //The source document and destination page. - ASAtomFromString("XYZ"), //Fit Type, set to the upper-left corner. - &bounds, //Pointer to the location rectangle we want. - PDViewDestNULL, //Zoom factor. 0 means to inherit the current zoom factor. - 0); //Unused argument. + // Create a View Destination pointing to the location desired along with different settings + PDViewDestination nextDestination = + PDViewDestCreate(inDoc.pdDoc, destPage, // The source document and destination page. + ASAtomFromString("XYZ"), // Fit Type, set to the upper-left corner. + &bounds, // Pointer to the location rectangle we want. + PDViewDestNULL, // Zoom factor. 0 means to inherit the current zoom factor. + 0); // Unused argument. PDPageRelease(destPage); - //Create an action representing the destination. - PDAction nextDestAct = PDActionNewFromDest(inDoc.pdDoc, nextDestination, inDoc.pdDoc); + // Create an action representing the destination. + PDAction nextDestAct = PDActionNewFromDest(inDoc.pdDoc, nextDestination, inDoc.pdDoc); - //Set the action to the link. - PDLinkAnnotSetAction(newDestLink, nextDestAct); + // Set the action to the link. + PDLinkAnnotSetAction(newDestLink, nextDestAct); - //Get the cos object from the link. - CosObj newDestLinkObj = PDAnnotGetCosObj(newDestLink); + // Get the cos object from the link. + CosObj newDestLinkObj = PDAnnotGetCosObj(newDestLink); - //Set the cos object type to the subtype, link. - CosDictPutKeyString(newDestLinkObj, "Subtype", CosNewNameFromString(inputDocCosDoc, false, "Link")); + // Set the cos object type to the subtype, link. + CosDictPutKeyString(newDestLinkObj, "Subtype", CosNewNameFromString(inputDocCosDoc, false, "Link")); -// Step 3) Create, set up, and place a link the will open a webpage. + // Step 3) Create, set up, and place a link the will open a webpage. - //Create a text object which displays "Click Me" at the given location + // Create a text object which displays "Click Me" at the given location PDEText clickMeText3 = clickMeTextMaker(72 * 6.48, 72 * 5.5); PDEContentAddElem(pageContent, kPDEAfterLast, (PDEElement)clickMeText3); PDERelease(reinterpret_cast(clickMeText3)); - //Set up the annotation's bounds + // Set up the annotation's bounds PDETextGetBBox(clickMeText3, kPDETextRun, 0, &annotLocation); - PDAnnot URIAnnot = PDPageCreateAnnot(page1, ASAtomFromString("Text"), &annotLocation); + PDAnnot URIAnnot = PDPageCreateAnnot(page1, ASAtomFromString("Text"), &annotLocation); - //Add the annotation as the third annotation on the page. - PDPageAddAnnot(page1, 1, URIAnnot); + // Add the annotation as the third annotation on the page. + PDPageAddAnnot(page1, 1, URIAnnot); - //Cast the file attachment annotation as a link. - PDLinkAnnot URILink = CastToPDLinkAnnot(URIAnnot); + // Cast the file attachment annotation as a link. + PDLinkAnnot URILink = CastToPDLinkAnnot(URIAnnot); - //Let's try out a border this time... + // Let's try out a border this time... linkBorder.width = 2; - PDLinkAnnotSetBorder(URILink, &linkBorder); + PDLinkAnnotSetBorder(URILink, &linkBorder); + + // Create a cos dictionary object to hold attributes of the link. + CosObj URIDict = CosNewDict(inputDocCosDoc, false, 2); - //Create a cos dictionary object to hold attributes of the link. - CosObj URIDict = CosNewDict(inputDocCosDoc, false, 2); - - //Using the name key "S" set up the URI type - CosDictPut ( URIDict, - ASAtomFromString("S"), - CosNewName(inputDocCosDoc, false, ASAtomFromString("URI"))); + // Using the name key "S" set up the URI type + CosDictPut(URIDict, ASAtomFromString("S"), CosNewName(inputDocCosDoc, false, ASAtomFromString("URI"))); - //Using the URI key "URI" set up the desired path - CosDictPut ( URIDict, - ASAtomFromString("URI"), - CosNewString(inputDocCosDoc, false, "http://www.datalogics.com", strlen("http://www.datalogics.com"))); + // Using the URI key "URI" set up the desired path + CosDictPut(URIDict, ASAtomFromString("URI"), + CosNewString(inputDocCosDoc, false, "http://www.datalogics.com", + strlen("http://www.datalogics.com"))); - //Set up an action object with the given attributes from the dictionary. - PDAction newPdAction = PDActionFromCosObj(URIDict); + // Set up an action object with the given attributes from the dictionary. + PDAction newPdAction = PDActionFromCosObj(URIDict); - //Set the action to the link. - PDLinkAnnotSetAction(URILink, newPdAction); + // Set the action to the link. + PDLinkAnnotSetAction(URILink, newPdAction); - //Get the cos object from the link. - CosObj URILinkObj = PDAnnotGetCosObj(URILink); + // Get the cos object from the link. + CosObj URILinkObj = PDAnnotGetCosObj(URILink); - //Set the cos object type to the subtype, link. - CosDictPutKeyString(URILinkObj, "Subtype", CosNewNameFromString(inputDocCosDoc, false, "Link")); + // Set the cos object type to the subtype, link. + CosDictPutKeyString(URILinkObj, "Subtype", CosNewNameFromString(inputDocCosDoc, false, "Link")); -// Step 4) Save and close. + // Step 4) Save and close. - PDPageSetPDEContentCanRaise(page1, NULL); //Set the content back into the page. + PDPageSetPDEContentCanRaise(page1, NULL); // Set the content back into the page. - //Page and content released before closing the document. + // Page and content released before closing the document. PDPageReleasePDEContent(page1, NULL); PDPageRelease(page1); - inDoc.saveDoc ( csOutputFileName.c_str() ); - -HANDLER - errCode = ERRORCODE; - lib.displayError(errCode); //If there was an error, display it. -END_HANDLER + inDoc.saveDoc(csOutputFileName.c_str()); - return errCode; //Returns program status. + HANDLER + errCode = ERRORCODE; + lib.displayError(errCode); // If there was an error, display it. + END_HANDLER + + return errCode; // Returns program status. } // PDEText Function: Creates and displays the text "Click Me" onto a pdf page given the x and y position -PDEText clickMeTextMaker(double xPos, double yPos) -{ +PDEText clickMeTextMaker(double xPos, double yPos) { PDEFontAttrs fontAttrs; memset(&fontAttrs, 0, sizeof(fontAttrs)); - //Set the font name and type. - fontAttrs.name = ASAtomFromString("CourierStd"); + // Set the font name and type. + fontAttrs.name = ASAtomFromString("CourierStd"); fontAttrs.type = ASAtomFromString("Type1"); - //Locate the system font that corresponds to the PDEFontAttrs struct we just set. + // Locate the system font that corresponds to the PDEFontAttrs struct we just set. PDSysFont sysFont = PDFindSysFont(&fontAttrs, sizeof(fontAttrs), 0); - //Create the CourierStd Type1 font with embed flag set. + // Create the CourierStd Type1 font with embed flag set. PDEFont courierFont = PDEFontCreateFromSysFont(sysFont, kPDEFontCreateEmbedded); std::string textToDisplay = " Click Me "; - - ASDoubleMatrix textMatrix; //Transformation matrix for location of the text - memset(&textMatrix, 0, sizeof(textMatrix)); //Clear structure. - textMatrix.a = 10; //Set font width and height. - textMatrix.d = 10; //Set font point size. - textMatrix.h = xPos; //x coordinate on page (72 pixels = 1 inch). - textMatrix.v = yPos; //y coordinate on page. + ASDoubleMatrix textMatrix; // Transformation matrix for location of the text + memset(&textMatrix, 0, sizeof(textMatrix)); // Clear structure. + textMatrix.a = 10; // Set font width and height. + textMatrix.d = 10; // Set font point size. + textMatrix.h = xPos; // x coordinate on page (72 pixels = 1 inch). + textMatrix.v = yPos; // y coordinate on page. PDEGraphicState gState; PDEDefaultGState(&gState, sizeof(PDEGraphicState)); - //Release the stroke color space before modifying it. + // Release the stroke color space before modifying it. PDERelease(reinterpret_cast(gState.fillColorSpec.space)); - //Set color to blue. + // Set color to blue. ASFixed red = ASFloatToFixed(0); ASFixed green = ASFloatToFixed(0); ASFixed blue = ASFloatToFixed(1); - //Set the RGB color space. + // Set the RGB color space. gState.fillColorSpec.space = PDEColorSpaceCreateFromName(ASAtomFromString("DeviceRGB")); - //Set up the color space values to form the wanted color. + // Set up the color space values to form the wanted color. gState.fillColorSpec.value.color[0] = red; gState.fillColorSpec.value.color[1] = green; gState.fillColorSpec.value.color[2] = blue; PDEText textObj = PDETextCreate(); - //Adding the text run to the PDE text object. + // Adding the text run to the PDE text object. PDETextState tState; - memset ( &tState, 0, sizeof(tState) ); - PDETextAddEx(textObj, //Text container to add to. - kPDETextRun, //kPDETextRun or kPDETextChar for text runs or text characters. - 0, //The index after which to add the text run. - (Uns8 *)textToDisplay.c_str(), //Text to add. - textToDisplay.length(), //Length of text. - courierFont, //Font to apply to text. - &gState, sizeof(gState), //PDEGraphicState and its size. Contains attributes of the text object. - &tState, 0, //Text state and its size .Contains attributes of the text object. - &textMatrix, //Matrix containing size and location for the text. - NULL); //Stroke matrix for the line width when stroking text. - - //Release used objects + memset(&tState, 0, sizeof(tState)); + PDETextAddEx(textObj, // Text container to add to. + kPDETextRun, // kPDETextRun or kPDETextChar for text runs or text characters. + 0, // The index after which to add the text run. + (Uns8 *)textToDisplay.c_str(), // Text to add. + static_cast(textToDisplay.length()), // Length of text. + courierFont, // Font to apply to text. + &gState, sizeof(gState), // PDEGraphicState and its size. Contains attributes of the text object. + &tState, 0, // Text state and its size .Contains attributes of the text object. + &textMatrix, // Matrix containing size and location for the text. + NULL); // Stroke matrix for the line width when stroking text. + + // Release used objects PDERelease(reinterpret_cast(courierFont)); PDERelease(reinterpret_cast(gState.strokeColorSpec.space)); PDERelease(reinterpret_cast(gState.fillColorSpec.space)); diff --git a/CPlusPlus/Sample_Source/ContentModification/AddPageNumbers/AddPageNumbers.cpp b/CPlusPlus/Sample_Source/ContentModification/AddPageNumbers/AddPageNumbers.cpp index 67082930..dcdeefcb 100644 --- a/CPlusPlus/Sample_Source/ContentModification/AddPageNumbers/AddPageNumbers.cpp +++ b/CPlusPlus/Sample_Source/ContentModification/AddPageNumbers/AddPageNumbers.cpp @@ -4,12 +4,12 @@ // For complete copyright information, refer to: // http://dev.datalogics.com/adobe-pdf-library/license-for-downloaded-pdf-samples/ // -// AddPageNumbers adds labels to the page numbers in a PDF document. These labels appear under the +// AddPageNumbers adds labels to the page numbers in a PDF document. These labels appear under the // page thumbnails. // // Command-line: (Both optional) // -// For more detail see the description of the AddPageNumbers sample program on our Developer’s site, +// For more detail see the description of the AddPageNumbers sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#addpagenumbers #include "InitializeLibrary.h" @@ -21,59 +21,57 @@ #define DEF_INPUT "toNumber.pdf" #define DEF_OUTPUT "AddPageNumbers-out.pdf" -int main(int argc, char** argv) -{ +int main(int argc, char **argv) { APDFLib lib; ASErrorCode errCode = 0; - if (lib.isValid() == false) - { + if (lib.isValid() == false) { errCode = lib.getInitError(); std::cout << "Initialization failed with code " << errCode << std::endl; return errCode; } - std::string csInputFileName ( argc > 1 ? argv[1] : INPUT_LOC DEF_INPUT ); - std::string csOutputFileName ( argc > 2 ? argv[2] : DEF_OUTPUT ); + std::string csInputFileName(argc > 1 ? argv[1] : INPUT_LOC DEF_INPUT); + std::string csOutputFileName(argc > 2 ? argv[2] : DEF_OUTPUT); std::cout << "Will add some page labels and numbers to " << csInputFileName.c_str() << " and save as " << csOutputFileName.c_str() << std::endl; -DURING + DURING -// Step 1) Open the Document that will have labels added to. + // Step 1) Open the Document that will have labels added to. - APDFLDoc document ( csInputFileName.c_str(), true ); - PDDoc pdDoc = document.getPDDoc(); + APDFLDoc document(csInputFileName.c_str(), true); + PDDoc pdDoc = document.getPDDoc(); -// Step 2) Create label's for different sets of pages + // Step 2) Create label's for different sets of pages - // NOTE: PDPageLabel() takes in a style key: - // "R" for upper-case Roman numbers, - // "r" for lower-case Roman numbers, - // "A" for upper-case alphabetic numbers, - // "a" for lower-case alphabetic numbers, or - // "D" for decimal Arabic numerals. + // NOTE: PDPageLabel() takes in a style key: + // "R" for upper-case Roman numbers, + // "r" for lower-case Roman numbers, + // "A" for upper-case alphabetic numbers, + // "a" for lower-case alphabetic numbers, or + // "D" for decimal Arabic numerals. - //Set the first page's label to "Cover" with the number counter to 1 - PDPageLabel coverLabel = PDPageLabelNew(pdDoc, ASAtomFromString("D"), "Cover ", 6, 1); - PDDocSetPageLabel(pdDoc, 0, coverLabel); + // Set the first page's label to "Cover" with the number counter to 1 + PDPageLabel coverLabel = PDPageLabelNew(pdDoc, ASAtomFromString("D"), "Cover ", 6, 1); + PDDocSetPageLabel(pdDoc, 0, coverLabel); - //Set the label of second page and up to "preface" with the number counter starting at 2 - PDPageLabel prefaceLabel = PDPageLabelNew(pdDoc, ASAtomFromString("r"), "preface ", 8, 2); - PDDocSetPageLabel(pdDoc, 1, prefaceLabel); + // Set the label of second page and up to "preface" with the number counter starting at 2 + PDPageLabel prefaceLabel = PDPageLabelNew(pdDoc, ASAtomFromString("r"), "preface ", 8, 2); + PDDocSetPageLabel(pdDoc, 1, prefaceLabel); - //Starting from the 5th page onwards, display pages numbers starting with 1 and upwards - PDPageLabel pageLabel = PDPageLabelNew(pdDoc, ASAtomFromString("D"), "", 0, 1); - PDDocSetPageLabel(pdDoc, 5, pageLabel); + // Starting from the 5th page onwards, display pages numbers starting with 1 and upwards + PDPageLabel pageLabel = PDPageLabelNew(pdDoc, ASAtomFromString("D"), "", 0, 1); + PDDocSetPageLabel(pdDoc, 5, pageLabel); -// Step 3) Save and exit - - document.saveDoc ( csOutputFileName.c_str(), PDSaveFull | PDSaveLinearized); + // Step 3) Save and exit -HANDLER - errCode = ERRORCODE; - lib.displayError(errCode); -END_HANDLER + document.saveDoc(csOutputFileName.c_str(), PDSaveFull | PDSaveLinearized); + + HANDLER + errCode = ERRORCODE; + lib.displayError(errCode); + END_HANDLER return errCode; } diff --git a/CPlusPlus/Sample_Source/ContentModification/EmbedFonts/EmbedFonts.cpp b/CPlusPlus/Sample_Source/ContentModification/EmbedFonts/EmbedFonts.cpp index f4ab8a3f..b376058c 100644 --- a/CPlusPlus/Sample_Source/ContentModification/EmbedFonts/EmbedFonts.cpp +++ b/CPlusPlus/Sample_Source/ContentModification/EmbedFonts/EmbedFonts.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2010-2019, Datalogics, Inc. All rights reserved. +// Copyright (c) 2010-2017, Datalogics, Inc. All rights reserved. // // For complete copyright information, see: // http://dev.datalogics.com/adobe-pdf-library/adobe-pdf-library-c-language-interface/license-for-downloaded-pdf-samples/ @@ -17,10 +17,9 @@ // subsets the characters of that font that are used in the document into that document, and // renames this newly subset font to show that it was embedded and subset. // -// For more detail see the description of the EmbedFonts sample program on our Developer’s site, +// For more detail see the description of the EmbedFonts sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#embedfonts -#include "CosCalls.h" #include "PSFCalls.h" #include "PERCalls.h" #include "PEWCalls.h" @@ -32,270 +31,170 @@ #include "EmbedFonts.h" #define INPUT_DIR "../../../../Resources/Sample_Input/" -#define INPUT_NAME "EmbedFonts-in.pdf" -#define OUTPUT_NAME "EmbedFonts-out.pdf" - -int main ( int argc, char **argv) -{ - APDFLib libInit; // Initialize the library - if (libInit.isValid() == false) - { +#define INPUT_NAME "EmbedFonts-in.pdf" +#define OUTPUT_NAME "EmbedFonts-out.pdf" + +int main(int argc, char **argv) { + APDFLib libInit; // Initialize the library + if (libInit.isValid() == false) { ASErrorCode errCode = libInit.getInitError(); APDFLib::displayError(errCode); return errCode; } - std::string csInputFileName(argc>1 ? argv[1] : INPUT_DIR INPUT_NAME); - std::string csOutputFileName(argc>2 ? argv[2] : OUTPUT_NAME); + std::string csInputFileName(argc > 1 ? argv[1] : INPUT_DIR INPUT_NAME); + std::string csOutputFileName(argc > 2 ? argv[2] : OUTPUT_NAME); std::cout << "Will embed fonts into " << csInputFileName.c_str() << " and rewrite file as " << csOutputFileName.c_str() << std::endl; - VectorOfFonts vFontsInUse; + ContainerOfFonts vFontsInUse; -DURING - // Open the input document - APDFLDoc apdflDoc ( csInputFileName.c_str(), true ); - PDDoc pdDoc = apdflDoc.getPDDoc(); + DURING - // Enumerate the fonts used in the document, and save those currently unembedded - PDDocEnumFonts(pdDoc, 0, PDDocGetNumPages(pdDoc) - 1, GetFontInfoProc, &vFontsInUse, 0, 0); + // Open the input document + APDFLDoc apdflDoc(csInputFileName.c_str(), true); + PDDoc pdDoc = apdflDoc.getPDDoc(); - // Embed a suitable system font for each font in the to-embed list - VectorOfFonts::iterator it, itE = vFontsInUse.end(); - for ( it = vFontsInUse.begin(); it != itE; ++it ) - { - EmbedSysFontForFontEntry ( *it, pdDoc); - - // Perform clean up while we're here - delete *it; - } - - // Save the PDF to a new file - apdflDoc.saveDoc ( csOutputFileName.c_str(), PDSaveFull | PDSaveCollectGarbage ); -HANDLER - APDFLib::displayError(ERRORCODE); - return ERRORCODE; -END_HANDLER - - return 0; -} + // Enumerate the fonts used in the document, and save those currently unembedded + PDDocEnumFonts(pdDoc, 0, PDDocGetNumPages(pdDoc) - 1, GetFontInfoProc, &vFontsInUse, 0, 0); -//Collect any /Differences entries from the /Encoding dictionary if any are present. -std::vector CollectEncodingDifferencesIfPresent(CosObj fontObj) -{ - std::vector differencesEncoding; - - if (CosObjGetType(fontObj) == CosDict && CosDictKnown(fontObj, ASAtomFromString("Encoding"))) - { - CosObj encodingObj = CosDictGet(fontObj, ASAtomFromString("Encoding")); - - if (CosObjGetType(encodingObj) == CosDict && CosDictKnown(encodingObj, ASAtomFromString("Differences"))) - { - CosObj differencesObj = CosDictGet(encodingObj, ASAtomFromString("Differences")); - - if (CosObjGetType(differencesObj) == CosArray) - { - //For a simple font there will only be 256 entries at most. - differencesEncoding.resize(256); - - ASInt32 differencesLength = CosArrayLength(differencesObj); - - ASInt32 codeValue = 0; - - //Walk through each array entry looking for an Integer that represents the Code Value, the Name that follows - //corresponds to that Code Value. Subsequent Names correspond to the next Code Value, and then the next Code Value, - //etc. until an Integer is found which represents a new Code Value for the following Name, etc. - for (int index = 0; index < differencesLength; index++) - { - CosObj differencesEntry = CosArrayGet(differencesObj, index); - ASInt32 differencesType = CosObjGetType(differencesEntry); - - if (differencesType == CosInteger) - { - codeValue = CosIntegerValue(differencesEntry); - } - else if (differencesType == CosName) - { - differencesEncoding[codeValue] = ASAtomGetString(CosNameValue(differencesEntry)); - codeValue++; - } - } - } - } - } + // Embed a suitable system font for each font in the to-embed list + ContainerOfFonts::iterator it, itE = vFontsInUse.end(); + for (it = vFontsInUse.begin(); it != itE; ++it) { + EmbedSysFontForFontEntry(*it, pdDoc); - return differencesEncoding; -} + // Perform clean up while we're here + delete *it; + } -void EmbedSysFontForFontEntry(struct _t_pdfUsedFont *fontEntry, PDDoc pdDoc) -{ -DURING - fontEntry->pdeFont = PDEFontCreateFromCosObj(&(fontEntry->fontCosObj) ); + // Save the PDF to a new file + apdflDoc.saveDoc(csOutputFileName.c_str(), PDSaveFull | PDSaveCollectGarbage); - // If there is a Cmap, acquire it - PDEFontAttrs attrs; - memset (&attrs, 0, sizeof (attrs)); - PDEFontGetAttrs (fontEntry->pdeFont, &attrs, sizeof (attrs)); + HANDLER + APDFLib::displayError(ERRORCODE); + return ERRORCODE; + END_HANDLER - PDSysEncoding sysEnc = NULL; - if (attrs.type == ASAtomFromString("Type0")) - { - sysEnc = PDSysEncodingCreateFromCMapName(attrs.encoding); - } - else - { - //Collect the /Differences from the /BaseEncoding if present for a simple font. - std::vector differencesEncoding = CollectEncodingDifferencesIfPresent(fontEntry->fontCosObj); + return 0; +} - sysEnc = PDSysEncodingCreateFromBaseName(attrs.encoding, differencesEncoding.size() > 0 ? &(*differencesEncoding.begin()) : NULL); - } +void EmbedSysFontForFontEntry(struct _t_pdfUsedFont *fontEntry, PDDoc pdDoc) { + DURING + fontEntry->pdeFont = PDEFontCreateFromCosObj(&(fontEntry->fontCosObj)); - fontEntry->pdSysFont = PDFindSysFontForPDEFont(fontEntry->pdeFont, kPDSysFontMatchNameAndCharSet); + // If there is a Cmap, acquire it + PDEFontAttrs attrs; + memset(&attrs, 0, sizeof(attrs)); + PDEFontGetAttrs(fontEntry->pdeFont, &attrs, sizeof(attrs)); - // If the font is not found on the system, sysFont will be 0. - if ( 0 == fontEntry->pdSysFont ) - { - std::cout << "Could not find a pdSysFont " << std::endl; - return; - } - - PDEFontSetSysFont(fontEntry->pdeFont, fontEntry->pdSysFont); + PDSysEncoding sysEnc = NULL; + if (attrs.type == ASAtomFromString("Type0")) { + sysEnc = PDSysEncodingCreateFromCMapName(attrs.encoding); + } else { + sysEnc = PDSysEncodingCreateFromBaseName(attrs.encoding, NULL); + } - // If there was a Cmap, set it as the sysencoding - if (sysEnc) - PDEFontSetSysEncoding (fontEntry->pdeFont, sysEnc); + fontEntry->pdSysFont = PDFindSysFontForPDEFont(fontEntry->pdeFont, kPDSysFontMatchNameAndCharSet); - if (attrs.cantEmbed != 0) - { - std::cout << "Font " << ASAtomGetString(attrs.name) << " cannot be embedded" << std::endl; - } - else - { - if (PDEFontIsMultiByte(fontEntry->pdeFont)) - { - // Subset embed font - PDEFont pdeFont; - if (sysEnc) - pdeFont = PDEFontCreateFromSysFontAndEncoding (fontEntry->pdSysFont, sysEnc, attrs.name, kPDEFontCreateEmbedded | kPDEFontCreateSubset); - else - pdeFont = PDEFontCreateFromSysFont(fontEntry->pdSysFont, kPDEFontCreateEmbedded | kPDEFontCreateSubset); - PDEFontSubsetNow(fontEntry->pdeFont, PDDocGetCosDoc(pdDoc)); - - PDERelease((PDEObject)pdeFont); + // If the font is not found on the system, sysFont will be 0. + if (0 == fontEntry->pdSysFont) { + std::cout << "Could not find a pdSysFont " << std::endl; + return; } - else - { - // Fully embed font - PDEFont pdeFont = PDEFontCreateFromSysFont(fontEntry->pdSysFont, kPDEFontCreateEmbedded); - PDEFontEmbedNow(fontEntry->pdeFont, PDDocGetCosDoc(pdDoc)); - PDERelease((PDEObject)pdeFont); + PDEFontSetSysFont(fontEntry->pdeFont, fontEntry->pdSysFont); + + // If there was a Cmap, set it as the sysencoding + if (sysEnc) + PDEFontSetSysEncoding(fontEntry->pdeFont, sysEnc); + + if (attrs.cantEmbed != 0) { + std::cout << "Font " << ASAtomGetString(attrs.name) << " cannot be embedded" << std::endl; + } else { + if (PDEFontIsMultiByte(fontEntry->pdeFont)) { + // Subset embed font + PDEFont pdeFont; + if (sysEnc) + pdeFont = PDEFontCreateFromSysFontAndEncoding( + fontEntry->pdSysFont, sysEnc, attrs.name, kPDEFontCreateEmbedded | kPDEFontCreateSubset); + else + pdeFont = PDEFontCreateFromSysFont(fontEntry->pdSysFont, + kPDEFontCreateEmbedded | kPDEFontCreateSubset); + PDEFontSubsetNow(fontEntry->pdeFont, PDDocGetCosDoc(pdDoc)); + + PDERelease((PDEObject)pdeFont); + } else { + // Fully embed font + PDEFont pdeFont = PDEFontCreateFromSysFont(fontEntry->pdSysFont, kPDEFontCreateEmbedded); + PDEFontEmbedNow(fontEntry->pdeFont, PDDocGetCosDoc(pdDoc)); + + PDERelease((PDEObject)pdeFont); + } } - } - if (sysEnc) - PDERelease ((PDEObject)sysEnc); - -HANDLER - APDFLib::displayError(ERRORCODE); -END_HANDLER + if (sysEnc) + PDERelease((PDEObject)sysEnc); + + HANDLER + APDFLib::displayError(ERRORCODE); + END_HANDLER } -ACCB1 ASBool ACCB2 GetFontInfoProc(PDFont pdFont, PDFontFlags *pdFontFlagsPtr, void *clientData) -{ +ACCB1 ASBool ACCB2 GetFontInfoProc(PDFont pdFont, PDFontFlags *pdFontFlagsPtr, void *clientData) { CosObj cosFont; PDEFontAttrs attrs; PDSysFont sysFont; char fontNameBuf[PSNAMESIZE]; - const char *fontSubtypeP; - char *fontNameStart = 0; - ASBool fontEmbedded = false, - fontSubset = false, - fontIsSysFont = false; -DURING - pVectorOfFonts pcf = (pVectorOfFonts)clientData; - - CosObj fontObj = PDFontGetCosObj(pdFont); - - //Check if we already have this font in our list and if we do, skip it. - for (std::vector<_t_pdfUsedFont*>::const_iterator usedFontIterator = pcf->begin(); usedFontIterator != pcf->end(); usedFontIterator++) - { - if (CosDictKnown(fontObj, ASAtomFromString("FontDescriptor"))) - { - CosObj fontDescriptorObj = CosDictGet(fontObj, ASAtomFromString("FontDescriptor")); - - if (CosObjGetType(fontDescriptorObj) == CosDict && CosObjEqual((*usedFontIterator)->fontDescriptorObj, fontDescriptorObj)) - { - return true; - } + const char *fontSubtypeP; + char *fontNameStart = 0; + ASBool fontEmbedded = false, fontSubset = false, fontIsSysFont = false; + DURING + memset(&attrs, 0, sizeof(attrs)); + + PDFontGetName(pdFont, fontNameBuf, PSNAMESIZE); + attrs.name = ASAtomFromString(fontNameBuf); + attrs.type = PDFontGetSubtype(pdFont); + fontSubtypeP = ASAtomGetString(attrs.type); + + fontEmbedded = PDFontIsEmbedded(pdFont); + // Subset test: a font was subset if the 7th character is '+' (a plus-sign), according + // to Acrobat/Reader and industry norms. + if (fontEmbedded) { + if ((strlen(fontNameBuf)) > 7 && (fontNameBuf[6] == '+')) + fontSubset = true; } - } - - memset(&attrs, 0, sizeof(attrs)); - - PDFontGetName(pdFont, fontNameBuf, PSNAMESIZE); - attrs.name = ASAtomFromString(fontNameBuf); - attrs.type = PDFontGetSubtype(pdFont); - fontSubtypeP = ASAtomGetString(attrs.type); - - fontEmbedded = PDFontIsEmbedded(pdFont); - // Subset test: a font was subset if the 7th character is '+' (a plus-sign), according - // to Acrobat/Reader and industry norms. - if (fontEmbedded) - { - if ((strlen(fontNameBuf)) > 7 && (fontNameBuf[6] == '+') ) - fontSubset = true; - } - if (fontSubset) - fontNameStart = fontNameBuf + 7; // skip the "ABCDEF+" - else - fontNameStart = fontNameBuf; - - // If the font is not found on the system, sysFont will be 0. - sysFont = PDFindSysFont(&attrs, sizeof(PDEFontAttrs), 0); - if (sysFont) - fontIsSysFont = true; - - // Print font information - std::cout << "Font " << fontNameStart << ", Subtype " << fontSubtypeP << " (" << - ( fontIsSysFont ? "" : "Not a " ) << "System Font, "; - if ( fontEmbedded ) - { - std::cout << "embedded" << ( fontSubset ? " subset" : "" ); - } - else - { - std::cout << "unembedded"; - } - std::cout << ")" << std::endl; - - // Add font to the list of fonts to be subset. This example only subsets System - // fonts that are not embedded in this PDF document. The sample will not subset fonts - // that are fully embedded in the PDF file. - if (fontIsSysFont && !fontEmbedded) - { - cosFont = PDFontGetCosObj(pdFont); - - _t_pdfUsedFont* usedFont = new _t_pdfUsedFont(cosFont); - - if (CosDictKnown(cosFont, ASAtomFromString("FontDescriptor"))) - { - CosObj cosFontDescriptor = CosDictGet(cosFont, ASAtomFromString("FontDescriptor")); - - if (CosObjGetType(cosFontDescriptor) == CosDict) - { - usedFont->fontDescriptorObj = cosFontDescriptor; - } + if (fontSubset) + fontNameStart = fontNameBuf + 7; // skip the "ABCDEF+" + else + fontNameStart = fontNameBuf; + + // If the font is not found on the system, sysFont will be 0. + sysFont = PDFindSysFont(&attrs, sizeof(PDEFontAttrs), 0); + if (sysFont) + fontIsSysFont = true; + + // Print font information + std::cout << "Font " << fontNameStart << ", Subtype " << fontSubtypeP << " (" + << (fontIsSysFont ? "" : "Not a ") << "System Font, "; + if (fontEmbedded) { + std::cout << "embedded" << (fontSubset ? " subset" : ""); + } else { + std::cout << "unembedded"; } - - pcf->push_back(usedFont); - } -HANDLER - std::cout << "Exception raised in GetFontInfoProc(): "; - APDFLib::displayError(ERRORCODE); -END_HANDLER + std::cout << ")" << std::endl; + + // Add font to the list of fonts to be subset. This example only subsets System + // fonts that are not embedded in this PDF document. The sample will not subset fonts + // that are fully embedded in the PDF file. + if (fontIsSysFont && !fontEmbedded) { + pContainerOfFonts pcf = (pContainerOfFonts)clientData; + cosFont = PDFontGetCosObj(pdFont); + pcf->push_back(new _t_pdfUsedFont(cosFont)); + } + HANDLER + std::cout << "Exception raised in GetFontInfoProc(): "; + APDFLib::displayError(ERRORCODE); + END_HANDLER return true; } - - diff --git a/CPlusPlus/Sample_Source/ContentModification/ImportPages/ImportPages.cpp b/CPlusPlus/Sample_Source/ContentModification/ImportPages/ImportPages.cpp index a11d7eb1..ca774b97 100644 --- a/CPlusPlus/Sample_Source/ContentModification/ImportPages/ImportPages.cpp +++ b/CPlusPlus/Sample_Source/ContentModification/ImportPages/ImportPages.cpp @@ -12,7 +12,7 @@ // The PDFEdit Layer (PDE) of the Adobe Acrobat API contains classes that provide for editing a variety of objects // in PDF documents, including form XObjects with this sample. // -// For more detail see the description of the ImportPages sample program on our Developer’s site, +// For more detail see the description of the ImportPages sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#importpages #include "PEWCalls.h" @@ -23,133 +23,108 @@ #include "APDFLDoc.h" #define INPUT_DIR "../../../../Resources/Sample_Input/" -#define PDF_FNAME1 "mergepdf1.pdf" -#define PDF_FNAME2 "mergepdf2.pdf" +#define PDF_FNAME1 "mergepdf1.pdf" +#define PDF_FNAME2 "mergepdf2.pdf" #define OUTPUT_FILE "importPages-out.pdf" -int main (int argc, char **argv) -{ - APDFLib libInit; // Initialize the Adobe PDF Library. The Library will terminate automatically when scope is lost. - if (libInit.isValid() == false) - { +int main(int argc, char **argv) { + APDFLib libInit; // Initialize the Adobe PDF Library. The Library will terminate automatically when scope is lost. + if (libInit.isValid() == false) { ASErrorCode errCode = libInit.getInitError(); - APDFLib::displayError ( errCode ); + APDFLib::displayError(errCode); return errCode; } - std::string csInputFile1 ( argc > 1 ? argv[1] : INPUT_DIR PDF_FNAME1 ); - std::string csInputFile2 ( argc > 2 ? argv[2] : INPUT_DIR PDF_FNAME2 ); - std::string csOutputFile ( argc > 3 ? argv[3] : OUTPUT_FILE ); - std::cout << "Will combine files " << csInputFile1.c_str() << " and " << csInputFile2.c_str() + std::string csInputFile1(argc > 1 ? argv[1] : INPUT_DIR PDF_FNAME1); + std::string csInputFile2(argc > 2 ? argv[2] : INPUT_DIR PDF_FNAME2); + std::string csOutputFile(argc > 3 ? argv[3] : OUTPUT_FILE); + std::cout << "Will combine files " << csInputFile1.c_str() << " and " << csInputFile2.c_str() << " and write to file " << csOutputFile.c_str() << std::endl; -DURING - - // Open input documents - APDFLDoc apdflDoc1 ( csInputFile1.c_str(), true ); - APDFLDoc apdflDoc2 ( csInputFile2.c_str(), true ); - PDDoc inputPDDoc1 = apdflDoc1.getPDDoc(); - PDDoc inputPDDoc2 = apdflDoc2.getPDDoc(); - - PDDoc outputPDDoc = PDDocCreate(); - CosDoc outputCosDoc = PDDocGetCosDoc(outputPDDoc); - - PDPage inputPage1 = PDDocAcquirePage(inputPDDoc1, 0); - PDPage inputPage2 = PDDocAcquirePage(inputPDDoc2, 0); - ASFixedRect inputPageRect1, inputPageRect2; - PDPageGetMediaBox(inputPage1, &inputPageRect1); - PDPageGetMediaBox(inputPage2, &inputPageRect2); - PDRotate inputRotate1 = PDPageGetRotate(inputPage1); - PDRotate inputRotate2 = PDPageGetRotate(inputPage2); - - ASFixedRect outputPageRect; - outputPageRect.left = outputPageRect.bottom = fixedZero; - outputPageRect.right = outputPageRect.top = 500 * fixedOne; - PDPage outputPDPage = PDDocCreatePage(outputPDDoc, PDBeforeFirstPage, outputPageRect); - PDEContent outputCont = PDPageAcquirePDEContent(outputPDPage, 0); - - // Position this page in the lower-left corner - ASFixedMatrix outputMatrix1; - outputMatrix1.a = ASFixedDiv((outputPageRect.right - outputPageRect.left) / 2, - (inputPageRect1.right - inputPageRect1.left)); - outputMatrix1.b = outputMatrix1.c = fixedZero; - outputMatrix1.d = ASFixedDiv((outputPageRect.top - outputPageRect.bottom) / 2, - (inputPageRect1.top - inputPageRect1.bottom)); - outputMatrix1.h = outputMatrix1.v = fixedZero; - - // If the input page was rotated 90 degrees (clockwise or counter-clockwise), - // swap the a and d values in the output matrix. The call to add the content - // will auto-rotate the created PDEForm, but the imported content needs to be - // adjusted so that the form takes up the bottom one-quarter of the page. - if ((inputRotate1 == pdRotate90) || (inputRotate1 == pdRotate270)) - { - ASFixed tempVal = outputMatrix1.a; - outputMatrix1.a = outputMatrix1.d; - outputMatrix1.d = tempVal; - } - - PDEContentAddPage(outputCont, - PDEContentGetNumElems(outputCont) - 1, - outputCosDoc, - inputPage1, - &outputMatrix1, - NULL, // ASAtom of annotation types to copy. An ASAtom object is a hashed token used to represent a string. - 0, // Flag to specify annotation types to copy (may be 0) - &inputPageRect1); // Destination bounding box - // Use NULL to use the crop box on the new page, in the output document. - - // Position this page in the upper-right corner. - ASFixedMatrix outputMatrix2; - outputMatrix2.a = ASFixedDiv((outputPageRect.right - outputPageRect.left) / 2, - (inputPageRect2.right - inputPageRect2.left)); - outputMatrix2.b = outputMatrix2.c = fixedZero; - outputMatrix2.d = ASFixedDiv((outputPageRect.top - outputPageRect.bottom) / 2, - (inputPageRect2.top - inputPageRect2.bottom)); - outputMatrix2.h = (outputPageRect.right - outputPageRect.left) / 2; - outputMatrix2.v = (outputPageRect.top - outputPageRect.bottom) / 2; - // Adjust this page's boundaries if it is also rotated. - if ((inputRotate2 == pdRotate90) || (inputRotate2 == pdRotate270)) - { - ASFixed tempVal = outputMatrix2.a; - outputMatrix2.a = outputMatrix2.d; - outputMatrix2.d = tempVal; - } - - PDEContentAddPage(outputCont, - PDEContentGetNumElems(outputCont) - 1, - outputCosDoc, - inputPage2, - &outputMatrix2, - NULL, - 0, - &inputPageRect2); - - PDPageSetPDEContent(outputPDPage, 0); - PDPageReleasePDEContent(outputPDPage, 0); - PDPageRelease(inputPage1); - PDPageRelease(inputPage2); - - ASPathName path = APDFLDoc::makePath ( csOutputFile.c_str() ); - - PDDocSaveParamsRec saveParams; - memset(&saveParams, 0, sizeof(PDDocSaveParamsRec)); - - saveParams.size = sizeof(PDDocSaveParamsRec); - saveParams.saveFlags = PDSaveFull; - saveParams.newPath = path; - saveParams.fileSys = ASGetDefaultFileSys(); - saveParams.saveFlags2 = PDSaveAddFlate | PDSaveReplaceLZW | PDSaveCompressed; - - PDDocSaveWithParams(outputPDDoc, &saveParams); - - ASFileSysReleasePath(NULL, path); - PDDocClose(outputPDDoc); - -HANDLER - APDFLib::displayError(ERRORCODE); - return ERRORCODE; -END_HANDLER + DURING + + // Open input documents + APDFLDoc apdflDoc1(csInputFile1.c_str(), true); + APDFLDoc apdflDoc2(csInputFile2.c_str(), true); + PDDoc inputPDDoc1 = apdflDoc1.getPDDoc(); + PDDoc inputPDDoc2 = apdflDoc2.getPDDoc(); + + PDDoc outputPDDoc = PDDocCreate(); + CosDoc outputCosDoc = PDDocGetCosDoc(outputPDDoc); + + PDPage inputPage1 = PDDocAcquirePage(inputPDDoc1, 0); + PDPage inputPage2 = PDDocAcquirePage(inputPDDoc2, 0); + ASFixedRect inputPageRect1, inputPageRect2; + PDPageGetMediaBox(inputPage1, &inputPageRect1); + PDPageGetMediaBox(inputPage2, &inputPageRect2); + PDRotate inputRotate1 = PDPageGetRotate(inputPage1); + PDRotate inputRotate2 = PDPageGetRotate(inputPage2); + + ASFixedRect outputPageRect; + outputPageRect.left = outputPageRect.bottom = fixedZero; + outputPageRect.right = outputPageRect.top = 500 * fixedOne; + PDPage outputPDPage = PDDocCreatePage(outputPDDoc, PDBeforeFirstPage, outputPageRect); + PDEContent outputCont = PDPageAcquirePDEContent(outputPDPage, 0); + + // Position this page in the lower-left corner + ASFixedMatrix outputMatrix1; + outputMatrix1.a = ASFixedDiv((outputPageRect.right - outputPageRect.left) / 2, + (inputPageRect1.right - inputPageRect1.left)); + outputMatrix1.b = outputMatrix1.c = fixedZero; + outputMatrix1.d = ASFixedDiv((outputPageRect.top - outputPageRect.bottom) / 2, + (inputPageRect1.top - inputPageRect1.bottom)); + outputMatrix1.h = outputMatrix1.v = fixedZero; + + // If the input page was rotated 90 degrees (clockwise or counter-clockwise), + // swap the a and d values in the output matrix. The call to add the content + // will auto-rotate the created PDEForm, but the imported content needs to be + // adjusted so that the form takes up the bottom one-quarter of the page. + if ((inputRotate1 == pdRotate90) || (inputRotate1 == pdRotate270)) { + ASFixed tempVal = outputMatrix1.a; + outputMatrix1.a = outputMatrix1.d; + outputMatrix1.d = tempVal; + } + + PDEContentAddPage( + outputCont, PDEContentGetNumElems(outputCont) - 1, outputCosDoc, inputPage1, &outputMatrix1, + NULL, // ASAtom of annotation types to copy. An ASAtom object is a hashed token used to represent a string. + 0, // Flag to specify annotation types to copy (may be 0) + &inputPageRect1); // Destination bounding box + // Use NULL to use the crop box on the new page, in the output document. + + // Position this page in the upper-right corner. + ASFixedMatrix outputMatrix2; + outputMatrix2.a = ASFixedDiv((outputPageRect.right - outputPageRect.left) / 2, + (inputPageRect2.right - inputPageRect2.left)); + outputMatrix2.b = outputMatrix2.c = fixedZero; + outputMatrix2.d = ASFixedDiv((outputPageRect.top - outputPageRect.bottom) / 2, + (inputPageRect2.top - inputPageRect2.bottom)); + outputMatrix2.h = (outputPageRect.right - outputPageRect.left) / 2; + outputMatrix2.v = (outputPageRect.top - outputPageRect.bottom) / 2; + // Adjust this page's boundaries if it is also rotated. + if ((inputRotate2 == pdRotate90) || (inputRotate2 == pdRotate270)) { + ASFixed tempVal = outputMatrix2.a; + outputMatrix2.a = outputMatrix2.d; + outputMatrix2.d = tempVal; + } + + PDEContentAddPage(outputCont, PDEContentGetNumElems(outputCont) - 1, outputCosDoc, + inputPage2, &outputMatrix2, NULL, 0, &inputPageRect2); + + PDPageSetPDEContent(outputPDPage, 0); + PDPageReleasePDEContent(outputPDPage, 0); + PDPageRelease(inputPage1); + PDPageRelease(inputPage2); + + ASPathName path = APDFLDoc::makePath(csOutputFile.c_str()); + PDDocSave(outputPDDoc, PDSaveFull, path, ASGetDefaultFileSys(), NULL, NULL); + ASFileSysReleasePath(NULL, path); + PDDocClose(outputPDDoc); + + HANDLER + APDFLib::displayError(ERRORCODE); + return ERRORCODE; + END_HANDLER return 0; } - diff --git a/CPlusPlus/Sample_Source/ContentModification/PDFMakeOCGVisible/PDFMakeOCGVisible.cpp b/CPlusPlus/Sample_Source/ContentModification/PDFMakeOCGVisible/PDFMakeOCGVisible.cpp index 1ac83456..e5f3452f 100644 --- a/CPlusPlus/Sample_Source/ContentModification/PDFMakeOCGVisible/PDFMakeOCGVisible.cpp +++ b/CPlusPlus/Sample_Source/ContentModification/PDFMakeOCGVisible/PDFMakeOCGVisible.cpp @@ -3,7 +3,7 @@ // // For complete copyright information, see: // http://dev.datalogics.com/adobe-pdf-library/adobe-pdf-library-c-language-interface/license-for-downloaded-pdf-samples/ -// +// // This program makes the Optional Content Groups within a PDF document visible within a viewing application, // like Adobe Reader or Adobe Acrobat. The program finds any of these Optional Content Groups within the input // PDF document and writes them to an output file. @@ -27,12 +27,10 @@ ACCB1 ASBool ACCB2 showFirstThree(PDOCG ocgGroup, void *ctrVoidPtr); -int main (int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { APDFLib libInit; - if (libInit.isValid() == false) - { + if (libInit.isValid() == false) { ASErrorCode errCode = libInit.getInitError(); std::cout << "Initialization failed with code " << errCode << std::endl; return errCode; @@ -47,92 +45,80 @@ int main (int argc, char *argv[]) // could also copy the pages to a temporary document, and process the page copies // on a second pass. -DURING - APDFLDoc apdflDoc ( csInputFile.c_str(), true ); - PDDoc pdDoc = apdflDoc.getPDDoc(); + DURING + APDFLDoc apdflDoc(csInputFile.c_str(), true); + PDDoc pdDoc = apdflDoc.getPDDoc(); - PDPage pdPage = PDDocAcquirePage(pdDoc, 0); + PDPage pdPage = PDDocAcquirePage(pdDoc, 0); - if (PDDocHasOC(pdDoc)) - { - ASUns32 ocgCounter = 1; + if (PDDocHasOC(pdDoc)) { + ASUns32 ocgCounter = 1; - // Enumerate the optional content, making the first three elements - // visible and the rest invisible - PDPageEnumOCGs(pdPage, showFirstThree, (void *) &ocgCounter); + // Enumerate the optional content, making the first three elements + // visible and the rest invisible + PDPageEnumOCGs(pdPage, showFirstThree, (void *)&ocgCounter); - // "Flatten" the PDPage's optional content, so that the PDPage has its visible - // content layers visible, and the invisible content is not on the page - PDPageFlattenOC(pdPage, PDDocGetOCContext(pdDoc)); + // "Flatten" the PDPage's optional content, so that the PDPage has its visible + // content layers visible, and the invisible content is not on the page + PDPageFlattenOC(pdPage, PDDocGetOCContext(pdDoc)); - // The above call does not remove the actual Optional Content structure. That is completed below. - CosDoc cosDoc = PDDocGetCosDoc(pdDoc); - CosObj cosCatalog = CosDocGetRoot(cosDoc); - if (CosDictKnown(cosCatalog, ASAtomFromString("OCProperties"))) - { - CosDictRemove(cosCatalog, ASAtomFromString("OCProperties")); + // The above call does not remove the actual Optional Content structure. That is completed below. + CosDoc cosDoc = PDDocGetCosDoc(pdDoc); + CosObj cosCatalog = CosDocGetRoot(cosDoc); + if (CosDictKnown(cosCatalog, ASAtomFromString("OCProperties"))) { + CosDictRemove(cosCatalog, ASAtomFromString("OCProperties")); + } + } else { + std::cout << "Document does not have any OC\n"; } - } - else - { - std::cout << "Document does not have any OC\n"; - } - PDPageRelease(pdPage); - apdflDoc.saveDoc ( csOutputFile.c_str() ); -HANDLER - APDFLib::displayError(ERRORCODE); - return ERRORCODE; -END_HANDLER + PDPageRelease(pdPage); + apdflDoc.saveDoc(csOutputFile.c_str()); + HANDLER + APDFLib::displayError(ERRORCODE); + return ERRORCODE; + END_HANDLER return 0; - } // Switch the first three OCG groups passed in to the visible state, // and switch all subsequent OCG groups to the invisible state. -ACCB1 ASBool ACCB2 showFirstThree(PDOCG ocgGroup, void *ctrVoidPtr) -{ - ASUns32* ctrPtr = (ASUns32*)ctrVoidPtr; +ACCB1 ASBool ACCB2 showFirstThree(PDOCG ocgGroup, void *ctrVoidPtr) { + ASUns32 *ctrPtr = (ASUns32 *)ctrVoidPtr; - if (!ocgGroup || !ctrVoidPtr) - { - return TRUE; // This result would rarely appear + if (!ocgGroup || !ctrVoidPtr) { + return TRUE; // This result would rarely appear } -DURING - PDDoc curPDDoc = PDOCGGetPDDoc(ocgGroup); - PDOCConfig curOCconfig = PDDocGetOCConfig(curPDDoc); - PDOCContext curOCcontext = PDDocGetOCContext(curPDDoc); - - // Get the name of this layer, and convert to a Roman character set - ASText groupASName = PDOCGGetName(ocgGroup); - if (groupASName) - { - std::cout << "Found group \"" << ASTextGetScriptText(groupASName, kASRomanScript) << "\", "; - ASTextDestroy(groupASName); - } + DURING + PDDoc curPDDoc = PDOCGGetPDDoc(ocgGroup); + PDOCConfig curOCconfig = PDDocGetOCConfig(curPDDoc); + PDOCContext curOCcontext = PDDocGetOCContext(curPDDoc); - if (*ctrPtr) - { - std::cout << "Setting group on...\n"; - PDOCGSetInitialState(ocgGroup, curOCconfig, TRUE); - PDOCGSetCurrentState(ocgGroup, curOCcontext, TRUE); - } - else - { - std::cout << "Setting group off...\n"; - PDOCGSetInitialState(ocgGroup, curOCconfig, FALSE); - PDOCGSetCurrentState(ocgGroup, curOCcontext, FALSE); - } + // Get the name of this layer, and convert to a Roman character set + ASText groupASName = PDOCGGetName(ocgGroup); + if (groupASName) { + std::cout << "Found group \"" << ASTextGetScriptText(groupASName, kASRomanScript) << "\", "; + ASTextDestroy(groupASName); + } + + if (*ctrPtr) { + std::cout << "Setting group on...\n"; + PDOCGSetInitialState(ocgGroup, curOCconfig, TRUE); + PDOCGSetCurrentState(ocgGroup, curOCcontext, TRUE); + } else { + std::cout << "Setting group off...\n"; + PDOCGSetInitialState(ocgGroup, curOCconfig, FALSE); + PDOCGSetCurrentState(ocgGroup, curOCcontext, FALSE); + } -HANDLER - std::cout << "Exception " << ERRORCODE << " in function \"showFirstThree\"\n"; -END_HANDLER + HANDLER + std::cout << "Exception " << ERRORCODE << " in function \"showFirstThree\"\n"; + END_HANDLER // Verify the number of layers processed. This sample completes only the first three. - if (*ctrPtr > 0) - { + if (*ctrPtr > 0) { *ctrPtr = *ctrPtr + 1; if (*ctrPtr >= 4) *ctrPtr = 0; diff --git a/CPlusPlus/Sample_Source/ContentModification/PDFUncompress/PDFUncompress.cpp b/CPlusPlus/Sample_Source/ContentModification/PDFUncompress/PDFUncompress.cpp index a34be797..877c0879 100644 --- a/CPlusPlus/Sample_Source/ContentModification/PDFUncompress/PDFUncompress.cpp +++ b/CPlusPlus/Sample_Source/ContentModification/PDFUncompress/PDFUncompress.cpp @@ -1,11 +1,11 @@ -// +// // Copyright (c) 2010-2017, Datalogics, Inc. All rights reserved. // // For complete copyright information, see: // http://dev.datalogics.com/adobe-pdf-library/adobe-pdf-library-c-language-interface/license-for-downloaded-pdf-samples/ // // The PDFUncompress sample is a utility that demonstrates how to completely un-compress the elements within a PDF -// document into a readable form. +// document into a readable form. // // Nearly all PDF documents feature compressed elements to make the documents more efficient to use, and most of the time // these documents are left in their compressed state even when being opened in a browser or viewing tool. But sometimes @@ -30,76 +30,72 @@ #define INPUT_FILE "CopyContent.pdf" #define OUTPUT_FILE "PDFUncompress-out.pdf" -int main (int argc, char* argv[]) -{ +int main(int argc, char *argv[]) { // Initialize library APDFLib libInit; - if (libInit.isValid() == false) - { + if (libInit.isValid() == false) { ASErrorCode errCode = libInit.getInitError(); - APDFLib::displayError ( errCode ); + APDFLib::displayError(errCode); return errCode; } std::string csInputFile(argc > 1 ? argv[1] : INPUT_DIR INPUT_FILE); std::string csOutputFile(argc > 2 ? argv[2] : OUTPUT_FILE); - std::cout << "Will uncompress file " << csInputFile.c_str() << " and save as " << csOutputFile.c_str() << std::endl; + std::cout << "Will uncompress file " << csInputFile.c_str() << " and save as " + << csOutputFile.c_str() << std::endl; // Open input document PDDoc pdDoc; -DURING - ASPathName InPath = APDFLDoc::makePath ( csInputFile.c_str() ); - pdDoc = PDDocOpen(InPath, NULL, NULL, true); - ASFileSysReleasePath(NULL, InPath); -HANDLER - std::cout << "Could not open file " << csInputFile.c_str() << std::endl; - APDFLib::displayError(ERRORCODE); - return ERRORCODE; -END_HANDLER + DURING + ASPathName InPath = APDFLDoc::makePath(csInputFile.c_str()); + pdDoc = PDDocOpen(InPath, NULL, NULL, true); + ASFileSysReleasePath(NULL, InPath); + HANDLER + std::cout << "Could not open file " << csInputFile.c_str() << std::endl; + APDFLib::displayError(ERRORCODE); + return ERRORCODE; + END_HANDLER // Determine if copying is permitted from this document bool DocumentEncrypted(false); -DURING - PDDocAuthorize (pdDoc, pdPermAll, NULL); - PDDocSetNewCryptHandler (pdDoc, ASAtomNull); -HANDLER - DocumentEncrypted = true; -END_HANDLER - - if (DocumentEncrypted) - { - PDDoc DocCopy; -DURING - DocCopy = PDDocCreate (); - PDDocInsertPages (DocCopy, PDBeforeFirstPage, pdDoc, 0, PDAllPages, PDInsertAll, NULL, NULL, NULL, NULL); -HANDLER - std::cout << "Document is encoded, and copy is not permitted!\n"; - return -2; -END_HANDLER + DURING + PDDocAuthorize(pdDoc, pdPermAll, NULL); + PDDocSetNewCryptHandler(pdDoc, ASAtomNull); + HANDLER + DocumentEncrypted = true; + END_HANDLER + + if (DocumentEncrypted) { + PDDoc DocCopy; + DURING + DocCopy = PDDocCreate(); + PDDocInsertPages(DocCopy, PDBeforeFirstPage, pdDoc, 0, PDAllPages, PDInsertAll, NULL, + NULL, NULL, NULL); + HANDLER + std::cout << "Document is encoded, and copy is not permitted!\n"; + return -2; + END_HANDLER } - int CurrentPage ( 0 ); - int Pages = PDDocGetNumPages (pdDoc); -DURING - for (CurrentPage = 0; CurrentPage < Pages; CurrentPage++) - { - PDPage Page = PDDocAcquirePage (pdDoc, CurrentPage); - CosObj cosPage = PDPageGetCosObj (Page); - CosObj Content = CosDictGet (cosPage, ASAtomFromString ("Contents")); + int CurrentPage(0); + int Pages = PDDocGetNumPages(pdDoc); + DURING + for (CurrentPage = 0; CurrentPage < Pages; CurrentPage++) { + PDPage Page = PDDocAcquirePage(pdDoc, CurrentPage); + CosObj cosPage = PDPageGetCosObj(Page); + CosObj Content = CosDictGet(cosPage, ASAtomFromString("Contents")); - switch (CosObjGetType (Content)) - { + switch (CosObjGetType(Content)) { case CosStream: - Content = Uncompress (Content); - CosDictPut (cosPage, ASAtomFromString ("Contents"), Content); + Content = Uncompress(Content); + CosDictPut(cosPage, ASAtomFromString("Contents"), Content); break; case CosArray: - for (int ContentElement = 0; ContentElement < CosArrayLength (Content); ContentElement++) - { - CosObj Stream; - Stream = CosArrayGet (Content, ContentElement); - CosArrayPut (Content, ContentElement, Uncompress (Stream)); + for (int ContentElement = 0; ContentElement < CosArrayLength(Content); ContentElement++) { + CosObj Stream; + Stream = CosArrayGet(Content, ContentElement); + CosArrayPut(Content, ContentElement, Uncompress(Stream)); } break; @@ -108,252 +104,222 @@ DURING default: break; - } + } - Content = CosDictGet (cosPage, ASAtomFromString ("Annots")); - if (CosObjGetType (Content) != CosNull) - { - for (int count = 0; count < CosArrayLength (Content); count++) - { - CosObj NewAnnot; - NewAnnot = UncompressAnnot (CosArrayGet (Content, count)); - if (CosObjGetType (NewAnnot) != CosNull) - CosArrayPut (Content, count, NewAnnot); + Content = CosDictGet(cosPage, ASAtomFromString("Annots")); + if (CosObjGetType(Content) != CosNull) { + for (int count = 0; count < CosArrayLength(Content); count++) { + CosObj NewAnnot; + NewAnnot = UncompressAnnot(CosArrayGet(Content, count)); + if (CosObjGetType(NewAnnot) != CosNull) + CosArrayPut(Content, count, NewAnnot); + } } - } - Content = CosDictGet (cosPage, ASAtomFromString ("Resources")); - if (CosObjGetType (Content) != CosNull) - { - CosObj Xobjs = CosDictGet (Content, ASAtomFromString ("XObject")); - if (CosObjGetType (Xobjs) == CosDict) - CosObjEnum (Xobjs, CompressXobj, &Xobjs); - } + Content = CosDictGet(cosPage, ASAtomFromString("Resources")); + if (CosObjGetType(Content) != CosNull) { + CosObj Xobjs = CosDictGet(Content, ASAtomFromString("XObject")); + if (CosObjGetType(Xobjs) == CosDict) + CosObjEnum(Xobjs, CompressXobj, &Xobjs); + } - PDPageRelease (Page); + PDPageRelease(Page); } -HANDLER - std::cout << "Problem uncompressing page " << CurrentPage+1 << std::endl; - return -3; -END_HANDLER - - PDDocEnumResources (pdDoc, 0, Pages-1, ASAtomNull, UncompressResource, pdDoc); - -DURING - // Save document - ASPathName path = APDFLDoc::makePath ( csOutputFile.c_str() ); - PDDocSaveParamsRec docSaveParamsRec; - memset(&docSaveParamsRec, 0, sizeof(docSaveParamsRec)); - docSaveParamsRec.size = sizeof(PDDocSaveParamsRec); - docSaveParamsRec.saveFlags = PDSaveFull | PDSaveCollectGarbage; - docSaveParamsRec.newPath = path; - docSaveParamsRec.major = 1; - docSaveParamsRec.minor = 1; - docSaveParamsRec.saveFlags2 = PDSaveUncompressed; - PDDocSaveWithParams(pdDoc, &docSaveParamsRec); -HANDLER -{ - std::cout << "Problem writing file \"" << csOutputFile.c_str() << "\"" << std::endl; - return -8; -} -END_HANDLER + HANDLER + std::cout << "Problem uncompressing page " << CurrentPage + 1 << std::endl; + return -3; + END_HANDLER + + PDDocEnumResources(pdDoc, 0, Pages - 1, ASAtomNull, UncompressResource, pdDoc); + + DURING + // Save document + ASPathName path = APDFLDoc::makePath(csOutputFile.c_str()); + PDDocSaveParamsRec docSaveParamsRec; + memset(&docSaveParamsRec, 0, sizeof(docSaveParamsRec)); + docSaveParamsRec.size = sizeof(PDDocSaveParamsRec); + docSaveParamsRec.saveFlags = PDSaveFull | PDSaveCollectGarbage; + docSaveParamsRec.newPath = path; + docSaveParamsRec.major = 1; + docSaveParamsRec.minor = 1; + docSaveParamsRec.saveFlags2 = PDSaveUncompressed; + PDDocSaveWithParams(pdDoc, &docSaveParamsRec); + HANDLER + { + std::cout << "Problem writing file \"" << csOutputFile.c_str() << "\"" << std::endl; + return -8; + } + END_HANDLER - PDDocRelease (pdDoc); + PDDocRelease(pdDoc); return 0; } -CosObj Uncompress (CosObj Stream) -{ - CosObj Filter; - CosObj NewStream; - CosObj CosDict; - ASStm Stm; +CosObj Uncompress(CosObj Stream) { + CosObj Filter; + CosObj NewStream; + CosObj CosDict; + ASStm Stm; - if (CosObjGetType (Stream) != CosStream) + if (CosObjGetType(Stream) != CosStream) return (Stream); - Filter = CosDictGet (Stream, ASAtomFromString ("Filter")); + Filter = CosDictGet(Stream, ASAtomFromString("Filter")); - if (CosObjGetType (Filter) == CosNull) + if (CosObjGetType(Filter) == CosNull) return (Stream); - CosDict = CosStreamDict (Stream); - CosDict = CosObjCopy (CosDict, CosObjGetDoc (Stream), TRUE); - CosDictRemove (CosDict, ASAtomFromString ("Filter")); - CosDictRemove (CosDict, ASAtomFromString ("DecodeParms")); - CosDictRemove (CosDict, ASAtomFromString ("Length")); + CosDict = CosStreamDict(Stream); + CosDict = CosObjCopy(CosDict, CosObjGetDoc(Stream), TRUE); + CosDictRemove(CosDict, ASAtomFromString("Filter")); + CosDictRemove(CosDict, ASAtomFromString("DecodeParms")); + CosDictRemove(CosDict, ASAtomFromString("Length")); - Stm = CosStreamOpenStm (Stream, cosOpenFiltered); - NewStream = CosNewStream (CosObjGetDoc (Stream), TRUE, Stm, 0, TRUE, - CosDict, CosNewNull(), -1); - ASStmClose (Stm); + Stm = CosStreamOpenStm(Stream, cosOpenFiltered); + NewStream = CosNewStream(CosObjGetDoc(Stream), TRUE, Stm, 0, TRUE, CosDict, CosNewNull(), -1); + ASStmClose(Stm); return (NewStream); } -ASBool UncompressResource (CosObj Key, CosObj Value, void* clientData) -{ - const char *KeyName, *DictType; - CosType KeyType = CosObjGetType (Key); - CosType ValueType = CosObjGetType (Value); +ASBool UncompressResource(CosObj Key, CosObj Value, void *clientData) { + const char *KeyName, *DictType; + CosType KeyType = CosObjGetType(Key); + CosType ValueType = CosObjGetType(Value); - if (CosObjGetType (Key) == CosName) - KeyName = ASAtomGetString (CosNameValue (Key)); + if (CosObjGetType(Key) == CosName) + KeyName = ASAtomGetString(CosNameValue(Key)); - if (KeyType == CosDict) - { - ASAtom Type; - CosObj TypeObj; + if (KeyType == CosDict) { + ASAtom Type; + CosObj TypeObj; - TypeObj = CosDictGet (Key, ASAtomFromString ("Type")); - if (CosObjGetType (TypeObj) == CosName) - { - Type = CosNameValue (TypeObj); - DictType = ASAtomGetString (Type); - } - else + TypeObj = CosDictGet(Key, ASAtomFromString("Type")); + if (CosObjGetType(TypeObj) == CosName) { + Type = CosNameValue(TypeObj); + DictType = ASAtomGetString(Type); + } else Type = ASAtomNull; - if (Type == ASAtomFromString ("Font")) - { - CosObj ToUnicode, CIDToGIDMap, CIDSet, FontDesc, DescFont; - ToUnicode = CosDictGet (Key, ASAtomFromString ("ToUnicode")); - if (!CosObjEqual (ToUnicode, CosNewNull())) - { - ToUnicode = Uncompress (ToUnicode); - CosDictPut (Key, ASAtomFromString ("ToUnicode"), ToUnicode); + if (Type == ASAtomFromString("Font")) { + CosObj ToUnicode, CIDToGIDMap, CIDSet, FontDesc, DescFont; + ToUnicode = CosDictGet(Key, ASAtomFromString("ToUnicode")); + if (!CosObjEqual(ToUnicode, CosNewNull())) { + ToUnicode = Uncompress(ToUnicode); + CosDictPut(Key, ASAtomFromString("ToUnicode"), ToUnicode); } - ToUnicode = CosDictGet (Key, ASAtomFromString ("Encoding")); - if (CosObjGetType (ToUnicode) == CosStream) - { - ToUnicode = Uncompress (ToUnicode); - CosDictPut (Key, ASAtomFromString ("Encoding"), ToUnicode); + ToUnicode = CosDictGet(Key, ASAtomFromString("Encoding")); + if (CosObjGetType(ToUnicode) == CosStream) { + ToUnicode = Uncompress(ToUnicode); + CosDictPut(Key, ASAtomFromString("Encoding"), ToUnicode); } - DescFont = CosDictGet (Key, ASAtomFromString ("DescendantFonts")); - if (!CosObjEqual (DescFont, CosNewNull())) - { - DescFont = CosArrayGet (DescFont, 0); - CIDToGIDMap = CosDictGet (DescFont, ASAtomFromString ("CIDToGIDMap")); - if (!CosObjEqual (CIDToGIDMap, CosNewNull())) - { - CIDToGIDMap = Uncompress (CIDToGIDMap); - CosDictPut (DescFont, ASAtomFromString ("CIDToGIDMap"), CIDToGIDMap); + DescFont = CosDictGet(Key, ASAtomFromString("DescendantFonts")); + if (!CosObjEqual(DescFont, CosNewNull())) { + DescFont = CosArrayGet(DescFont, 0); + CIDToGIDMap = CosDictGet(DescFont, ASAtomFromString("CIDToGIDMap")); + if (!CosObjEqual(CIDToGIDMap, CosNewNull())) { + CIDToGIDMap = Uncompress(CIDToGIDMap); + CosDictPut(DescFont, ASAtomFromString("CIDToGIDMap"), CIDToGIDMap); } - FontDesc = CosDictGet (DescFont, ASAtomFromString ("FontDescriptor")); - if (!CosObjEqual (FontDesc, CosNewNull())) - { - CIDSet = CosDictGet (FontDesc, ASAtomFromString ("CISSet")); - if (CosObjGetType (CIDSet) == CosStream) - { - CIDSet = Uncompress (CIDSet); - CosDictPut (FontDesc, ASAtomFromString ("CISSet"), CIDSet); + FontDesc = CosDictGet(DescFont, ASAtomFromString("FontDescriptor")); + if (!CosObjEqual(FontDesc, CosNewNull())) { + CIDSet = CosDictGet(FontDesc, ASAtomFromString("CISSet")); + if (CosObjGetType(CIDSet) == CosStream) { + CIDSet = Uncompress(CIDSet); + CosDictPut(FontDesc, ASAtomFromString("CISSet"), CIDSet); } - CIDSet = CosDictGet (FontDesc, ASAtomFromString ("FontFile")); - if (CosObjGetType (CIDSet) == CosStream) - { - CIDSet = Uncompress (CIDSet); - CosDictPut (FontDesc, ASAtomFromString ("FontFile"), CIDSet); + CIDSet = CosDictGet(FontDesc, ASAtomFromString("FontFile")); + if (CosObjGetType(CIDSet) == CosStream) { + CIDSet = Uncompress(CIDSet); + CosDictPut(FontDesc, ASAtomFromString("FontFile"), CIDSet); } - CIDSet = CosDictGet (FontDesc, ASAtomFromString ("FontFile2")); - if (CosObjGetType (CIDSet) == CosStream) - { - CIDSet = Uncompress (CIDSet); - CosDictPut (FontDesc, ASAtomFromString ("FontFile2"), CIDSet); + CIDSet = CosDictGet(FontDesc, ASAtomFromString("FontFile2")); + if (CosObjGetType(CIDSet) == CosStream) { + CIDSet = Uncompress(CIDSet); + CosDictPut(FontDesc, ASAtomFromString("FontFile2"), CIDSet); } - CIDSet = CosDictGet (FontDesc, ASAtomFromString ("FontFile3")); - if (CosObjGetType (CIDSet) == CosStream) - { - CIDSet = Uncompress (CIDSet); - CosDictPut (FontDesc, ASAtomFromString ("FontFile3"), CIDSet); + CIDSet = CosDictGet(FontDesc, ASAtomFromString("FontFile3")); + if (CosObjGetType(CIDSet) == CosStream) { + CIDSet = Uncompress(CIDSet); + CosDictPut(FontDesc, ASAtomFromString("FontFile3"), CIDSet); } - } - } - else - { - FontDesc = CosDictGet (Key, ASAtomFromString ("FontDescriptor")); - if (!CosObjEqual (FontDesc, CosNewNull())) - { - CIDSet = CosDictGet (FontDesc, ASAtomFromString ("CISSet")); - if (CosObjGetType (CIDSet) == CosStream) - { - CIDSet = Uncompress (CIDSet); - CosDictPut (FontDesc, ASAtomFromString ("CISSet"), CIDSet); + } + } else { + FontDesc = CosDictGet(Key, ASAtomFromString("FontDescriptor")); + if (!CosObjEqual(FontDesc, CosNewNull())) { + CIDSet = CosDictGet(FontDesc, ASAtomFromString("CISSet")); + if (CosObjGetType(CIDSet) == CosStream) { + CIDSet = Uncompress(CIDSet); + CosDictPut(FontDesc, ASAtomFromString("CISSet"), CIDSet); } - CIDSet = CosDictGet (FontDesc, ASAtomFromString ("FontFile")); - if (CosObjGetType (CIDSet) == CosStream) - { - CIDSet = Uncompress (CIDSet); - CosDictPut (FontDesc, ASAtomFromString ("FontFile"), CIDSet); + CIDSet = CosDictGet(FontDesc, ASAtomFromString("FontFile")); + if (CosObjGetType(CIDSet) == CosStream) { + CIDSet = Uncompress(CIDSet); + CosDictPut(FontDesc, ASAtomFromString("FontFile"), CIDSet); } - CIDSet = CosDictGet (FontDesc, ASAtomFromString ("FontFile2")); - if (CosObjGetType (CIDSet) == CosStream) - { - CIDSet = Uncompress (CIDSet); - CosDictPut (FontDesc, ASAtomFromString ("FontFile2"), CIDSet); + CIDSet = CosDictGet(FontDesc, ASAtomFromString("FontFile2")); + if (CosObjGetType(CIDSet) == CosStream) { + CIDSet = Uncompress(CIDSet); + CosDictPut(FontDesc, ASAtomFromString("FontFile2"), CIDSet); } - CIDSet = CosDictGet (FontDesc, ASAtomFromString ("FontFile3")); - if (CosObjGetType (CIDSet) == CosStream) - { - CIDSet = Uncompress (CIDSet); - CosDictPut (FontDesc, ASAtomFromString ("FontFile3"), CIDSet); + CIDSet = CosDictGet(FontDesc, ASAtomFromString("FontFile3")); + if (CosObjGetType(CIDSet) == CosStream) { + CIDSet = Uncompress(CIDSet); + CosDictPut(FontDesc, ASAtomFromString("FontFile3"), CIDSet); } } } } if (KeyType == CosStream) - Uncompress (Key); + Uncompress(Key); if (ValueType == CosStream) - Uncompress (Value); + Uncompress(Value); } return (TRUE); } -ASBool CompressXobj (CosObj Key, CosObj Value, void *Data) -{ - CosObj NewXobj = Uncompress (Value); - CosDictPut (*(CosObj *) Data, CosNameValue (Key), NewXobj); +ASBool CompressXobj(CosObj Key, CosObj Value, void *Data) { + CosObj NewXobj = Uncompress(Value); + CosDictPut(*(CosObj *)Data, CosNameValue(Key), NewXobj); return TRUE; } -ASBool SubAnnot (CosObj Key, CosObj Value, void *Data) -{ - CosType Type = CosObjGetType (Value); +ASBool SubAnnot(CosObj Key, CosObj Value, void *Data) { + CosType Type = CosObjGetType(Value); if (Type == CosStream) - CosDictPut (*(CosObj*)Data, CosNameValue (Key), Uncompress (Value)); + CosDictPut(*(CosObj *)Data, CosNameValue(Key), Uncompress(Value)); if (Type == CosDict) - CosObjEnum (Value, SubAnnot, &Value); + CosObjEnum(Value, SubAnnot, &Value); return TRUE; } -CosObj UncompressAnnot (CosObj Annot) -{ - CosObj APDict; +CosObj UncompressAnnot(CosObj Annot) { + CosObj APDict; - if (CosObjGetType (Annot) != CosDict) + if (CosObjGetType(Annot) != CosDict) return (CosNewNull()); - APDict = CosDictGet (Annot, ASAtomFromString ("AP")); - if (CosObjGetType (APDict) == CosNull) + APDict = CosDictGet(Annot, ASAtomFromString("AP")); + if (CosObjGetType(APDict) == CosNull) return (CosNewNull()); - if (CosObjGetType (APDict) == CosStream) - return (Uncompress (APDict)); + if (CosObjGetType(APDict) == CosStream) + return (Uncompress(APDict)); - CosObjEnum (APDict, SubAnnot, &APDict); + CosObjEnum(APDict, SubAnnot, &APDict); return (CosNewNull()); } - diff --git a/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcColor.cpp b/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcColor.cpp index 01fd0a6c..915b8988 100644 --- a/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcColor.cpp +++ b/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcColor.cpp @@ -17,11 +17,9 @@ #include "PagePDECntCalls.h" #include "DisplayPDEContent.h" -class CColorSpaces -{ -public: - enum Colorspaces - { +class CColorSpaces { + public: + enum Colorspaces { Unknown_cs = 0, Gray_cs = 1, RGB_cs, @@ -35,209 +33,188 @@ class CColorSpaces Separation_cs, DeviceN_cs }; - - struct ColorSelect - { + + struct ColorSelect { std::string m_name; ASAtom m_atom; Colorspaces m_group; - ColorSelect ( const char *name, Colorspaces cs ) : m_name ( name ), m_group ( cs ) - { - m_atom = m_name.length() ? ASAtomFromString ( name ) : ASAtomNull; + ColorSelect(const char *name, Colorspaces cs) : m_name(name), m_group(cs) { + m_atom = m_name.length() ? ASAtomFromString(name) : ASAtomNull; } }; - CColorSpaces() - { - m_spaces.push_back ( ColorSelect ( "DeviceGray", Gray_cs ) ); - m_spaces.push_back ( ColorSelect ( "DeviceRGB", RGB_cs ) ); - m_spaces.push_back ( ColorSelect ( "DeviceCMYK", CMYK_cs ) ); - m_spaces.push_back ( ColorSelect ( "CalGray", CalGray_cs ) ); - m_spaces.push_back ( ColorSelect ( "CalRGB", CalRGB_cs ) ); - m_spaces.push_back ( ColorSelect ( "Lab", LAB_cs ) ); - m_spaces.push_back ( ColorSelect ( "ICCBased", ICC_cs ) ); - m_spaces.push_back ( ColorSelect ( "Pattern", Pattern_cs ) ); - m_spaces.push_back ( ColorSelect ( "Indexed", Index_cs ) ); - m_spaces.push_back ( ColorSelect ( "Separation", Separation_cs ) ); - m_spaces.push_back ( ColorSelect ( "DeviceN", DeviceN_cs ) ); - m_spaces.push_back ( ColorSelect ( "", Unknown_cs ) ); + CColorSpaces() { + m_spaces.push_back(ColorSelect("DeviceGray", Gray_cs)); + m_spaces.push_back(ColorSelect("DeviceRGB", RGB_cs)); + m_spaces.push_back(ColorSelect("DeviceCMYK", CMYK_cs)); + m_spaces.push_back(ColorSelect("CalGray", CalGray_cs)); + m_spaces.push_back(ColorSelect("CalRGB", CalRGB_cs)); + m_spaces.push_back(ColorSelect("Lab", LAB_cs)); + m_spaces.push_back(ColorSelect("ICCBased", ICC_cs)); + m_spaces.push_back(ColorSelect("Pattern", Pattern_cs)); + m_spaces.push_back(ColorSelect("Indexed", Index_cs)); + m_spaces.push_back(ColorSelect("Separation", Separation_cs)); + m_spaces.push_back(ColorSelect("DeviceN", DeviceN_cs)); + m_spaces.push_back(ColorSelect("", Unknown_cs)); } - struct MyComp - { - explicit MyComp ( ASAtom a ) : m_a ( a ) {} - inline bool operator() (const ColorSelect& cs) const { return cs.m_atom == m_a; } - private: + struct MyComp { + explicit MyComp(ASAtom a) : m_a(a) {} + inline bool operator()(const ColorSelect &cs) const { return cs.m_atom == m_a; } + + private: ASAtom m_a; }; - ColorSelect& FindColor ( ASAtom c ) - { - return * std::find_if ( m_spaces.begin(), m_spaces.end(), MyComp ( c ) ); + ColorSelect &FindColor(ASAtom c) { + return *std::find_if(m_spaces.begin(), m_spaces.end(), MyComp(c)); } -private: - std::vector m_spaces; + private: + std::vector m_spaces; }; -std::string DisplayColor (PDEColorSpec *Color) -{ +std::string DisplayColor(PDEColorSpec *Color) { static CColorSpaces sColorSpaces; - char Amount[20][20]; - PDEColorSpace Space = Color->space; - ASAtom SpaceName = PDEColorSpaceGetName (Space); - + char Amount[20][20]; + PDEColorSpace Space = Color->space; + ASAtom SpaceName = PDEColorSpaceGetName(Space); + std::ostringstream oss; - CColorSpaces::ColorSelect& ColorInfo = sColorSpaces.FindColor ( SpaceName ); + CColorSpaces::ColorSelect &ColorInfo = sColorSpaces.FindColor(SpaceName); - switch ( ColorInfo.m_group ) - { - case CColorSpaces::Unknown_cs: - oss << "This is not a valid color space!"; - break; + switch (ColorInfo.m_group) { + case CColorSpaces::Unknown_cs: + oss << "This is not a valid color space!"; + break; - case CColorSpaces::Gray_cs: - if (Color->value.color[0] == 0) - { - oss << " Gray - Black"; + case CColorSpaces::Gray_cs: + if (Color->value.color[0] == 0) { + oss << " Gray - Black"; + break; + } + if (Color->value.color[0] == fixedOne) { + oss << " Gray - White"; + break; + } + ASFixedToCString((fixedOne - Color->value.color[0]) * 100, Amount[0], 20, 5); + oss << " " << Amount[0] << "% Gray "; + break; + + case CColorSpaces::RGB_cs: + if ((Color->value.color[0] == Color->value.color[1]) || + (Color->value.color[1] == Color->value.color[2])) { + // This is a gray color in RGB + if (Color->value.color[0] == 0) { + oss << " RGB - Black"; break; } - if (Color->value.color[0] == fixedOne) - { - oss << " Gray - White"; + if (Color->value.color[0] == fixedOne) { + oss << " RGB - White"; break; } - ASFixedToCString ((fixedOne - Color->value.color[0]) * 100, Amount[0], 20, 5); - oss << " " << Amount[0] << "% Gray "; + + ASFixedToCString((fixedOne - Color->value.color[0]) * 100, Amount[0], 20, 5); + oss << " " << Amount[0] << "% Gray (In RGB) "; break; + } - case CColorSpaces::RGB_cs: - if ((Color->value.color[0] == Color->value.color[1]) || - (Color->value.color[1] == Color->value.color[2])) - { - // This is a gray color in RGB - if (Color->value.color[0] == 0) - { - oss << " RGB - Black"; - break; - } - if (Color->value.color[0] == fixedOne) - { - oss << " RGB - White"; - break; - } - - ASFixedToCString ((fixedOne - Color->value.color[0]) * 100, Amount[0], 20, 5); - oss << " " << Amount[0] << "% Gray (In RGB) "; + ASFixedToCString(Color->value.color[0], Amount[0], 20, 5); + ASFixedToCString(Color->value.color[1], Amount[1], 20, 5); + ASFixedToCString(Color->value.color[2], Amount[2], 20, 5); + oss << " RGB (" << Amount[0] << ", " << Amount[1] << ", " << Amount[2] << ")"; + break; + + case CColorSpaces::CMYK_cs: + if ((Color->value.color[0] == Color->value.color[1]) || + (Color->value.color[1] == Color->value.color[2]) || + (Color->value.color[2] == Color->value.color[3])) { + // This is a gray in CMYK + if ((Color->value.color[0] == 0) && (Color->value.color[3] == 0)) { + oss << " CMYK - White"; break; } - - ASFixedToCString (Color->value.color[0], Amount[0], 20, 5); - ASFixedToCString (Color->value.color[1], Amount[1], 20, 5); - ASFixedToCString (Color->value.color[2], Amount[2], 20, 5); - oss << " RGB (" << Amount[0] << ", " << Amount[1] << ", " << Amount[2] << ")"; - break; - - case CColorSpaces::CMYK_cs: - if ((Color->value.color[0] == Color->value.color[1]) || - (Color->value.color[1] == Color->value.color[2]) || - (Color->value.color[2] == Color->value.color[3])) - { - // This is a gray in CMYK - if ((Color->value.color[0] == 0) && - (Color->value.color[3] == 0)) - { - oss << " CMYK - White"; - break; - } - if ((Color->value.color[0] == 0) && - (Color->value.color[3] == fixedOne)) - { - oss << " CMYK - True Black"; - break; - } - if (Color->value.color[0] == fixedOne) - { - oss << " CMYK - Black"; - break; - } - - if (Color->value.color[0] == 0) - { - ASFixedToCString ((fixedOne - Color->value.color[3]) * 100, Amount[0], 20, 5); - oss << " " << Amount[0] << "% Gray (In CMYK Black) "; - break; - } - - if (Color->value.color[3] == 0) - { - ASFixedToCString ((fixedOne - Color->value.color[0]) * 100, Amount[0], 20, 5); - oss << " " << Amount[0] << "% Gray (In CMYK Colors) "; - break; - } + if ((Color->value.color[0] == 0) && (Color->value.color[3] == fixedOne)) { + oss << " CMYK - True Black"; + break; + } + if (Color->value.color[0] == fixedOne) { + oss << " CMYK - Black"; + break; } - ASFixedToCString (Color->value.color[0], Amount[0], 20, 5); - ASFixedToCString (Color->value.color[1], Amount[1], 20, 5); - ASFixedToCString (Color->value.color[2], Amount[2], 20, 5); - ASFixedToCString (Color->value.color[3], Amount[3], 20, 5); - oss << " CMYK (" << Amount[0] << ", " << Amount[1] << ", " << Amount[2] << ", " << Amount[3] << ")"; - break; + if (Color->value.color[0] == 0) { + ASFixedToCString((fixedOne - Color->value.color[3]) * 100, Amount[0], 20, 5); + oss << " " << Amount[0] << "% Gray (In CMYK Black) "; + break; + } - case CColorSpaces::Index_cs: - { - ASUns32 IndexRange = PDEColorSpaceGetHiVal (Space); - ASUns8 *ColorTable; - ASUns8 Comps = PDEColorSpaceGetBaseNumComps (Space); - ASUns8 *ColorBase; - ASUns8 Index; - - CColorSpaces::ColorSelect& BaseColorInfo = sColorSpaces.FindColor ( PDEColorSpaceGetBase ( Space ) ); - oss << " Indexed Color space of " << IndexRange + 1 << " Value in " << BaseColorInfo.m_name.c_str() << ". Value " << Color->value.color[0] << " ("; - - ColorTable = (ASUns8 *)ASmalloc (Comps * (IndexRange + 1)); - PDEColorSpaceGetCTable (Space, ColorTable); - ColorBase = &ColorTable[Color->value.color[0] * Comps]; - for (Index = 0; Index < Comps; Index++) - { - oss << ColorBase[Index]; - if (Index+1 < Comps) - oss << " "; + if (Color->value.color[3] == 0) { + ASFixedToCString((fixedOne - Color->value.color[0]) * 100, Amount[0], 20, 5); + oss << " " << Amount[0] << "% Gray (In CMYK Colors) "; + break; } - oss << ")"; - ASfree (ColorTable); - break; } - case CColorSpaces::CalGray_cs: - /* TBD Cal gray color space */ - break; + ASFixedToCString(Color->value.color[0], Amount[0], 20, 5); + ASFixedToCString(Color->value.color[1], Amount[1], 20, 5); + ASFixedToCString(Color->value.color[2], Amount[2], 20, 5); + ASFixedToCString(Color->value.color[3], Amount[3], 20, 5); + oss << " CMYK (" << Amount[0] << ", " << Amount[1] << ", " << Amount[2] << ", " << Amount[3] << ")"; + break; + + case CColorSpaces::Index_cs: { + ASUns32 IndexRange = PDEColorSpaceGetHiVal(Space); + ASUns8 *ColorTable; + ASUns8 Comps = PDEColorSpaceGetBaseNumComps(Space); + ASUns8 *ColorBase; + ASUns8 Index; + + CColorSpaces::ColorSelect &BaseColorInfo = sColorSpaces.FindColor(PDEColorSpaceGetBase(Space)); + oss << " Indexed Color space of " << IndexRange + 1 << " Value in " + << BaseColorInfo.m_name.c_str() << ". Value " << Color->value.color[0] << " ("; + + ColorTable = (ASUns8 *)ASmalloc(Comps * (IndexRange + 1)); + PDEColorSpaceGetCTable(Space, ColorTable); + ColorBase = &ColorTable[Color->value.color[0] * Comps]; + for (Index = 0; Index < Comps; Index++) { + oss << ColorBase[Index]; + if (Index + 1 < Comps) + oss << " "; + } + oss << ")"; + ASfree(ColorTable); + break; + } - case CColorSpaces::CalRGB_cs: - /* TBD Cal RGB Color space */ - break; + case CColorSpaces::CalGray_cs: + /* TBD Cal gray color space */ + break; - case CColorSpaces::LAB_cs: - /* TBD LAB Color space */ - break; + case CColorSpaces::CalRGB_cs: + /* TBD Cal RGB Color space */ + break; - case CColorSpaces::ICC_cs: - /* TBD ICC Color space */ - break; + case CColorSpaces::LAB_cs: + /* TBD LAB Color space */ + break; - case CColorSpaces::Pattern_cs: - /* TBD Pattern color spaces (Tiles and gradients) */ - break; + case CColorSpaces::ICC_cs: + /* TBD ICC Color space */ + break; - case CColorSpaces::Separation_cs: - /* TBD Separation color spaces */ - break; + case CColorSpaces::Pattern_cs: + /* TBD Pattern color spaces (Tiles and gradients) */ + break; - case CColorSpaces::DeviceN_cs: - /* TBD DeviceN Color Spaces */ - break; + case CColorSpaces::Separation_cs: + /* TBD Separation color spaces */ + break; + + case CColorSpaces::DeviceN_cs: + /* TBD DeviceN Color Spaces */ + break; } return oss.str(); } - diff --git a/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcDict.cpp b/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcDict.cpp index 1c492df4..4d0628da 100644 --- a/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcDict.cpp +++ b/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcDict.cpp @@ -19,153 +19,138 @@ #include "DisplayPDEContent.h" #include "dpcOutput.h" - -typedef struct dictent -{ +typedef struct dictent { char *Key; char *Value; } DICTENT; -typedef struct dict -{ - CosObj DictObj; +typedef struct dict { + CosObj DictObj; ASUns32 NumberOfEntries; ASUns32 CurrentEntry; DICTENT Entries[1]; } DICT; -static ASBool CountCosDictEnumProc (CosObj obj, CosObj value, void * clientData) -{ +static ASBool CountCosDictEnumProc(CosObj obj, CosObj value, void *clientData) { ASInt32 *Count = (ASInt32 *)clientData; (*Count)++; return (true); } -static ASBool LoadCosDictEnumProc (CosObj obj, CosObj value, void * clientData) -{ - DICT *Dictionary = (DICT *)clientData; - DICTENT *Entry = &Dictionary->Entries[Dictionary->CurrentEntry]; - ASTCount NameSize; - CosType ValueType = CosObjGetType (value); - ASText astKey, astValue; +static ASBool LoadCosDictEnumProc(CosObj obj, CosObj value, void *clientData) { + DICT *Dictionary = (DICT *)clientData; + DICTENT *Entry = &Dictionary->Entries[Dictionary->CurrentEntry]; + ASTCount NameSize; + CosType ValueType = CosObjGetType(value); + ASText astKey, astValue; Dictionary->CurrentEntry++; astKey = ASTextFromPDText(CosCopyNameStringValue(obj, &NameSize)); Entry->Key = reinterpret_cast(ASTextGetUnicodeCopy(astKey, kUTF8)); ASTextDestroy(astKey); - Entry->Key = CosCopyNameStringValue (obj, &NameSize); - - switch (ValueType) - { - case CosArray: - Entry->Value = (char *)ASmalloc (19); - strcpy (Entry->Value, "An Array Of Values"); - break; - - case CosBoolean: - Entry->Value = (char*)ASmalloc(6); - if (CosBooleanValue (value)) - strcpy (Entry->Value, "true"); - else - strcpy (Entry->Value, "false"); - break; - - case CosDict: - Entry->Value = (char *)ASmalloc (23); - strcpy (Entry->Value, "A dictionary of values"); - break; - - case CosInteger: - case CosReal: - { - double Numeric = CosFloatValue (value); - std::ostringstream ossF; - ossF << Numeric; - Entry->Value = (char *)ASmalloc (ossF.str().length()+1); - strcpy (Entry->Value, ossF.str().c_str()); - } - break; - - case CosName: - astValue = ASTextFromPDText(CosCopyNameStringValue(value, &NameSize)); - Entry->Value = reinterpret_cast(ASTextGetUnicodeCopy(astValue, kUTF8)); - ASTextDestroy(astValue); - break; - - case CosNull: - Entry->Value = (char *)ASmalloc (11); - strcpy (Entry->Value, "null value"); - break; - - case CosStream: - Entry->Value = (char *)ASmalloc (9); - strcpy (Entry->Value, "A Stream"); - break; - - case CosString: - astValue = ASTextFromPDText(CosCopyStringValue(value, &NameSize)); - Entry->Value = reinterpret_cast(ASTextGetUnicodeCopy(astValue, kUTF8)); - ASTextDestroy(astValue); - break; + Entry->Key = CosCopyNameStringValue(obj, &NameSize); + + switch (ValueType) { + case CosArray: + Entry->Value = (char *)ASmalloc(19); + strcpy(Entry->Value, "An Array Of Values"); + break; + + case CosBoolean: + Entry->Value = (char *)ASmalloc(6); + if (CosBooleanValue(value)) + strcpy(Entry->Value, "true"); + else + strcpy(Entry->Value, "false"); + break; + + case CosDict: + Entry->Value = (char *)ASmalloc(23); + strcpy(Entry->Value, "A dictionary of values"); + break; + + case CosInteger: + case CosReal: { + double Numeric = CosFloatValue(value); + std::ostringstream ossF; + ossF << Numeric; + Entry->Value = (char *)ASmalloc(ossF.str().length() + 1); + strcpy(Entry->Value, ossF.str().c_str()); + } break; + + case CosName: + astValue = ASTextFromPDText(CosCopyNameStringValue(value, &NameSize)); + Entry->Value = reinterpret_cast(ASTextGetUnicodeCopy(astValue, kUTF8)); + ASTextDestroy(astValue); + break; + + case CosNull: + Entry->Value = (char *)ASmalloc(11); + strcpy(Entry->Value, "null value"); + break; + + case CosStream: + Entry->Value = (char *)ASmalloc(9); + strcpy(Entry->Value, "A Stream"); + break; + + case CosString: + astValue = ASTextFromPDText(CosCopyStringValue(value, &NameSize)); + Entry->Value = reinterpret_cast(ASTextGetUnicodeCopy(astValue, kUTF8)); + ASTextDestroy(astValue); + break; } return (true); } -static DICT *LoadCosDict (CosObj Dictionary) -{ - DICT *Result; - CosType DictType = CosObjGetType (Dictionary); - ASUns32 Size = 0; +static DICT *LoadCosDict(CosObj Dictionary) { + DICT *Result; + CosType DictType = CosObjGetType(Dictionary); + ASUns32 Size = 0; if ((DictType != CosDict) && (DictType != CosStream)) return (NULL); - CosObjEnum (Dictionary, CountCosDictEnumProc, &Size); + CosObjEnum(Dictionary, CountCosDictEnumProc, &Size); ASUns32 dict_size = sizeof(DICT) + Size * sizeof(DICTENT); - Result = (DICT *)ASmalloc (dict_size); - memset ( Result, 0, dict_size ); + Result = (DICT *)ASmalloc(dict_size); + memset(Result, 0, dict_size); - Result->DictObj = Dictionary; + Result->DictObj = Dictionary; Result->NumberOfEntries = Size; Result->CurrentEntry = 0; - CosObjEnum (Dictionary, LoadCosDictEnumProc, Result); + CosObjEnum(Dictionary, LoadCosDictEnumProc, Result); return (Result); } -static void FreeDict (DICT *Dictionary) -{ +static void FreeDict(DICT *Dictionary) { ASUns32 Index; - for (Index = 0; Index < Dictionary->NumberOfEntries; Index++) - { + for (Index = 0; Index < Dictionary->NumberOfEntries; Index++) { DICTENT *Entry = &Dictionary->Entries[Index]; - ASfree (Entry->Key); - ASfree (Entry->Value); + ASfree(Entry->Key); + ASfree(Entry->Value); } - ASfree (Dictionary); + ASfree(Dictionary); return; } -std::string DisplayCosDict(CosObj cobj) -{ +std::string DisplayCosDict(CosObj cobj) { std::ostringstream oss; oss << '<'; - if (CosObjGetType(cobj) == CosDict) - { + if (CosObjGetType(cobj) == CosDict) { DICT *Dictionary = LoadCosDict(cobj); ASUns32 NumEntries = Dictionary->NumberOfEntries; - for (ASUns32 Index = 0; Index < NumEntries; Index++) - { + for (ASUns32 Index = 0; Index < NumEntries; Index++) { DICTENT *Entry = &Dictionary->Entries[Index]; oss << '\"' << Entry->Key << "\" = \"" << Entry->Value << '\"'; - if (Index + 1 < NumEntries) - { + if (Index + 1 < NumEntries) { oss << ", "; } } @@ -174,4 +159,3 @@ std::string DisplayCosDict(CosObj cobj) oss << '>'; return oss.str(); } - diff --git a/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcGraphic.cpp b/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcGraphic.cpp index 33411fc0..a7140016 100644 --- a/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcGraphic.cpp +++ b/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcGraphic.cpp @@ -17,75 +17,71 @@ #include "DisplayPDEContent.h" #include "dpcOutput.h" -void DisplayGraphicState ( PDEGraphicState *GState) -{ - char Amount[20]; +void DisplayGraphicState(PDEGraphicState *GState) { + char Amount[20]; std::ostringstream oss; oss << "Graphic State: "; - - ASFixedToCString (GState->dash.dashPhase, Amount, 20, 5); + + ASFixedToCString(GState->dash.dashPhase, Amount, 20, 5); oss << "Dash Phase: " << Amount << ", "; - + oss << "Dash Length: " << GState->dash.dashLen << ", "; oss << "Dashes ["; - for ( ASInt32 Dash = 0; Dash < GState->dash.dashLen; Dash++) - { - ASFixedToCString (GState->dash.dashes[Dash], Amount, 20, 5); + for (ASInt32 Dash = 0; Dash < GState->dash.dashLen; Dash++) { + ASFixedToCString(GState->dash.dashes[Dash], Amount, 20, 5); oss << Amount; - if (Dash+1 < GState->dash.dashLen) + if (Dash + 1 < GState->dash.dashLen) oss << ", "; } oss << "], "; - ASFixedToCString (GState->lineWidth, Amount, 20, 5); + ASFixedToCString(GState->lineWidth, Amount, 20, 5); oss << "Line Width: " << Amount << ", "; - ASFixedToCString (GState->miterLimit, Amount, 20, 5); + ASFixedToCString(GState->miterLimit, Amount, 20, 5); oss << "Miter Limit: " << Amount << ", "; - ASFixedToCString (GState->flatness, Amount, 20, 5); + ASFixedToCString(GState->flatness, Amount, 20, 5); oss << "Flatness: " << Amount << ", "; - ASFixedToCString (GState->lineCap, Amount, 20, 5); + ASFixedToCString(GState->lineCap, Amount, 20, 5); oss << "LineCap: " << Amount << ", "; - ASFixedToCString (GState->lineJoin, Amount, 20, 5); + ASFixedToCString(GState->lineJoin, Amount, 20, 5); oss << "Line Join: " << Amount << ", "; - oss << "Render Intent: " << ASAtomGetString ( GState->renderIntent ); + oss << "Render Intent: " << ASAtomGetString(GState->renderIntent); Outputter::Inst()->GetOfs() << oss.str() << std::endl; Outputter::Inst()->Indent(); oss.str(""); - if (GState->extGState) - { + if (GState->extGState) { // Format extended gstate PDEExtGState ExtState = GState->extGState; - oss << "Alpha Is Shape: " << ( PDEExtGStateGetAIS (ExtState) ? "true " : "false " ); - - oss << "Blend Mode: " << ASAtomGetString ( PDEExtGStateGetBlendMode(ExtState)) << " "; + oss << "Alpha Is Shape: " << (PDEExtGStateGetAIS(ExtState) ? "true " : "false "); + + oss << "Blend Mode: " << ASAtomGetString(PDEExtGStateGetBlendMode(ExtState)) << " "; - ASFixedToCString (PDEExtGStateGetOpacityFill (ExtState), Amount, 20, 5); + ASFixedToCString(PDEExtGStateGetOpacityFill(ExtState), Amount, 20, 5); oss << " Fill Opacity: " << Amount << ", "; - ASFixedToCString (PDEExtGStateGetOpacityStroke (ExtState), Amount, 20, 5); + ASFixedToCString(PDEExtGStateGetOpacityStroke(ExtState), Amount, 20, 5); oss << "Stroke Opacity: " << Amount << ", "; - - oss << "Fill Overprinting: " << ( PDEExtGStateGetOPFill (ExtState) ? "on " : "off " ) - << "Stroke Overprinting: " << ( PDEExtGStateGetOPStroke (ExtState) ? "on " : "off " ) << std::endl; + + oss << "Fill Overprinting: " << (PDEExtGStateGetOPFill(ExtState) ? "on " : "off ") + << "Stroke Overprinting: " << (PDEExtGStateGetOPStroke(ExtState) ? "on " : "off ") << std::endl; Outputter::Inst()->GetOfs() << oss.str(); oss.str(""); - ASFixedToCString (PDEExtGStateGetOPM (ExtState), Amount, 20, 5); + ASFixedToCString(PDEExtGStateGetOPM(ExtState), Amount, 20, 5); oss << "Overprint Mode: " << Amount << ", "; - oss << "Stroke Adjustment: " << (PDEExtGStateGetSA (ExtState) ? "enabled " : "disabled " ); - oss << "Text Knockout: " << ( PDEExtGStateGetTK (ExtState) ? "enabled " : "disabled "); - oss << (PDEExtGStateHasSoftMask (ExtState) ? "Has Soft Mask " : "Has No Soft Mask" ) << std::endl; + oss << "Stroke Adjustment: " << (PDEExtGStateGetSA(ExtState) ? "enabled " : "disabled "); + oss << "Text Knockout: " << (PDEExtGStateGetTK(ExtState) ? "enabled " : "disabled "); + oss << (PDEExtGStateHasSoftMask(ExtState) ? "Has Soft Mask " : "Has No Soft Mask") << std::endl; Outputter::Inst()->GetOfs() << oss.str(); } - Outputter::Inst()->GetOfs() << "Fill Color: " << DisplayColor (&GState->fillColorSpec ) << std::endl; - Outputter::Inst()->GetOfs() << "Stroke Color: " << DisplayColor (&GState->strokeColorSpec ) << std::endl; + Outputter::Inst()->GetOfs() << "Fill Color: " << DisplayColor(&GState->fillColorSpec) << std::endl; + Outputter::Inst()->GetOfs() << "Stroke Color: " << DisplayColor(&GState->strokeColorSpec) << std::endl; Outputter::Inst()->Outdent(); } - diff --git a/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcImage.cpp b/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcImage.cpp index de2e6568..a149890d 100644 --- a/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcImage.cpp +++ b/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcImage.cpp @@ -17,85 +17,79 @@ #include "DisplayPDEContent.h" #include "dpcOutput.h" -void DisplayImage (PDEImage Image, ASFixedMatrix *Matrix, PDEGraphicState *GState, ASBool HasGState) -{ - PDEImageAttrs Attributes; - PDEColorSpace ColorSpace = PDEImageGetColorSpace (Image); - ASInt32 ImageDataSize = PDEImageGetDataLen (Image); - ASInt32 ImageRequiredSize; +void DisplayImage(PDEImage Image, ASFixedMatrix *Matrix, PDEGraphicState *GState, ASBool HasGState) { + PDEImageAttrs Attributes; + PDEColorSpace ColorSpace = PDEImageGetColorSpace(Image); + ASInt32 ImageDataSize = PDEImageGetDataLen(Image); + ASInt32 ImageRequiredSize; - PDEImageGetAttrs (Image, &Attributes, sizeof (Attributes)); + PDEImageGetAttrs(Image, &Attributes, sizeof(Attributes)); Outputter::Inst()->GetOfs() << "Image Object: at " << DisplayMatrix(Matrix) << std::endl; Outputter::Inst()->Indent(); - ASBool IsExternal (Attributes.flags & kPDEImageExternal); - ASBool MaskedByPosition ( Attributes.flags & kPDEImageMaskedByPosition ); - ASBool MaskedByColor (Attributes.flags & kPDEImageMaskedByColor); + ASBool IsExternal(Attributes.flags & kPDEImageExternal); + ASBool MaskedByPosition(Attributes.flags & kPDEImageMaskedByPosition); + ASBool MaskedByColor(Attributes.flags & kPDEImageMaskedByColor); - ASBool IsMask (Attributes.flags & kPDEImageIsMask); - ASInt32 Comps = PDEColorSpaceGetNumComps ( IsMask ? GState->fillColorSpec.space : ColorSpace ); + ASBool IsMask(Attributes.flags & kPDEImageIsMask); + ASInt32 Comps = PDEColorSpaceGetNumComps(IsMask ? GState->fillColorSpec.space : ColorSpace); std::string sRI; - if (Attributes.intent != ASAtomNull) - { + if (Attributes.intent != ASAtomNull) { sRI = ", RenderingIntent: "; - sRI += ASAtomGetString (Attributes.intent); + sRI += ASAtomGetString(Attributes.intent); } - Outputter::Inst()->GetOfs() << ( IsMask ? "ImageMask" : "Image" ) << " of " << Attributes.width << " bits by " - << Attributes.height << " bits, " << Attributes.bitsPerComponent << " bits per " + Outputter::Inst()->GetOfs() << (IsMask ? "ImageMask" : "Image") << " of " << Attributes.width + << " bits by " << Attributes.height << " bits, " + << Attributes.bitsPerComponent << " bits per " << "component, " << Comps << " components" << sRI.c_str() << std::endl; /* Round the row size up to even 8 bit words */ ImageRequiredSize = (((Attributes.width * Comps * Attributes.bitsPerComponent) + 7) / 8); ImageRequiredSize *= Attributes.height; - ASInt32 NumberOfFilters = PDEImageGetFilterArray ( Image, NULL ); - PDEFilterArray* Filters = (PDEFilterArray*)ASmalloc (sizeof(PDEFilterArray) + (NumberOfFilters * sizeof(PDEFilterSpec))); - NumberOfFilters = PDEImageGetFilterArray (Image, Filters); + ASInt32 NumberOfFilters = PDEImageGetFilterArray(Image, NULL); + PDEFilterArray *Filters = + (PDEFilterArray *)ASmalloc(sizeof(PDEFilterArray) + (NumberOfFilters * sizeof(PDEFilterSpec))); + NumberOfFilters = PDEImageGetFilterArray(Image, Filters); std::ostringstream ossFilter; if (NumberOfFilters > 1) ossFilter << "["; - for ( ASInt32 Index = 0; Index < NumberOfFilters; Index++) - { - ossFilter << ASAtomGetString ( Filters->spec[Index].name ) << ( Index+1 < NumberOfFilters ? ", " : "" ); + for (ASInt32 Index = 0; Index < NumberOfFilters; Index++) { + ossFilter << ASAtomGetString(Filters->spec[Index].name) << (Index + 1 < NumberOfFilters ? ", " : ""); } if (NumberOfFilters > 1) ossFilter << "]"; - std::string sInLine ( "Inline" ); - if (IsExternal) - { + std::string sInLine("Inline"); + if (IsExternal) { CosObj ImageObj; CosObj Length; - PDEImageGetCosObj (Image, &ImageObj); - Length = CosDictGet (ImageObj, ASAtomFromString ("Length")); - if (CosObjGetType (Length) == CosInteger) - ImageDataSize = CosIntegerValue (Length); + PDEImageGetCosObj(Image, &ImageObj); + Length = CosDictGet(ImageObj, ASAtomFromString("Length")); + if (CosObjGetType(Length) == CosInteger) + ImageDataSize = CosIntegerValue(Length); sInLine = "External"; } - Outputter::Inst()->GetOfs() << sInLine.c_str() << " Image requires " << ImageRequiredSize << " bytes and is compressed to " - << ImageDataSize << "(" - << ((1.0 - ((ImageDataSize * 1.0) / (ImageRequiredSize * 1.0)) ) * 100.0) - << "% using " << ossFilter.str().c_str() << ')' << std::endl; - - if ( PDEImageHasSMask (Image) ) - { + Outputter::Inst()->GetOfs() << sInLine.c_str() << " Image requires " << ImageRequiredSize + << " bytes and is compressed to " << ImageDataSize << "(" + << ((1.0 - ((ImageDataSize * 1.0) / (ImageRequiredSize * 1.0))) * 100.0) + << "% using " << ossFilter.str().c_str() << ')' << std::endl; + + if (PDEImageHasSMask(Image)) { Outputter::Inst()->GetOfs() << "Image has a soft Mask\n"; } - if (MaskedByPosition) - { + if (MaskedByPosition) { Outputter::Inst()->GetOfs() << "Image is masked by Position\n"; } - - if (MaskedByColor) - { + + if (MaskedByColor) { Outputter::Inst()->GetOfs() << "Image is masked by Color\n"; } Outputter::Inst()->Outdent(); - ASfree (Filters); + ASfree(Filters); } - diff --git a/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcOutput.cpp b/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcOutput.cpp index 3c956f40..e74b2abd 100644 --- a/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcOutput.cpp +++ b/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcOutput.cpp @@ -4,51 +4,41 @@ // For complete copyright information, see: // http://dev.datalogics.com/adobe-pdf-library/adobe-pdf-library-c-language-interface/license-for-downloaded-pdf-samples/ // - + #include #include #include "dpcOutput.h" -Outputter* Outputter::m_instance = 0; +Outputter *Outputter::m_instance = 0; int Outputter::m_indentation = 0; std::string Outputter::m_filename; -std::ostream* Outputter::m_ofs; +std::ostream *Outputter::m_ofs; -Outputter* Outputter::Inst() -{ - if ( !m_instance ) - { +Outputter *Outputter::Inst() { + if (!m_instance) { m_instance = new Outputter(); } return m_instance; } -void Outputter::Init ( const char* filename ) -{ +void Outputter::Init(const char *filename) { m_filename = filename; - m_ofs = new std::ofstream ( m_filename.c_str() ); + m_ofs = new std::ofstream(m_filename.c_str()); } -void Outputter::Indent() -{ - m_indentation += 4; -} +void Outputter::Indent() { m_indentation += 4; } -void Outputter::Outdent() -{ +void Outputter::Outdent() { m_indentation -= 4; - if ( m_indentation < 0 ) - { + if (m_indentation < 0) { // Shouldn't happen if indents/outdents are matched, but just in case m_indentation = 0; } } -std::ostream& Outputter::GetOfs() -{ - for ( int i = 0; i < m_indentation; ++i ) - { +std::ostream &Outputter::GetOfs() { + for (int i = 0; i < m_indentation; ++i) { *m_ofs << ' '; } return *m_ofs; diff --git a/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcShading.cpp b/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcShading.cpp index d51a35e4..18179889 100644 --- a/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcShading.cpp +++ b/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcShading.cpp @@ -17,77 +17,61 @@ #include "DisplayPDEContent.h" #include "dpcOutput.h" -static ASBool PdeClipenumProc(PDEElement Element, void * clientData) -{ - ASFixedMatrix fm1; - ASFixedMatrix m1, matrix; - PDEType Type; - ASBool HasGState; - - PDEGraphicState GState; - HasGState = PDEElementHasGState(Element, &GState, sizeof(PDEGraphicState)); +static ASBool PdeClipenumProc(PDEElement Element, void *clientData) { + PDEGraphicState GState; + ASBool HasGState = PDEElementHasGState(Element, &GState, sizeof(PDEGraphicState)); + ASFixedMatrix fm1; + ASFixedMatrix matrix; PDEElementGetMatrix(Element, &fm1); - if ( ( fixedZero == fm1.a ) && - ( fixedZero == fm1.b ) && - ( fixedZero == fm1.c ) && - ( fixedZero == fm1.d ) && - ( fixedZero == fm1.h ) && - ( fixedZero == fm1.v ) ) - { + if ((fixedZero == fm1.a) && (fixedZero == fm1.b) && (fixedZero == fm1.c) && + (fixedZero == fm1.d) && (fixedZero == fm1.h) && (fixedZero == fm1.v)) { // Invert zero matrix --> identity matrix ASFixedMatrixInvert(&matrix, &fm1); - } - else - { + } else { PDEElementGetMatrix(Element, &matrix); } - Type = (PDEType)PDEObjectGetType((PDEObject)Element); - switch (Type) - { - case kPDEText: - // Display a complete text object - DisplayText((PDEText)Element, &matrix, &GState, HasGState); - break; - - case kPDEPath: - // Display a complete path - DisplayPath((PDEPath)Element, &matrix, &GState, HasGState); - break; - default: - Outputter::Inst()->GetOfs() << "******* Unknown Clip Element. Type " << Type << std::endl; - break; + PDEType Type = (PDEType)PDEObjectGetType((PDEObject)Element); + switch (Type) { + case kPDEText: + // Display a complete text object + DisplayText((PDEText)Element, &matrix, &GState, HasGState); + break; + + case kPDEPath: + // Display a complete path + DisplayPath((PDEPath)Element, &matrix, &GState, HasGState); + break; + default: + Outputter::Inst()->GetOfs() << "******* Unknown Clip Element. Type " << Type << std::endl; + break; } return true; } -static void DisplayClip(PDEClip Clip) -{ +static void DisplayClip(PDEClip Clip) { ASInt32 nElems = PDEClipGetNumElems(Clip); - if (nElems) - { + if (nElems) { Outputter::Inst()->GetOfs() << "Begin Clip:\n"; Outputter::Inst()->GetOfs() << "{\n"; Outputter::Inst()->Indent(); - PDEClipFlattenedEnumElems(Clip, (PDEClipEnumProc)PdeClipenumProc, NULL ); + PDEClipFlattenedEnumElems(Clip, (PDEClipEnumProc)PdeClipenumProc, NULL); Outputter::Inst()->Outdent(); Outputter::Inst()->GetOfs() << "} End of Clip\n"; } } -void DisplayShading(PDEShading Shading, ASFixedMatrix *Matrix, PDEGraphicState *GState, ASBool HasGState) -{ - Outputter::Inst()->GetOfs() << "Shading op: At " << DisplayMatrix ( Matrix ).c_str() << std::endl; +void DisplayShading(PDEShading Shading, ASFixedMatrix *Matrix, PDEGraphicState *GState, ASBool HasGState) { + Outputter::Inst()->GetOfs() << "Shading op: At " << DisplayMatrix(Matrix).c_str() << std::endl; Outputter::Inst()->Indent(); - CosObj cobj; + CosObj cobj; PDEShadingGetCosObj(Shading, &cobj); - if (CosObjGetType(cobj) == CosDict) - { - Outputter::Inst()->GetOfs() << "Shading Dictionary: " << DisplayCosDict ( cobj ) << std::endl; + if (CosObjGetType(cobj) == CosDict) { + Outputter::Inst()->GetOfs() << "Shading Dictionary: " << DisplayCosDict(cobj) << std::endl; } if (HasGState) @@ -99,4 +83,3 @@ void DisplayShading(PDEShading Shading, ASFixedMatrix *Matrix, PDEGraphicState * Outputter::Inst()->Indent(); } - diff --git a/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcSupport.cpp b/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcSupport.cpp index e795a435..1926b6b6 100644 --- a/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcSupport.cpp +++ b/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcSupport.cpp @@ -12,62 +12,57 @@ #include "DisplayPDEContent.h" -std::string DisplayQuad (ASFixedQuad *Quad ) -{ - char LLX[20], LLY[20], ULX[20], ULY[20]; - char LRX[20], LRY[20], URX[20], URY[20]; +std::string DisplayQuad(ASFixedQuad *Quad) { + char LLX[20], LLY[20], ULX[20], ULY[20]; + char LRX[20], LRY[20], URX[20], URY[20]; - ASFixedToCString (Quad->bl.h, LLX, 20, 5); - ASFixedToCString (Quad->bl.v, LLY, 20, 5); - ASFixedToCString (Quad->tl.h, ULX, 20, 5); - ASFixedToCString (Quad->tl.v, ULY, 20, 5); - ASFixedToCString (Quad->br.h, LRX, 20, 5); - ASFixedToCString (Quad->br.v, LRY, 20, 5); - ASFixedToCString (Quad->tr.h, URX, 20, 5); - ASFixedToCString (Quad->tr.v, URY, 20, 5); + ASFixedToCString(Quad->bl.h, LLX, 20, 5); + ASFixedToCString(Quad->bl.v, LLY, 20, 5); + ASFixedToCString(Quad->tl.h, ULX, 20, 5); + ASFixedToCString(Quad->tl.v, ULY, 20, 5); + ASFixedToCString(Quad->br.h, LRX, 20, 5); + ASFixedToCString(Quad->br.v, LRY, 20, 5); + ASFixedToCString(Quad->tr.h, URX, 20, 5); + ASFixedToCString(Quad->tr.v, URY, 20, 5); std::ostringstream oss; - oss << "[LL(" << LLX << ',' << LLY << "), UL(" << ULX << ',' << ULY << "), LR(" << LRX - << ',' << LRY << "), UR(" << URX << ',' << URY << ")]"; + oss << "[LL(" << LLX << ',' << LLY << "), UL(" << ULX << ',' << ULY << "), LR(" << LRX << ',' + << LRY << "), UR(" << URX << ',' << URY << ")]"; return oss.str(); } -std::string DisplayMatrix ( ASFixedMatrix *Matrix ) -{ - char a[20], b[20], c[20], d[20], h[20], v[20]; +std::string DisplayMatrix(ASFixedMatrix *Matrix) { + char a[20], b[20], c[20], d[20], h[20], v[20]; - ASFixedToCString (Matrix->a, a, 20, 5); - ASFixedToCString (Matrix->b, b, 20, 5); - ASFixedToCString (Matrix->c, c, 20, 5); - ASFixedToCString (Matrix->d, d, 20, 5); - ASFixedToCString (Matrix->h, h, 20, 5); - ASFixedToCString (Matrix->v, v, 20, 5); + ASFixedToCString(Matrix->a, a, 20, 5); + ASFixedToCString(Matrix->b, b, 20, 5); + ASFixedToCString(Matrix->c, c, 20, 5); + ASFixedToCString(Matrix->d, d, 20, 5); + ASFixedToCString(Matrix->h, h, 20, 5); + ASFixedToCString(Matrix->v, v, 20, 5); std::ostringstream oss; oss << "[" << a << ", " << b << ", " << c << ", " << d << ", " << h << ", " << v << "]"; return oss.str(); } -std::string DisplayFixed (ASFixed *Fixed) -{ +std::string DisplayFixed(ASFixed *Fixed) { char LocalText[120]; - ASFixedToCString (*Fixed, LocalText, 20, 5); - return std::string ( LocalText ); + ASFixedToCString(*Fixed, LocalText, 20, 5); + return std::string(LocalText); } -std::string AppendPoint ( ASFixedPoint *Point, ASFixedMatrix *Matrix, ASBool MoreToCome) -{ +std::string AppendPoint(ASFixedPoint *Point, ASFixedMatrix *Matrix, ASBool MoreToCome) { ASFixedPoint Local; if (Matrix) - ASFixedMatrixTransform (&Local, Matrix, Point); - else - { + ASFixedMatrixTransform(&Local, Matrix, Point); + else { Local.h = Point->h; Local.v = Point->v; } char h[20], v[20]; - ASFixedToCString (Local.h, h, 20, 5); - ASFixedToCString (Local.v, v, 20, 5); + ASFixedToCString(Local.h, h, 20, 5); + ASFixedToCString(Local.v, v, 20, 5); std::ostringstream oss; - oss << "(" << h << ", " << v << ")" << ( MoreToCome ? ", " : "" ); + oss << "(" << h << ", " << v << ")" << (MoreToCome ? ", " : ""); return oss.str(); } diff --git a/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcText.cpp b/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcText.cpp index fd28f348..b5ef032c 100644 --- a/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcText.cpp +++ b/CPlusPlus/Sample_Source/Display/DisplayPDEContent/dpcText.cpp @@ -19,29 +19,27 @@ #include "DisplayPDEContent.h" #include "dpcOutput.h" -static std::string DisplayTextState (PDETextState *State) -{ - char Amount[20]; +static std::string DisplayTextState(PDETextState *State) { + char Amount[20]; std::ostringstream oss; - ASFixedToCString (State->charSpacing, Amount, 20, 5); + ASFixedToCString(State->charSpacing, Amount, 20, 5); oss << "Char Space: " << Amount << ", "; - ASFixedToCString (State->wordSpacing, Amount, 20, 5); + ASFixedToCString(State->wordSpacing, Amount, 20, 5); oss << "Word Space: " << Amount << ", "; - ASFixedToCString (State->fontSize, Amount, 20, 5); + ASFixedToCString(State->fontSize, Amount, 20, 5); oss << "Font Size: " << Amount << ", "; - ASFixedToCString (State->hScale, Amount, 20, 5); + ASFixedToCString(State->hScale, Amount, 20, 5); oss << "Horizontal Scale: " << Amount << ", "; - ASFixedToCString (State->textRise, Amount, 20, 5); + ASFixedToCString(State->textRise, Amount, 20, 5); oss << "Text Rise: " << Amount << ", "; oss << "Render Mode: "; - switch (State->renderMode) - { + switch (State->renderMode) { case 0: oss << "Fill"; break; @@ -70,83 +68,78 @@ static std::string DisplayTextState (PDETextState *State) return oss.str(); } -void DisplayTextRun ( PDEText Text, ASUns32 Run ) -{ - ASFixedMatrix RunMatrix, TextMatrix; - ASFixedQuad TextQuad; - PDETextState TextState; +void DisplayTextRun(PDEText Text, ASUns32 Run) { + ASFixedMatrix RunMatrix, TextMatrix; + ASFixedQuad TextQuad; + PDETextState TextState; PDEGraphicState GState; - ASFixedPoint Advance; - CosObj COSFont; - PDFont TranslationFont; - PDEFont Font = PDETextGetFont (Text, kPDETextRun, Run); - ASUns32 NumBytes = PDETextGetNumBytes (Text, kPDETextRun, Run); - ASUns32 UCSBytes; - ASUns8 *TextContent; - ASUns8 *UCSText; - char *FontName; - - PDETextGetGState (Text, kPDETextRun, Run, &GState, sizeof (PDEGraphicState)); - PDETextGetMatrix (Text, kPDETextRun, Run, &RunMatrix); - PDETextGetQuad (Text, kPDETextRun, Run, &TextQuad); - PDETextGetState (Text, kPDETextRun, Run, &TextState, sizeof (TextState)); - PDETextGetTextMatrix (Text, kPDETextRun, Run, &TextMatrix); - PDETextGetAdvance (Text, kPDETextRun | kPDETextPageSpace, Run, &Advance); + ASFixedPoint Advance; + CosObj COSFont; + PDFont TranslationFont; + PDEFont Font = PDETextGetFont(Text, kPDETextRun, Run); + ASUns32 NumBytes = PDETextGetNumBytes(Text, kPDETextRun, Run); + ASUns32 UCSBytes; + ASUns8 *TextContent; + ASUns8 *UCSText; + char *FontName; + + PDETextGetGState(Text, kPDETextRun, Run, &GState, sizeof(PDEGraphicState)); + PDETextGetMatrix(Text, kPDETextRun, Run, &RunMatrix); + PDETextGetQuad(Text, kPDETextRun, Run, &TextQuad); + PDETextGetState(Text, kPDETextRun, Run, &TextState, sizeof(TextState)); + PDETextGetTextMatrix(Text, kPDETextRun, Run, &TextMatrix); + PDETextGetAdvance(Text, kPDETextRun | kPDETextPageSpace, Run, &Advance); // Obtain the text in whatever encoding the font used - TextContent = (ASUns8 *)ASmalloc (NumBytes+2); - PDETextGetText (Text, kPDETextRun, Run, TextContent); - TextContent[NumBytes] = TextContent[NumBytes+1] = '\0'; + TextContent = (ASUns8 *)ASmalloc(NumBytes + 2); + PDETextGetText(Text, kPDETextRun, Run, TextContent); + TextContent[NumBytes] = TextContent[NumBytes + 1] = '\0'; // Create a PD font, and translate the font encoded text to UCS - PDEFontGetCosObj (Font, &COSFont); - TranslationFont = PDFontFromCosObj (COSFont); - UCSBytes = PDFontXlateToUCS (TranslationFont, TextContent, NumBytes, NULL, 0); + PDEFontGetCosObj(Font, &COSFont); + TranslationFont = PDFontFromCosObj(COSFont); + UCSBytes = PDFontXlateToUCS(TranslationFont, TextContent, NumBytes, NULL, 0); UCSText = (ASUns8 *)ASmalloc(UCSBytes + 2); - UCSBytes = PDFontXlateToUCS (TranslationFont, TextContent, NumBytes, UCSText, UCSBytes+2); + UCSBytes = PDFontXlateToUCS(TranslationFont, TextContent, NumBytes, UCSText, UCSBytes + 2); - ASText displayText = ASTextFromSizedUnicode ( (ASUTF16Val*)UCSText, kUTF16BigEndian, UCSBytes ); - char* displayTextUTF8 = reinterpret_cast(ASTextGetUnicodeCopy(displayText, kUTF8)); - ASTextDestroy ( displayText ); + ASText displayText = ASTextFromSizedUnicode((ASUTF16Val *)UCSText, kUTF16BigEndian, UCSBytes); + char *displayTextUTF8 = reinterpret_cast(ASTextGetUnicodeCopy(displayText, kUTF8)); + ASTextDestroy(displayText); ASText asFontName = ASTextNew(); PDFontGetASTextName(TranslationFont, false, asFontName); FontName = (char *)ASTextGetUnicodeCopy(asFontName, kUTF8); ASTextDestroy(asFontName); - Outputter::Inst()->GetOfs() << "Text Run: At " << DisplayQuad ( &TextQuad ) << std::endl; + Outputter::Inst()->GetOfs() << "Text Run: At " << DisplayQuad(&TextQuad) << std::endl; Outputter::Inst()->Indent(); - Outputter::Inst()->GetOfs() << "Matrix: " << DisplayMatrix ( &TextMatrix ) << " Font: " << FontName << std::endl; - Outputter::Inst()->GetOfs() << "Text State: " << DisplayTextState ( &TextState ) << std::endl; + Outputter::Inst()->GetOfs() << "Matrix: " << DisplayMatrix(&TextMatrix) << " Font: " << FontName + << std::endl; + Outputter::Inst()->GetOfs() << "Text State: " << DisplayTextState(&TextState) << std::endl; - DisplayGraphicState (&GState); + DisplayGraphicState(&GState); Outputter::Inst()->GetOfs() << "Content: \"" << displayTextUTF8 << "\"" << std::endl; Outputter::Inst()->Outdent(); - ASfree (UCSText); - ASfree (TextContent); + ASfree(UCSText); + ASfree(TextContent); ASfree(displayTextUTF8); ASfree(FontName); } -void DisplayText (PDEText Text, ASFixedMatrix *Matrix, PDEGraphicState *GState, ASBool HasGState) -{ - ASUns32 Runs = PDETextGetNumRuns (Text); +void DisplayText(PDEText Text, ASFixedMatrix *Matrix, PDEGraphicState *GState, ASBool HasGState) { + ASUns32 Runs = PDETextGetNumRuns(Text); - Outputter::Inst()->GetOfs() << "Text Object: At " << DisplayMatrix ( Matrix ) << ", contains " + Outputter::Inst()->GetOfs() << "Text Object: At " << DisplayMatrix(Matrix) << ", contains " << Runs << " runs.\n"; Outputter::Inst()->GetOfs() << "{\n"; Outputter::Inst()->Indent(); - for ( ASUns32 Run = 0; Run < Runs; Run++) - { - DisplayTextRun ( Text, Run ); + for (ASUns32 Run = 0; Run < Runs; Run++) { + DisplayTextRun(Text, Run); } Outputter::Inst()->Outdent(); Outputter::Inst()->GetOfs() << "}\n"; } - - - diff --git a/CPlusPlus/Sample_Source/Display/PDFViewer/PDFViewer.cpp b/CPlusPlus/Sample_Source/Display/PDFViewer/PDFViewer.cpp index 6641ffc7..90c2588b 100644 --- a/CPlusPlus/Sample_Source/Display/PDFViewer/PDFViewer.cpp +++ b/CPlusPlus/Sample_Source/Display/PDFViewer/PDFViewer.cpp @@ -1567,7 +1567,7 @@ void CPDFViewerView::PageToScreen() { */ switch (PageRotate) { case 0: - ASDoubleMatrixTranslate(&RotateMatrix, &RotateMatrix, 0, -PageSize.top); + ASDoubleMatrixTranslate(&RotateMatrix, &RotateMatrix, -PageSize.left, -PageSize.top); break; case 90: diff --git a/CPlusPlus/Sample_Source/DocumentConversion/ConvertPDFtoPostscript/ConvertPDFtoPostscript.cpp b/CPlusPlus/Sample_Source/DocumentConversion/ConvertPDFtoPostscript/ConvertPDFtoPostscript.cpp index 1101ce72..ab469f33 100644 --- a/CPlusPlus/Sample_Source/DocumentConversion/ConvertPDFtoPostscript/ConvertPDFtoPostscript.cpp +++ b/CPlusPlus/Sample_Source/DocumentConversion/ConvertPDFtoPostscript/ConvertPDFtoPostscript.cpp @@ -8,7 +8,7 @@ // // Command-line: (Both optional) // -// For more detail see the description of the ConvertPDFtoPostscript sample program on our Developer’s site, +// For more detail see the description of the ConvertPDFtoPostscript sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#convertpdftopostscript #include "InitializeLibrary.h" @@ -20,77 +20,75 @@ #define DEF_INPUT "Ulysses.pdf" #define DEF_OUTPUT "ConvertPDFtoPostscript-out.ps" -int main(int argc, char **argv) -{ +int main(int argc, char **argv) { APDFLib lib; ASErrorCode errCode = 0; - if (lib.isValid() == false) - { + if (lib.isValid() == false) { errCode = lib.getInitError(); std::cout << "Initialization failed with code " << errCode << std::endl; return lib.getInitError(); } - - std::string csInputFileName ( argc > 1 ? argv[1] : DIR_LOC DEF_INPUT ); - std::string csOutputFileName ( argc > 2 ? argv[2] : DEF_OUTPUT ); + + std::string csInputFileName(argc > 1 ? argv[1] : DIR_LOC DEF_INPUT); + std::string csOutputFileName(argc > 2 ? argv[2] : DEF_OUTPUT); std::cout << "Will convert " << csInputFileName.c_str() << " to Postscript, writing output to " << csOutputFileName.c_str() << std::endl; -DURING + DURING + + // Step 1) Open the input PDF -// Step 1) Open the input PDF + // Open the input document, repairing it if necessary. + APDFLDoc inAPDoc(csInputFileName.c_str(), true); + PDDoc inDoc = inAPDoc.getPDDoc(); - // Open the input document, repairing it if necessary. - APDFLDoc inAPDoc ( csInputFileName.c_str(), true); - PDDoc inDoc = inAPDoc.getPDDoc(); + // Step 2) Initialize print parameters -// Step 2) Initialize print parameters + // Set defaults (see SetupPrintParams files in Common folder) + PDPrintParamsRec psParams; + SetupPDPrintParams(&psParams); - // Set defaults (see SetupPrintParams files in Common folder) - PDPrintParamsRec psParams; - SetupPDPrintParams(&psParams); + PDFLPrintUserParamsRec userParams; + SetupPDFLPrintUserParams(&userParams); - PDFLPrintUserParamsRec userParams; - SetupPDFLPrintUserParams(&userParams); + // Override defaults with specifics for this sample + userParams.emitToFile = true; // Print to file + psParams.emitPS = true; // Create PS file - // Override defaults with specifics for this sample - userParams.emitToFile = true; // Print to file - psParams.emitPS = true; // Create PS file + // Step 3) Open the output stream and set print param for stream -// Step 3) Open the output stream and set print param for stream + // Create the file for output + ASFile outFile = APDFLDoc::OpenFlatFile(csOutputFileName.c_str(), ASFILE_WRITE | ASFILE_CREATE); - // Create the file for output - ASFile outFile = APDFLDoc::OpenFlatFile ( csOutputFileName.c_str(), ASFILE_WRITE | ASFILE_CREATE ); + // Create writeable ProcStm to handle the print stream + ASStm printStm = ASFileStmWrOpen(outFile, 0); - // Create writeable ProcStm to handle the print stream - ASStm printStm = ASFileStmWrOpen ( outFile, 0 ); + userParams.printStm = printStm; // Send output to the writeable stream + userParams.printParams = &psParams; // Connect the two structures - userParams.printStm = printStm; // Send output to the writeable stream - userParams.printParams = &psParams; // Connect the two structures + // Step 4) Write to PS file, close it, and clean up -// Step 4) Write to PS file, close it, and clean up + DURING + PDFLPrintDoc(inDoc, &userParams); + HANDLER + errCode = ERRORCODE; + lib.displayError(errCode); + END_HANDLER -DURING - PDFLPrintDoc(inDoc, &userParams); -HANDLER - errCode = ERRORCODE; - lib.displayError(errCode); -END_HANDLER - - // Cleanup and free memory - DisposePDPrintParams(&psParams); - DisposePDFLPrintUserParams(&userParams); + // Cleanup and free memory + DisposePDPrintParams(&psParams); + DisposePDFLPrintUserParams(&userParams); - ASStmClose(printStm); // Close the file stream - PDDocClose(inDoc); // Close the input document + ASStmClose(printStm); // Close the file stream + PDDocClose(inDoc); // Close the input document - ASFileFlush(outFile); // Safely close outFile - ASFileClose(outFile); + ASFileFlush(outFile); // Safely close outFile + ASFileClose(outFile); -HANDLER - errCode = ERRORCODE; - lib.displayError(errCode); -END_HANDLER + HANDLER + errCode = ERRORCODE; + lib.displayError(errCode); + END_HANDLER - return errCode; // APDFLib's destructor terminates the APDFL + return errCode; // APDFLib's destructor terminates the APDFL }; diff --git a/CPlusPlus/Sample_Source/DocumentConversion/ConvertToPDFA/ConvertToPDFA.cpp b/CPlusPlus/Sample_Source/DocumentConversion/ConvertToPDFA/ConvertToPDFA.cpp index 759f2571..71fa9e4d 100644 --- a/CPlusPlus/Sample_Source/DocumentConversion/ConvertToPDFA/ConvertToPDFA.cpp +++ b/CPlusPlus/Sample_Source/DocumentConversion/ConvertToPDFA/ConvertToPDFA.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2017-2019, Datalogics, Inc. All rights reserved. +// Copyright (c) 2017, Datalogics, Inc. All rights reserved. // // For complete copyright information, refer to: // http://dev.datalogics.com/adobe-pdf-library/license-for-downloaded-pdf-samples/ @@ -7,19 +7,16 @@ // ConvertToPDFA converts the input PDF to a PDF/A compliant PDF. // // Command-line: (all parameters are optional moving from left to right) -// where convert-option is '1a', '1b', '2b', '2u', '3b', or '3u' and where color-space is 'rgb' or 'cmyk' -// if no parameters are specified, a pre-selected PDF is input and converted using 1b RGB. +// where convert-option is 'PDF1b' or 'PDF1a' and where color-space is 'rgb' or 'cmyk' +// if no parameters are specified, a pre-selected PDF is input and converted using PDFA1bRGB // // For example, you might enter a command line statement that looks like this: // -// ConvertToPDFA input-file.pdf 2b +// ConvertToPDFA input-file.pdf PDF1a // -// This statement provides the name of an input file and specifies the PDF/A-2b format, rather than +// This statement provides the name of an input file and specifies the PDF/A-1a format, rather than // the default PDF/A-1b format. -// -// NOTE: Level A conformance requires logical structure information (tagging) exist for the document, if this is not -// present. Conversion will be re-attempted using Level B conformance. -// For more detail see the description of the ConvertToPDFA sample program on our Developer’s site, +// For more detail see the description of the ConvertToPDFA sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#converttopdfa #include @@ -32,283 +29,132 @@ #define DEF_INPUT "Ulysses.pdf" #define DEF_OUTPUT "ConvertToPDFA-out.pdf" -//forward declarations +// forward declarations ASBool PDFProcessorProgressMonitorCB(ASInt32 pageNum, ASInt32 totalPages, float current, void *clientData); void SetupPDFAProcessorParams(PDFProcessorPDFAConvertParams userParams); -int main(int argc, char **argv) -{ +int main(int argc, char **argv) { PDFProcessorPDFAConversionOption convertOption; - char *outputPathName; /* Step 1) Select conversion option */ - if (argc < 2) - { + if (argc < 2) { std::cout << "PDF Conversion Standard not specified or unknown, defaulting to PDFA1bRGB." << std::endl; convertOption = kPDFProcessorConvertToPDFA1bRGB; - outputPathName = DEF_OUTPUT; - } - else if (argc > 2 && (!strcmp(argv[2], "1b") || !strcmp(argv[2], "1B"))) - { - if (argc > 3) - { - if (!strcmp(argv[3], "rgb") || !strcmp(argv[3], "RGB")) - { + } else if (argc > 2 && (!strcmp(argv[2], "PDFA1b") || !strcmp(argv[2], "PDFA1B"))) { + if (argc > 3) { + if (!strcmp(argv[3], "rgb") || !strcmp(argv[3], "RGB")) { convertOption = kPDFProcessorConvertToPDFA1bRGB; - } - else if (!strcmp(argv[3], "cmyk") || !strcmp(argv[3], "CMYK")) - { + } else if (!strcmp(argv[3], "cmyk") || !strcmp(argv[3], "CMYK")) { convertOption = kPDFProcessorConvertToPDFA1bCMYK; } - } - else - { + } else { convertOption = kPDFProcessorConvertToPDFA1bRGB; } - outputPathName = DEF_OUTPUT; - } - else if (argc > 2 && (!strcmp(argv[2], "1a") || !strcmp(argv[2], "1A"))) - { - if (argc > 3) - { - if (!strcmp(argv[3], "rgb") || !strcmp(argv[3], "RGB")) - { + } else if (argc > 2 && (!strcmp(argv[2], "PDFA1a") || !strcmp(argv[2], "PDFA1A"))) { + if (argc > 3) { + if (!strcmp(argv[3], "rgb") || !strcmp(argv[3], "RGB")) { convertOption = kPDFProcessorConvertToPDFA1aRGB; - } - else if (!strcmp(argv[3], "cmyk") || !strcmp(argv[3], "CMYK")) - { + } else if (!strcmp(argv[3], "cmyk") || !strcmp(argv[3], "CMYK")) { convertOption = kPDFProcessorConvertToPDFA1aCMYK; } - } - else - { + } else { convertOption = kPDFProcessorConvertToPDFA1aRGB; } - outputPathName = DEF_OUTPUT; - } - else if (argc > 2 && (!strcmp(argv[2], "2b") || !strcmp(argv[2], "2B"))) - { - if (argc > 3) - { - if (!strcmp(argv[3], "rgb") || !strcmp(argv[3], "RGB")) - { - convertOption = kPDFProcessorConvertToPDFA2bRGB; - } - else if (!strcmp(argv[3], "cmyk") || !strcmp(argv[3], "CMYK")) - { - convertOption = kPDFProcessorConvertToPDFA2bCMYK; - } - } - else - { - convertOption = kPDFProcessorConvertToPDFA2bRGB; - } - outputPathName = DEF_OUTPUT; - } - else if (argc > 2 && (!strcmp(argv[2], "2u") || !strcmp(argv[2], "2U"))) - { - if (argc > 3) - { - if (!strcmp(argv[3], "rgb") || !strcmp(argv[3], "RGB")) - { - convertOption = kPDFProcessorConvertToPDFA2uRGB; - } - else if (!strcmp(argv[3], "cmyk") || !strcmp(argv[3], "CMYK")) - { - convertOption = kPDFProcessorConvertToPDFA2uCMYK; - } - } - else - { - convertOption = kPDFProcessorConvertToPDFA2uRGB; - } - outputPathName = DEF_OUTPUT; - } - else if (argc > 2 && (!strcmp(argv[2], "3b") || !strcmp(argv[2], "3B"))) - { - if (argc > 3) - { - if (!strcmp(argv[3], "rgb") || !strcmp(argv[3], "RGB")) - { - convertOption = kPDFProcessorConvertToPDFA3bRGB; - } - else if (!strcmp(argv[3], "cmyk") || !strcmp(argv[3], "CMYK")) - { - convertOption = kPDFProcessorConvertToPDFA3bCMYK; - } - } - else - { - convertOption = kPDFProcessorConvertToPDFA3bRGB; - } - outputPathName = DEF_OUTPUT; - } - else if (argc > 2 && (!strcmp(argv[2], "3u") || !strcmp(argv[2], "3U"))) - { - if (argc > 3) - { - if (!strcmp(argv[3], "rgb") || !strcmp(argv[3], "RGB")) - { - convertOption = kPDFProcessorConvertToPDFA3uRGB; - } - else if (!strcmp(argv[3], "cmyk") || !strcmp(argv[3], "CMYK")) - { - convertOption = kPDFProcessorConvertToPDFA3uCMYK; - } - } - else - { - convertOption = kPDFProcessorConvertToPDFA3uRGB; - } - outputPathName = DEF_OUTPUT; - } - else - { + } else { std::cout << "PDF Conversion Standard not specified or unknown, defaulting to PDFA1bRGB." << std::endl; convertOption = kPDFProcessorConvertToPDFA1bRGB; - outputPathName = DEF_OUTPUT; } APDFLib lib; ASErrorCode errCode = 0; - if (lib.isValid() == false) - { + if (lib.isValid() == false) { errCode = lib.getInitError(); std::cout << "Initialization failed with code " << errCode << std::endl; return lib.getInitError(); } - - std::string csInputFileName ( argc > 1 ? argv[1] : DIR_LOC DEF_INPUT ); - std::string csOutputFileName ( DEF_OUTPUT ); + + std::string csInputFileName(argc > 1 ? argv[1] : DIR_LOC DEF_INPUT); + std::string csOutputFileName(DEF_OUTPUT); std::cout << "Will convert " << csInputFileName.c_str() << " to a PDF/A compliant PDF named " << csOutputFileName.c_str() << std::endl; -DURING - gPDFProcessorHFT = InitPDFProcessorHFT; + DURING + gPDFProcessorHFT = InitPDFProcessorHFT; - //Step 2) initialize PDFProcessor plugin - if(PDFProcessorInitialize()) - { - ASInt32 res = false; + // Step 2) initialize PDFProcessor plugin + if (PDFProcessorInitialize()) { + ASInt32 res = false; - ASPathName destFilePath = NULL; + ASPathName destFilePath = NULL; - // Step 3) Open the input PDF - APDFLDoc inAPDoc ( csInputFileName.c_str(), true); // Open the input document, repairing it if necessary. + // Step 3) Open the input PDF + APDFLDoc inAPDoc(csInputFileName.c_str(), true); // Open the input document, repairing it if necessary. #if !MAC_ENV - destFilePath = ASFileSysCreatePathName( NULL, ASAtomFromString("Cstring"), csOutputFileName.c_str(), NULL ); + destFilePath = + ASFileSysCreatePathName(NULL, ASAtomFromString("Cstring"), csOutputFileName.c_str(), NULL); #else - destFilePath = APDFLDoc::makePath ( csOutputFileName.c_str() ); + destFilePath = APDFLDoc::makePath(csOutputFileName.c_str()); #endif - // Step 4) Convert the input PDF - PDFProcessorPDFAConvertParamsRec userParamsA; - std::cout << "Converting using PDFProcessorConvertAndSaveToPDFA (with Callback)" << std::endl; - SetupPDFAProcessorParams(&userParamsA); - - bool levelAConversionNotPossible = false; - - DURING - res = PDFProcessorConvertAndSaveToPDFA(inAPDoc.getPDDoc(), destFilePath, ASGetDefaultFileSys(), convertOption, &userParamsA); - HANDLER - errCode = ERRORCODE; - - char errStr[250]; - ASGetErrorString(errCode, errStr, sizeof(errStr)); + // Step 4) Convert the input PDF + PDFProcessorPDFAConvertParamsRec userParamsA; + std::cout << "Converting using PDFProcessorConvertAndSaveToPDFA (with Callback)" << std::endl; + SetupPDFAProcessorParams(&userParamsA); - bool levelAConformanceNotPossible = false; + res = PDFProcessorConvertAndSaveToPDFA(inAPDoc.getPDDoc(), destFilePath, + ASGetDefaultFileSys(), convertOption, &userParamsA); - if (strcmp(errStr, "Structure Tree Root Is Missing") == 0) - { - std::cout << std::endl << "PDF/A Level A requires logical structure information (tagging), the input PDF was not " << std::endl - << "created with this information and this information can not be created automatically." << std::endl - << "Conversion will be re-attempted using Level B conformance instead." << std::endl << std::endl; - - if (!strcmp(argv[3], "rgb") || !strcmp(argv[3], "RGB")) - { - convertOption = kPDFProcessorConvertToPDFA1bRGB; - } - else if (!strcmp(argv[3], "cmyk") || !strcmp(argv[3], "CMYK")) - { - convertOption = kPDFProcessorConvertToPDFA1bCMYK; - } - - errCode = 0; - levelAConversionNotPossible = true; - } - else - { - RERAISE(); + if (res) { + std::cout << "File " << csInputFileName.c_str() + << " has been successfully Converted." << std::endl; + } else { + std::cout << "Conversion of file " << csInputFileName.c_str() << " has failed..." << std::endl; } - END_HANDLER - - if (levelAConversionNotPossible) - { - res = PDFProcessorConvertAndSaveToPDFA(inAPDoc.getPDDoc(), destFilePath, ASGetDefaultFileSys(), convertOption, &userParamsA); - } - if(res) - { - std::cout << "File " << csInputFileName.c_str() << " has been successfully Converted." << std::endl; - } - else - { - std::cout << "Conversion of file " << csInputFileName.c_str() << " has failed..." << std::endl; - } + // Cleanup and free memory + if (destFilePath) { + ASFileSysReleasePath(ASGetDefaultFileSys(), destFilePath); + } - // Cleanup and free memory - if (destFilePath) - { - ASFileSysReleasePath(ASGetDefaultFileSys(), destFilePath); + // Terminate PDFProcessor plugin + PDFProcessorTerminate(); } + HANDLER + errCode = ERRORCODE; + lib.displayError(errCode); - //Terminate PDFProcessor plugin + // Terminate PDFProcessor plugin PDFProcessorTerminate(); - } -HANDLER - errCode = ERRORCODE; - lib.displayError(errCode); - - //Terminate PDFProcessor plugin - PDFProcessorTerminate(); -END_HANDLER + END_HANDLER - return errCode;// APDFLib's destructor terminates APDFL + return errCode; // APDFLib's destructor terminates APDFL } -ASBool PDFProcessorProgressMonitorCB(ASInt32 pageNum, ASInt32 totalPages, float current, void *clientData) -{ - if (clientData) - { - ASBool * IsMonitorCalled = (ASBool*)clientData; - if (*IsMonitorCalled == false) - { +ASBool PDFProcessorProgressMonitorCB(ASInt32 pageNum, ASInt32 totalPages, float current, void *clientData) { + if (clientData) { + ASBool *IsMonitorCalled = (ASBool *)clientData; + if (*IsMonitorCalled == false) { std::cout << "PDFProcessor Progress Monitor CallBack" << std::endl; - //Set to true to Display this Message Only Once + // Set to true to Display this Message Only Once *IsMonitorCalled = true; } } - std::cout << "PDFProcessor Page " - << pageNum + 1 << " of " /* Adding 1, since Page numbers are 0-indexed*/ - << totalPages << ". Overall Progress = " - << current << "%." /* Current Overall Progress */ - << std::endl; + std::cout << "PDFProcessor Page " << pageNum + 1 << " of " /* Adding 1, since Page numbers are 0-indexed*/ + << totalPages << ". Overall Progress = " << current << "%." /* Current Overall Progress */ + << std::endl; - //Return 1 to Cancel conversion + // Return 1 to Cancel conversion return 0; } -void SetupPDFAProcessorParams(PDFProcessorPDFAConvertParams userParams) -{ - memset (userParams, 0, sizeof (PDFProcessorPDFAConvertParamsRec)); +void SetupPDFAProcessorParams(PDFProcessorPDFAConvertParams userParams) { + memset(userParams, 0, sizeof(PDFProcessorPDFAConvertParamsRec)); userParams->size = sizeof(PDFProcessorPDFAConvertParamsRec); userParams->progMon = PDFProcessorProgressMonitorCB; userParams->noRasterizationOnFontErrors = false; userParams->removeAllAnnotations = false; userParams->colorCompression = kPDFProcessorColorJpegCompression; - userParams->noValidationErrors = false; - userParams->validateImplementationLimitsOfDocument = true; } diff --git a/CPlusPlus/Sample_Source/DocumentConversion/ConvertToPDFX/ConvertToPDFX.cpp b/CPlusPlus/Sample_Source/DocumentConversion/ConvertToPDFX/ConvertToPDFX.cpp index 7f2ec446..69e0050b 100644 --- a/CPlusPlus/Sample_Source/DocumentConversion/ConvertToPDFX/ConvertToPDFX.cpp +++ b/CPlusPlus/Sample_Source/DocumentConversion/ConvertToPDFX/ConvertToPDFX.cpp @@ -16,7 +16,7 @@ // // This statement provides the name of an input file and specifies the PDF/X-3:2003 format, rather than // the default PDF/X-1a:2001 format. -// For more detail see the description of the ConvertToPDFX sample program on our Developer’s site, +// For more detail see the description of the ConvertToPDFX sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#converttopdfx #include @@ -29,137 +29,114 @@ #define DEF_INPUT "Ulysses.pdf" #define DEF_OUTPUT "ConvertToPDFX-out.pdf" -//forward declarations +// forward declarations ASBool PDFProcessorProgressMonitorCB(ASInt32 pageNum, ASInt32 totalPages, float current, void *clientData); void SetupPDFXProcessorParams(PDFProcessorPDFXConvertParams userParams); -int main(int argc, char **argv) -{ +int main(int argc, char **argv) { PDFProcessorPDFXConversionOption convertOption; - char *outputPathName; /* Step 1) Select conversion option */ - if (argc < 2) - { + if (argc < 2) { std::cout << "PDF Conversion Standard not specified or unknown, defaulting to PDFX1a2001." << std::endl; convertOption = kPDFProcessorConvertToPDFX1a2001; - outputPathName = DEF_OUTPUT; - } - else if (argc > 2 && (!strcmp(argv[2], "PDFX1a2001") || !strcmp(argv[2], "PDFX1A2001"))) - { + } else if (argc > 2 && (!strcmp(argv[2], "PDFX1a2001") || !strcmp(argv[2], "PDFX1A2001"))) { convertOption = kPDFProcessorConvertToPDFX1a2001; - outputPathName = DEF_OUTPUT; - } - else if (argc > 2 && (!strcmp(argv[2], "PDFX32003"))) - { + } else if (argc > 2 && (!strcmp(argv[2], "PDFX32003"))) { convertOption = kPDFProcessorConvertToPDFX32003; - - outputPathName = DEF_OUTPUT; - } - else - { + + } else { std::cout << "PDF Conversion Standard not specified or unknown, defaulting to PDFX1a2001." << std::endl; convertOption = kPDFProcessorConvertToPDFX1a2001; - outputPathName = DEF_OUTPUT; } APDFLib lib; ASErrorCode errCode = 0; - if (lib.isValid() == false) - { + if (lib.isValid() == false) { errCode = lib.getInitError(); std::cout << "Initialization failed with code " << errCode << std::endl; return lib.getInitError(); } - - std::string csInputFileName ( argc > 1 ? argv[1] : DIR_LOC DEF_INPUT ); - std::string csOutputFileName ( DEF_OUTPUT ); - std::cout << "Will convert " << csInputFileName.c_str() << " to a PDF/X compliant PDF named " - << csOutputFileName.c_str() << std::endl; -DURING - gPDFProcessorHFT = InitPDFProcessorHFT; + std::string csInputFileName(argc > 1 ? argv[1] : DIR_LOC DEF_INPUT); + std::string csOutputFileName(DEF_OUTPUT); + std::cout << "Will convert " << csInputFileName << " to a PDF/X compliant PDF named " + << csOutputFileName << std::endl; + + DURING + gPDFProcessorHFT = InitPDFProcessorHFT; - //Step 2) initialize PDFProcessor plugin - if(PDFProcessorInitialize()) - { - ASInt32 res = false; + // Step 2) initialize PDFProcessor plugin + if (PDFProcessorInitialize()) { + ASInt32 res = false; - ASPathName destFilePath = NULL; + ASPathName destFilePath = NULL; - // Step 3) Open the input PDF - APDFLDoc inAPDoc ( csInputFileName.c_str(), true); // Open the input document, repairing it if necessary. + // Step 3) Open the input PDF + APDFLDoc inAPDoc(csInputFileName.c_str(), true); // Open the input document, repairing it if necessary. #if !MAC_ENV - destFilePath = ASFileSysCreatePathName( NULL, ASAtomFromString("Cstring"), csOutputFileName.c_str(), NULL ); + destFilePath = + ASFileSysCreatePathName(NULL, ASAtomFromString("Cstring"), csOutputFileName.c_str(), NULL); #else - destFilePath = APDFLDoc::makePath ( csOutputFileName.c_str() ); + destFilePath = APDFLDoc::makePath(csOutputFileName.c_str()); #endif - // Step 4) Convert the input PDF - PDFProcessorPDFXConvertParamsRec userParamsX; - std::cout << "Converting using PDFProcessorConvertAndSaveToPDFX (with Callback)" << std::endl; - SetupPDFXProcessorParams(&userParamsX); + // Step 4) Convert the input PDF + PDFProcessorPDFXConvertParamsRec userParamsX; + std::cout << "Converting using PDFProcessorConvertAndSaveToPDFX (with Callback)" << std::endl; + SetupPDFXProcessorParams(&userParamsX); - res = PDFProcessorConvertAndSaveToPDFX(inAPDoc.getPDDoc(), destFilePath, ASGetDefaultFileSys(), convertOption, &userParamsX); + res = PDFProcessorConvertAndSaveToPDFX(inAPDoc.getPDDoc(), destFilePath, + ASGetDefaultFileSys(), convertOption, &userParamsX); - if(res) - { - std::cout << "File " << csInputFileName.c_str() << " has been successfully Converted." << std::endl; - } - else - { - std::cout << "Conversion of file " << csInputFileName.c_str() << " has failed..." << std::endl; - } + if (res) { + std::cout << "File " << csInputFileName << " has been successfully Converted." << std::endl; + } else { + std::cout << "Conversion of file " << csInputFileName << " has failed..." << std::endl; + } + + // Cleanup and free memory + if (destFilePath) { + ASFileSysReleasePath(ASGetDefaultFileSys(), destFilePath); + } - // Cleanup and free memory - if (destFilePath) - { - ASFileSysReleasePath(ASGetDefaultFileSys(), destFilePath); + // Terminate PDFProcessor plugin + PDFProcessorTerminate(); } + HANDLER + errCode = ERRORCODE; + lib.displayError(errCode); - //Terminate PDFProcessor plugin + // Terminate PDFProcessor plugin PDFProcessorTerminate(); - } -HANDLER - errCode = ERRORCODE; - lib.displayError(errCode); - - //Terminate PDFProcessor plugin - PDFProcessorTerminate(); -END_HANDLER + END_HANDLER - return errCode;// APDFLib's destructor terminates APDFL + return errCode; // APDFLib's destructor terminates APDFL } -ASBool PDFProcessorProgressMonitorCB(ASInt32 pageNum, ASInt32 totalPages, float current, void *clientData) -{ - if (clientData) - { - ASBool * IsMonitorCalled = (ASBool*)clientData; - if (*IsMonitorCalled == false) - { +ASBool PDFProcessorProgressMonitorCB(ASInt32 pageNum, ASInt32 totalPages, float current, void *clientData) { + if (clientData) { + ASBool *IsMonitorCalled = (ASBool *)clientData; + if (*IsMonitorCalled == false) { std::cout << "PDFProcessor Progress Monitor CallBack" << std::endl; - //Set to true to Display this Message Only Once + // Set to true to Display this Message Only Once *IsMonitorCalled = true; } } - std::cout << "PDFProcessor Page " - << pageNum + 1 << " of " /* Adding 1, since Page numbers are 0-indexed*/ - << totalPages << ". Overall Progress = " - << current << "%." /* Current Overall Progress */ - << std::endl; + std::cout << "PDFProcessor Page " << pageNum + 1 << " of " /* Adding 1, since Page numbers are 0-indexed*/ + << totalPages << ". Overall Progress = " << current << "%." /* Current Overall Progress */ + << std::endl; - //Return 1 to Cancel conversion + // Return 1 to Cancel conversion return 0; } -void SetupPDFXProcessorParams(PDFProcessorPDFXConvertParams userParams) -{ - memset (userParams, 0, sizeof (PDFProcessorPDFXConvertParamsRec)); +void SetupPDFXProcessorParams(PDFProcessorPDFXConvertParams userParams) { + memset(userParams, 0, sizeof(PDFProcessorPDFXConvertParamsRec)); userParams->size = sizeof(PDFProcessorPDFXConvertParamsRec); userParams->progMon = PDFProcessorProgressMonitorCB; userParams->removeAllAnnotations = false; diff --git a/CPlusPlus/Sample_Source/DocumentConversion/ConvertToZUGFeRD/ConvertToZUGFeRD.cpp b/CPlusPlus/Sample_Source/DocumentConversion/ConvertToZUGFeRD/ConvertToZUGFeRD.cpp index 7fe3bba5..918b9256 100644 --- a/CPlusPlus/Sample_Source/DocumentConversion/ConvertToZUGFeRD/ConvertToZUGFeRD.cpp +++ b/CPlusPlus/Sample_Source/DocumentConversion/ConvertToZUGFeRD/ConvertToZUGFeRD.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2019, Datalogics, Inc. All rights reserved. +// Copyright (c) 2019-2021, Datalogics, Inc. All rights reserved. // // For complete copyright information, refer to: // http://dev.datalogics.com/adobe-pdf-library/license-for-downloaded-pdf-samples/ diff --git a/CPlusPlus/Sample_Source/DocumentConversion/XPStoPDF/XPStoPDF.cpp b/CPlusPlus/Sample_Source/DocumentConversion/XPStoPDF/XPStoPDF.cpp index 7715f4df..f7cc08a9 100644 --- a/CPlusPlus/Sample_Source/DocumentConversion/XPStoPDF/XPStoPDF.cpp +++ b/CPlusPlus/Sample_Source/DocumentConversion/XPStoPDF/XPStoPDF.cpp @@ -4,7 +4,7 @@ // // This sample demonstrates the XPS2PDF plugin, which converts a PDF document into an XPS document. // -// For more detail see the description of the XPStoPDF sample program on our Developer’s site, +// For more detail see the description of the XPStoPDF sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#xpstopdf #include "InitializeLibrary.h" @@ -19,90 +19,88 @@ #define DEF_INPUT "XPStoPDF.xps" #define DEF_OUTPUT "XPStoPDF-out.pdf" -int main(int argc, char** argv) -{ - APDFLib lib; //Initialize the Adobe PDF Library. - ASErrorCode errCode = 0; //Variable used to report any exceptions/errors if they occured. +int main(int argc, char **argv) { + APDFLib lib; // Initialize the Adobe PDF Library. + ASErrorCode errCode = 0; // Variable used to report any exceptions/errors if they occured. - if (lib.isValid() == false) //If there was a problem in initialization, return the error code. + if (lib.isValid() == false) // If there was a problem in initialization, return the error code. return lib.getInitError(); DURING -//========================================================================================================================= -// 1) Load and configure settings for the plugin. -//========================================================================================================================= + //========================================================================================================================= + // 1) Load and configure settings for the plugin. + //========================================================================================================================= - gXPS2PDFHFT = InitXPS2PDFHFT; //Sets the function called by XPS2PDFInitialize(). + gXPS2PDFHFT = InitXPS2PDFHFT; // Sets the function called by XPS2PDFInitialize(). - //Load the XPS2PDF plugin. - if (!XPS2PDFInitialize()) { - std::wcout << L"XPS2PDF Could not initialize:" << std::endl; - ASRaise(ERRORCODE); //The handler will display the error code. - } + // Load the XPS2PDF plugin. + if (!XPS2PDFInitialize()) { + std::wcout << L"XPS2PDF Could not initialize:" << std::endl; + ASRaise(ERRORCODE); // The handler will display the error code. + } - std::string csInputFileName(argc > 1 ? argv[1] : DIR_LOC DEF_INPUT); - std::string csOutputFileName(argc > 2 ? argv[2] : DEF_OUTPUT); + std::string csInputFileName(argc > 1 ? argv[1] : DIR_LOC DEF_INPUT); + std::string csOutputFileName(argc > 2 ? argv[2] : DEF_OUTPUT); - std::cout << "Converting input file " << csInputFileName.c_str() - << " and saving as " << csOutputFileName.c_str() << std::endl; + std::cout << "Converting input file " << csInputFileName.c_str() << " and saving as " + << csOutputFileName.c_str() << std::endl; - ASCab settings = ASCabNew(); + ASCab settings = ASCabNew(); - //The .joboptions file specifies a great number of settings which determine exactly how the PDF document - //is created by the converter. - ASText jobNameText = ASTextFromUnicode((ASUTF16Val*)"../../../../Resources/joboptions/Standard.joboptions", kUTF8); - ASCabPutText(settings, "PDFSettings", jobNameText); + // The .joboptions file specifies a great number of settings which determine exactly how the + // PDF document is created by the converter. + ASText jobNameText = + ASTextFromUnicode((ASUTF16Val *)"../../../../Resources/joboptions/Standard.joboptions", kUTF8); + ASCabPutText(settings, "PDFSettings", jobNameText); - //Specify which description in the .joboptions file we will use. - //There are many others, for different langauges. See the file. - ASText language = ASTextFromUnicode((ASUTF16Val*)"ENU", kUTF8); - ASCabPutText(settings, "PDFSettingsLang", language); + // Specify which description in the .joboptions file we will use. + // There are many others, for different langauges. See the file. + ASText language = ASTextFromUnicode((ASUTF16Val *)"ENU", kUTF8); + ASCabPutText(settings, "PDFSettingsLang", language); -//========================================================================================================================= -// 2) Convert the input XPS document. -//========================================================================================================================= + //========================================================================================================================= + // 2) Convert the input XPS document. + //========================================================================================================================= - //The path of the input XPS. - ASPathName asInPathName = ASFileSysCreatePathName(NULL, ASAtomFromString("Cstring"), csInputFileName.c_str(), 0); + // The path of the input XPS. + ASPathName asInPathName = + ASFileSysCreatePathName(NULL, ASAtomFromString("Cstring"), csInputFileName.c_str(), 0); - //We supply an empty PDDoc to convert the XPS into. - PDDoc outputDoc = NULL; - int ret_val = XPS2PDFConvert(settings,0,asInPathName,NULL,&outputDoc,NULL); + // We supply an empty PDDoc to convert the XPS into. + PDDoc outputDoc = NULL; + int ret_val = XPS2PDFConvert(settings, 0, asInPathName, NULL, &outputDoc, NULL); - //If we succeeded, XPS2PDFConvert returns 1. - if (ret_val != 1) - { - std::wcout << L"Conversion failed." << std::endl; - } - else - { -//========================================================================================================================= -// 3) Save the new PDF document and release resources. -//========================================================================================================================= + // If we succeeded, XPS2PDFConvert returns 1. + if (ret_val != 1) { + std::wcout << L"Conversion failed." << std::endl; + } else { + //========================================================================================================================= + // 3) Save the new PDF document and release resources. + //========================================================================================================================= - //We construct an APDFLDoc object for this PDF to ease saving it. - APDFLDoc outAPDoc; - outAPDoc.pdDoc = outputDoc; - outAPDoc.saveDoc(csOutputFileName.c_str()); + // We construct an APDFLDoc object for this PDF to ease saving it. + APDFLDoc outAPDoc; + outAPDoc.pdDoc = outputDoc; + outAPDoc.saveDoc(csOutputFileName.c_str()); - //Release the other resources we created. - //(APDFLDoc's destructor takes care of closing the document and releasing the rest of its resources.) - ASCabDestroy(settings); - ASFileSysReleasePath(NULL, asInPathName); + // Release the other resources we created. + //(APDFLDoc's destructor takes care of closing the document and releasing the rest of its resources.) + ASCabDestroy(settings); + ASFileSysReleasePath(NULL, asInPathName); - std::wcout << L"Successfully converted the document." << std::endl; - } + std::wcout << L"Successfully converted the document." << std::endl; + } - //Close the plugin. - XPS2PDFTerminate(); + // Close the plugin. + XPS2PDFTerminate(); HANDLER errCode = ERRORCODE; - lib.displayError(errCode); //If there was an error, display it. + lib.displayError(errCode); // If there was an error, display it. END_HANDLER - return errCode; //APDFLib's destructor terminates the library. + return errCode; // APDFLib's destructor terminates the library. } \ No newline at end of file diff --git a/CPlusPlus/Sample_Source/FileSystem/AlternateFileSystem/AlternateFileSystem.cpp b/CPlusPlus/Sample_Source/FileSystem/AlternateFileSystem/AlternateFileSystem.cpp index 74222cea..e980bfef 100644 --- a/CPlusPlus/Sample_Source/FileSystem/AlternateFileSystem/AlternateFileSystem.cpp +++ b/CPlusPlus/Sample_Source/FileSystem/AlternateFileSystem/AlternateFileSystem.cpp @@ -305,7 +305,6 @@ ASMDFile altFSReopen(ASMDFile f, ASFileMode newMode, ASErrorCode *error) { if (!f) { - *error - 1; return f; } diff --git a/CPlusPlus/Sample_Source/FileSystem/AlternateFileSystem/AlternateFileSystemTest.cpp b/CPlusPlus/Sample_Source/FileSystem/AlternateFileSystem/AlternateFileSystemTest.cpp index c95556b7..74f690fd 100644 --- a/CPlusPlus/Sample_Source/FileSystem/AlternateFileSystem/AlternateFileSystemTest.cpp +++ b/CPlusPlus/Sample_Source/FileSystem/AlternateFileSystem/AlternateFileSystemTest.cpp @@ -1,6 +1,6 @@ // // Copyright (c) 2004-2017, Datalogics, Inc. All rights reserved. -// +// // For complete copyright information, see: // http://dev.datalogics.com/adobe-pdf-library/adobe-pdf-library-c-language-interface/license-for-downloaded-pdf-samples/ // @@ -16,7 +16,7 @@ // #ifdef WIN32 -#pragma warning(disable:4267) +#pragma warning(disable : 4267) #endif #include @@ -41,19 +41,18 @@ // In AlternateFileSystem.cpp extern ASFileSys altFileSys(); -int main ( int argc, char* argv[] ) -{ - APDFLib libInit; // Initialize the Adobe PDF Library. Termination will be automatic when scope is lost +int main(int argc, char *argv[]) { + APDFLib libInit; // Initialize the Adobe PDF Library. Termination will be automatic when scope is lost - if (libInit.isValid() == false) // Check for errors upon initialization. + if (libInit.isValid() == false) // Check for errors upon initialization. { int errCode = libInit.getInitError(); - APDFLib::displayError ( errCode ); + APDFLib::displayError(errCode); return errCode; } - - std::string csInputFile ( argc > 1 ? argv[1] : INPUT_DIR INPUT_FILE ); - std::string csOutputFile ( argc > 2 ? argv[2] : OUTPUT_FILE ); + + std::string csInputFile(argc > 1 ? argv[1] : INPUT_DIR INPUT_FILE); + std::string csOutputFile(argc > 2 ? argv[2] : OUTPUT_FILE); std::cout << "Processing input file " << csInputFile.c_str() << std::endl; std::cout << "Will write to output file " << csOutputFile.c_str() << std::endl; @@ -62,112 +61,118 @@ int main ( int argc, char* argv[] ) ASPathName asPathName = NULL; // Open a PDF file via the alternate file system and get a PDDoc from it -DURING - // Create asPathName with an Alternate FileSystem. - asPathName = ASFileSysCreatePathName(asFileSys, ASAtomFromString("Cstring"), csInputFile.c_str(), 0); - - // Open pdDocIn from asPathName. - pdDocIn = PDDocOpen(asPathName, asFileSys, NULL, true); - ASFileSysReleasePath(asFileSys, asPathName); -HANDLER - APDFLib::displayError(ERRORCODE); - std::cout << "Couldn't open alternate input file " << csInputFile.c_str() << std::endl; - return ERRORCODE; -END_HANDLER - - // Create Doc, Page, Content Container - PDDoc pdDoc; // reference to a PDF document - PDPage pdPage; // reference to a page in doc - PDEContent pdeContent; // container for page content - ASFixedRect mediaBox; // dimensions of page - PDEFont pdeFont; // reference to a font used on a page - PDEFontAttrs pdeFontAttrs; // font attributes - PDEText pdeText; // container for text - ASFixedMatrix textMatrix; // transformation matrix for text - PDEColorSpace pdeColorSpace; // ColorSpace - PDEGraphicState gState; // graphic state to apply to operation + DURING + // Create asPathName with an Alternate FileSystem. + asPathName = + ASFileSysCreatePathName(asFileSys, ASAtomFromString( +#if MAC_ENV + "POSIXPath" +#else + "Cstring" +#endif + ), csInputFile.c_str(), 0); + + // Open pdDocIn from asPathName. + pdDocIn = PDDocOpen(asPathName, asFileSys, NULL, true); + ASFileSysReleasePath(asFileSys, asPathName); + HANDLER + APDFLib::displayError(ERRORCODE); + std::cout << "Couldn't open alternate input file " << csInputFile.c_str() << std::endl; + return ERRORCODE; + END_HANDLER + + // Create Doc, Page, Content Container + PDDoc pdDoc; // reference to a PDF document + PDPage pdPage; // reference to a page in doc + PDEContent pdeContent; // container for page content + ASFixedRect mediaBox; // dimensions of page + PDEFont pdeFont; // reference to a font used on a page + PDEFontAttrs pdeFontAttrs; // font attributes + PDEText pdeText; // container for text + ASFixedMatrix textMatrix; // transformation matrix for text + PDEColorSpace pdeColorSpace; // ColorSpace + PDEGraphicState gState; // graphic state to apply to operation const char *HelloWorldStr = "Hello AltFSTest!"; -DURING - - pdDoc = PDDocCreate(); // create new document - - mediaBox.left = fixedZero; // dimensions of page - mediaBox.top = Int16ToFixed(4*72); // in this case 5" x 4" - mediaBox.right = Int16ToFixed(5*72); - mediaBox.bottom = fixedZero; - - // Create page with those dimensions and insert as first page - pdPage = PDDocCreatePage(pdDoc, PDBeforeFirstPage, mediaBox); - - // Acquire PDEContent container for page - pdeContent = PDPageAcquirePDEContent(pdPage, NULL); - - // Acquire font, add text, insert into page content container - memset(&pdeFontAttrs, 0, sizeof(pdeFontAttrs)); - pdeFontAttrs.name = ASAtomFromString("Times-Roman"); // font name - pdeFontAttrs.type = ASAtomFromString("Type1"); // font type - - pdeFont = PDEFontCreate(&pdeFontAttrs, sizeof(pdeFontAttrs), - 0, 255, 0, // Widths - 0, ASAtomNull, // Encoding - 0, 0, 0, 0); // Font embedding - - // The following code sets up the default Graphics state. We do this so that - // we can free the PDEColorSpace objects - pdeColorSpace = PDEColorSpaceCreateFromName(ASAtomFromString("DeviceGray")); - memset(&gState, 0, sizeof(PDEGraphicState)); - gState.strokeColorSpec.space = gState.fillColorSpec.space = pdeColorSpace; - gState.miterLimit = fixedTen; - gState.flatness = fixedOne; - gState.lineWidth = fixedOne; - - memset(&textMatrix, 0, sizeof(textMatrix)); // clear structure - textMatrix.a = Int16ToFixed(24); // set font width and height - textMatrix.d = Int16ToFixed(24); // to 24 point size - textMatrix.h = Int16ToFixed(1*72); // x,y coordinate on page - textMatrix.v = Int16ToFixed(2*72); // in this case, 1" x 2" - pdeText = PDETextCreate(); // create new text run - PDETextAdd(pdeText, // text container to add to - kPDETextRun, // kPDETextRun, kPDETextChar - 0, // index - (ASUns8 *)HelloWorldStr, // text to add - strlen(HelloWorldStr), // length of text - pdeFont, // font to apply to text - &gState, sizeof(gState), // graphic state to apply to text - NULL, 0, // text state and size of structure - &textMatrix, // transformation matrix for text - NULL); // stroke matrix - - // insert text into page content - PDEContentAddElem(pdeContent, kPDEAfterLast, (PDEElement) pdeText); - - // Convert To Objects, Add To Page, Release Resources - // Set the PDEContent for the page - PDPageSetPDEContent(pdPage, NULL); - - // Insert pages from the opened doc to the created pdDoc - PDDocInsertPages (pdDoc,PDLastPage,pdDocIn, 0, PDAllPages,PDInsertAll, NULL,NULL,NULL,NULL); - - ASPathName Path = APDFLDoc::makePath(csOutputFile.c_str()); - PDDocSave(pdDoc, PDSaveFull, Path, NULL, NULL, NULL); - ASFileSysReleasePath ( NULL, Path ); - - // remember to release all objects that were created - PDERelease((PDEObject) pdeFont); - PDERelease((PDEObject) pdeText); - PDPageReleasePDEContent(pdPage, NULL); - PDERelease((PDEObject)pdeColorSpace); - PDPageRelease(pdPage); - PDDocRelease(pdDoc); - - PDDocClose(pdDocIn); - PDDocRelease(pdDocIn); - -HANDLER - APDFLib::displayError(ERRORCODE); - return ERRORCODE; -END_HANDLER + DURING + + pdDoc = PDDocCreate(); // create new document + + mediaBox.left = fixedZero; // dimensions of page + mediaBox.top = Int16ToFixed(4 * 72); // in this case 5" x 4" + mediaBox.right = Int16ToFixed(5 * 72); + mediaBox.bottom = fixedZero; + + // Create page with those dimensions and insert as first page + pdPage = PDDocCreatePage(pdDoc, PDBeforeFirstPage, mediaBox); + + // Acquire PDEContent container for page + pdeContent = PDPageAcquirePDEContent(pdPage, NULL); + + // Acquire font, add text, insert into page content container + memset(&pdeFontAttrs, 0, sizeof(pdeFontAttrs)); + pdeFontAttrs.name = ASAtomFromString("Times-Roman"); // font name + pdeFontAttrs.type = ASAtomFromString("Type1"); // font type + + pdeFont = PDEFontCreate(&pdeFontAttrs, sizeof(pdeFontAttrs), 0, 255, 0, // Widths + 0, ASAtomNull, // Encoding + 0, 0, 0, 0); // Font embedding + + // The following code sets up the default Graphics state. We do this so that + // we can free the PDEColorSpace objects + pdeColorSpace = PDEColorSpaceCreateFromName(ASAtomFromString("DeviceGray")); + memset(&gState, 0, sizeof(PDEGraphicState)); + gState.strokeColorSpec.space = gState.fillColorSpec.space = pdeColorSpace; + gState.miterLimit = fixedTen; + gState.flatness = fixedOne; + gState.lineWidth = fixedOne; + + memset(&textMatrix, 0, sizeof(textMatrix)); // clear structure + textMatrix.a = Int16ToFixed(24); // set font width and height + textMatrix.d = Int16ToFixed(24); // to 24 point size + textMatrix.h = Int16ToFixed(1 * 72); // x,y coordinate on page + textMatrix.v = Int16ToFixed(2 * 72); // in this case, 1" x 2" + pdeText = PDETextCreate(); // create new text run + PDETextAdd(pdeText, // text container to add to + kPDETextRun, // kPDETextRun, kPDETextChar + 0, // index + (ASUns8 *)HelloWorldStr, // text to add + strlen(HelloWorldStr), // length of text + pdeFont, // font to apply to text + &gState, sizeof(gState), // graphic state to apply to text + NULL, 0, // text state and size of structure + &textMatrix, // transformation matrix for text + NULL); // stroke matrix + + // insert text into page content + PDEContentAddElem(pdeContent, kPDEAfterLast, (PDEElement)pdeText); + + // Convert To Objects, Add To Page, Release Resources + // Set the PDEContent for the page + PDPageSetPDEContent(pdPage, NULL); + + // Insert pages from the opened doc to the created pdDoc + PDDocInsertPages(pdDoc, PDLastPage, pdDocIn, 0, PDAllPages, PDInsertAll, NULL, NULL, NULL, NULL); + + ASPathName Path = APDFLDoc::makePath(csOutputFile.c_str()); + PDDocSave(pdDoc, PDSaveFull, Path, NULL, NULL, NULL); + ASFileSysReleasePath(NULL, Path); + + // remember to release all objects that were created + PDERelease((PDEObject)pdeFont); + PDERelease((PDEObject)pdeText); + PDPageReleasePDEContent(pdPage, NULL); + PDERelease((PDEObject)pdeColorSpace); + PDPageRelease(pdPage); + PDDocRelease(pdDoc); + + PDDocClose(pdDocIn); + PDDocRelease(pdDocIn); + + HANDLER + APDFLib::displayError(ERRORCODE); + return ERRORCODE; + END_HANDLER return 0; } diff --git a/CPlusPlus/Sample_Source/Images/AddThumbnailsToPDF/AddThumbnailsToPDF.cpp b/CPlusPlus/Sample_Source/Images/AddThumbnailsToPDF/AddThumbnailsToPDF.cpp index 0d5e70fb..1f4a0806 100644 --- a/CPlusPlus/Sample_Source/Images/AddThumbnailsToPDF/AddThumbnailsToPDF.cpp +++ b/CPlusPlus/Sample_Source/Images/AddThumbnailsToPDF/AddThumbnailsToPDF.cpp @@ -8,7 +8,7 @@ // Thumbnails appear in a panel on the left side of the Adobe Acrobat window and // aid in navigating through a document, as a user can scroll through a series of // thumbnails quickly to find a page. This sample program demonstrates how to create -// thumbnails for a PDF document, one for each page. The program saves the thumbnail +// thumbnails for a PDF document, one for each page. The program saves the thumbnail // images in a PDF output file, using an indexed color table with 256 colors RGB. // // For more detail see the description of the AddThumbnailsToPDF sample program on our Developer’s site, @@ -20,57 +20,48 @@ #include "APDFLDoc.h" #define INPUT_DIR "../../../../Resources/Sample_Input/" -#define INPUT_FILE "AddThumbnailsToPDF-in.pdf" -#define OUTPUT_FILE "AddThumbnailsToPDF-out.pdf" +#define INPUT_FILE "AddThumbnailsToPDF-in.pdf" +#define OUTPUT_FILE "AddThumbnailsToPDF-out.pdf" static void MakeColorTable(ASUns8 *lookupTable); -static ASBool MycancelProc (void* clientData); +static ASBool MycancelProc(void *clientData); -int main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { // Initialize the Adobe PDF Library. Termination will be automatic when scope is lost. APDFLib libInit; - if (libInit.isValid() == false) - { + if (libInit.isValid() == false) { ASErrorCode errCode = libInit.getInitError(); - APDFLib::displayError ( errCode ); + APDFLib::displayError(errCode); return errCode; } std::string csInputFile(argc > 1 ? argv[1] : INPUT_DIR INPUT_FILE); std::string csOutputFile(argc > 2 ? argv[2] : OUTPUT_FILE); - std::cout << "Placing thumbnails into " << csInputFile.c_str() << ", writing to " << csOutputFile.c_str() << std::endl; - -DURING - - // Open the input document - APDFLDoc apdflDoc ( csInputFile.c_str(), true ); - PDDoc pdDoc = apdflDoc.getPDDoc(); - - // Prepare the color lookup table - ASUns8 lookupTable[768]; // Enough space for 256 colors (with three color components) - MakeColorTable(lookupTable); - - // Create thumbnails - PDDocCreateThumbs (pdDoc, - 0, - PDLastPage, - NULL, NULL, - ASAtomFromString ("DeviceRGB"), - 8, 255, - (char*) lookupTable, - NULL, NULL, - MycancelProc, - NULL); - - // Save the output document - apdflDoc.saveDoc ( csOutputFile.c_str() ); - -HANDLER - APDFLib::displayError(ERRORCODE); - return ERRORCODE; -END_HANDLER + std::cout << "Placing thumbnails into " << csInputFile.c_str() << ", writing to " + << csOutputFile.c_str() << std::endl; + + DURING + + // Open the input document + APDFLDoc apdflDoc(csInputFile.c_str(), true); + PDDoc pdDoc = apdflDoc.getPDDoc(); + + // Prepare the color lookup table + ASUns8 lookupTable[768]; // Enough space for 256 colors (with three color components) + MakeColorTable(lookupTable); + + // Create thumbnails + PDDocCreateThumbs(pdDoc, 0, PDLastPage, NULL, NULL, ASAtomFromString("DeviceRGB"), 8, 255, + (char *)lookupTable, NULL, NULL, MycancelProc, NULL); + + // Save the output document + apdflDoc.saveDoc(csOutputFile.c_str()); + + HANDLER + APDFLib::displayError(ERRORCODE); + return ERRORCODE; + END_HANDLER return 0; } @@ -80,22 +71,18 @@ END_HANDLER // 256 colors times three (RGB). Anything in the array will // be overwritten. // -void MakeColorTable(ASUns8 *p) -{ +void MakeColorTable(ASUns8 *p) { ASUns8 red, green, blue; int redCount, greenCount, blueCount; int i; // Populate a 6x6x6 entry RGB cube red = 0; - for ( redCount = 7; --redCount; ) - { + for (redCount = 7; --redCount;) { green = 0; - for ( greenCount = 7; --greenCount; ) - { + for (greenCount = 7; --greenCount;) { blue = 0; - for ( blueCount = 7; --blueCount; ) - { + for (blueCount = 7; --blueCount;) { *p++ = red; *p++ = green; *p++ = blue; @@ -108,11 +95,9 @@ void MakeColorTable(ASUns8 *p) /* Add 10 additional grays */ red = 0; - for ( redCount = 0; redCount < 10; redCount++) - { + for (redCount = 0; redCount < 10; redCount++) { // Skip this one because it's already in the 6x6x6 cube - if ( (redCount & 1) == 0 ) - { + if ((redCount & 1) == 0) { red += 0x11; } *p++ = red; @@ -122,8 +107,7 @@ void MakeColorTable(ASUns8 *p) } // Fill the rest of the table with white - for (i = 226; i < 256; i++) - { + for (i = 226; i < 256; i++) { *p++ = 255; *p++ = 255; *p++ = 255; @@ -133,11 +117,8 @@ void MakeColorTable(ASUns8 *p) // // Call-back to provide some feedback to the user as we process // -ASBool MycancelProc (void* clientData) -{ +ASBool MycancelProc(void *clientData) { std::cout << '.'; std::cout.flush(); return false; } - - diff --git a/CPlusPlus/Sample_Source/Images/CalcImageDPI/CalcImageDPI.cpp b/CPlusPlus/Sample_Source/Images/CalcImageDPI/CalcImageDPI.cpp index 26e777c1..ec0db659 100644 --- a/CPlusPlus/Sample_Source/Images/CalcImageDPI/CalcImageDPI.cpp +++ b/CPlusPlus/Sample_Source/Images/CalcImageDPI/CalcImageDPI.cpp @@ -9,7 +9,7 @@ // rotating them as needed before calculating the Dots per Inch (DPI) for each image. Then, it // lists the results in an output text file. // -// For more detail see the description of the CalcImageDPI sample program on our Developer’s site, +// For more detail see the description of the CalcImageDPI sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#calcimagedpi #include @@ -39,16 +39,14 @@ #define M_PI 3.14159265358979323846 #endif -#define degrees_to_radians (M_PI / 180.0) +#define degrees_to_radians (M_PI / 180.0) #include "CalcImageDPI.h" -int main(int argc, char **argv) -{ +int main(int argc, char **argv) { // Initialize the library APDFLib libInit; - if (libInit.isValid() == false) - { + if (libInit.isValid() == false) { ASErrorCode errCode = libInit.getInitError(); std::cout << "APDFL Library initialization failed with code " << errCode << std::endl; return errCode; @@ -58,69 +56,66 @@ int main(int argc, char **argv) std::string csInputFile(argc > 1 ? argv[1] : INPUT_DIR INPUT_FILE); std::string csOutputFile(argc > 2 ? argv[2] : OUTPUT_FILE); - std::ofstream ofs ( csOutputFile.c_str() ); - if ( !ofs.is_open() ) - { + std::ofstream ofs(csOutputFile.c_str()); + if (!ofs.is_open()) { std::cout << "Unable to open output file " << csOutputFile.c_str() << std::endl; return -6; } ofs << "CalcImageDPI: Results for file " << csInputFile.c_str() << std::endl; - std::cout << "Analyzing file " << csInputFile.c_str() << ", writing results to " << csOutputFile.c_str() << std::endl; + std::cout << "Analyzing file " << csInputFile.c_str() << ", writing results to " + << csOutputFile.c_str() << std::endl; std::vector ImageTable; -DURING + DURING // Open input file - APDFLDoc apdflDoc ( csInputFile.c_str(), true ); + APDFLDoc apdflDoc(csInputFile.c_str(), true); PDDoc doc = apdflDoc.getPDDoc(); // Process each page - ASInt32 pages = PDDocGetNumPages (doc); - for (ASInt32 pageNumb = 0; pageNumb < pages; pageNumb++) - { - PDPage page = PDDocAcquirePage (doc, pageNumb); - PDEContent content = PDPageAcquirePDEContent (page, 0); - - // Get the page's matrix. If we use unity, then we will have to "un rotate" all the upright - // images in a rotated page (which we will do just fine). If we use the upright matrix, - // they they wil be unrotated automatically. Either works. + ASInt32 pages = PDDocGetNumPages(doc); + for (ASInt32 pageNumb = 0; pageNumb < pages; pageNumb++) { + PDPage page = PDDocAcquirePage(doc, pageNumb); + PDEContent content = PDPageAcquirePDEContent(page, 0); + + // Get the page's matrix. If we use unity, then we will have to "un rotate" all the + // upright images in a rotated page (which we will do just fine). If we use the upright + // matrix, they they wil be unrotated automatically. Either works. ASFixedMatrix UprightImage = {fixedOne, 0, 0, fixedOne, 0, 0}; - PDPageGetDefaultMatrix (page, &UprightImage); + PDPageGetDefaultMatrix(page, &UprightImage); - // Fetch the user-assigned scale factor. It may be anything, but is usually used to - // make the "1 unit in user space" larger then 1/72nd of an inch. Doing this allows the - // ASFixedMatrix to describe a larger page. - // But regardless of how or why this is used, it enters into the DPI calaculation by moving the + // Fetch the user-assigned scale factor. It may be anything, but is usually used to + // make the "1 unit in user space" larger then 1/72nd of an inch. Doing this allows the + // ASFixedMatrix to describe a larger page. + // But regardless of how or why this is used, it enters into the DPI calaculation by moving the // default unit size away from 1/72nd of an inch, so we must track it to find DPI. double userUnit = PDPageGetUserUnitSize(page); // Now, walk the content of the page, starting with this matrix and user unit ASInt16 sequence = 1; - WalkContent (content, &UprightImage, userUnit, pageNumb+1, &sequence, ImageTable); + WalkContent(content, &UprightImage, userUnit, pageNumb + 1, &sequence, ImageTable); - PDPageReleasePDEContent (page, 0); - PDPageRelease (page); + PDPageReleasePDEContent(page, 0); + PDPageRelease(page); } // Report out the results - size_t numEntries ( ImageTable.size() ); + size_t numEntries(ImageTable.size()); ofs << "We found " << numEntries << " images" << std::endl; - for (size_t index = 0; index < numEntries; index++) - { + for (size_t index = 0; index < numEntries; index++) { ofs << ImageTable[index]; } -HANDLER - APDFLib::displayError(ERRORCODE); - return ERRORCODE; -END_HANDLER + HANDLER + APDFLib::displayError(ERRORCODE); + return ERRORCODE; + END_HANDLER return (0); } // Rotate a matrix by a given amount -void ASFixedMatrixRotate (ASFixedMatrix *M, double Angle) -{ +void ASFixedMatrixRotate(ASFixedMatrix *M, double Angle) { double Sina, Cosa; double Ma, Mb, Mc, Md; @@ -134,37 +129,34 @@ void ASFixedMatrixRotate (ASFixedMatrix *M, double Angle) return; Angle *= degrees_to_radians; - Ma = ASFixedToFloat (M->a); - Mb = ASFixedToFloat (M->b); - Mc = ASFixedToFloat (M->c); - Md = ASFixedToFloat (M->d); - Sina = sin (Angle); - Cosa= cos (Angle); - - M->a = FloatToASFixed ((Cosa * Ma) + (Sina * Mc)); - M->b = FloatToASFixed ((Cosa * Mb) + (Sina * Md)); - M->c = FloatToASFixed ((Cosa * Mc) - (Sina * Ma)); - M->d = FloatToASFixed ((Cosa * Md) - (Sina * Mb)); + Ma = ASFixedToFloat(M->a); + Mb = ASFixedToFloat(M->b); + Mc = ASFixedToFloat(M->c); + Md = ASFixedToFloat(M->d); + Sina = sin(Angle); + Cosa = cos(Angle); + + M->a = FloatToASFixed((Cosa * Ma) + (Sina * Mc)); + M->b = FloatToASFixed((Cosa * Mb) + (Sina * Md)); + M->c = FloatToASFixed((Cosa * Mc) - (Sina * Ma)); + M->d = FloatToASFixed((Cosa * Md) - (Sina * Mb)); return; } - // Scale a natrix by a given amount -void ASFixedMatrixScale (ASFixedMatrix *M, double ScaleX, double ScaleY) -{ - M->a = FloatToASFixed(ASFixedToFloat (M->a) * ScaleX); - M->b = FloatToASFixed(ASFixedToFloat (M->b) * ScaleX); - M->c = FloatToASFixed(ASFixedToFloat (M->c) * ScaleY); - M->d = FloatToASFixed(ASFixedToFloat (M->d) * ScaleY); +void ASFixedMatrixScale(ASFixedMatrix *M, double ScaleX, double ScaleY) { + M->a = FloatToASFixed(ASFixedToFloat(M->a) * ScaleX); + M->b = FloatToASFixed(ASFixedToFloat(M->b) * ScaleX); + M->c = FloatToASFixed(ASFixedToFloat(M->c) * ScaleY); + M->d = FloatToASFixed(ASFixedToFloat(M->d) * ScaleY); } // A simple utility routine to assure that angle is within // 0 to 359 degrees, and has no more then 2 decimal places of precision // This makes comparing angles simpler -double NormalizeRotation (double Angle) -{ +double NormalizeRotation(double Angle) { Angle = floor((Angle * 100) + 0.5) / 100; while (Angle >= 360) Angle -= 360; @@ -174,45 +166,45 @@ double NormalizeRotation (double Angle) } // Calculate the DPI for the image -void FindImageDPI (PDEImage image,ASFixedMatrix *matrix, double userScale, ASInt16 pageNumb, ASInt16 sequence, std::vector& imageTable) -{ +void FindImageDPI(PDEImage image, ASFixedMatrix *matrix, double userScale, ASInt16 pageNumb, + ASInt16 sequence, std::vector &imageTable) { // Select an output area ImageEntry idata; - // Identify the image + // Identify the image idata.pageNumb = pageNumb; idata.imageNumb = sequence; // Save the current Matrix - memmove ((char *)&idata.currentMatrix, (char *)matrix, sizeof (ASFixedMatrix)); + memmove((char *)&idata.currentMatrix, (char *)matrix, sizeof(ASFixedMatrix)); // Save the elements matrix - PDEElementGetMatrix ((PDEElement)image, &idata.elementMatrix); + PDEElementGetMatrix((PDEElement)image, &idata.elementMatrix); - // Find the final matrix used to set the image, as the matrix currently in effect + // Find the final matrix used to set the image, as the matrix currently in effect // was concatenated to the matrix used to set the image - ASFixedMatrixConcat (&idata.finalMatrix, &idata.elementMatrix, &idata.currentMatrix); - + ASFixedMatrixConcat(&idata.finalMatrix, &idata.elementMatrix, &idata.currentMatrix); - // Find the angle between the current matrix, and erect, horizontally and vertically - // ArcTangent of the vertical over horizontal components of the movement yields angle in radians, and can convert + // Find the angle between the current matrix, and erect, horizontally and vertically + // ArcTangent of the vertical over horizontal components of the movement yields angle in radians, and can convert // easily to degrees. The horizontal movement components are b and d, where d is the vertical and b the horizontal. // See section 8.8.4 of the ISO 32000-1:2008, Document Management-Portable Document Format-Part 1:PDF 1.7, - // "Transformation Matrices," page 119. + // "Transformation Matrices," page 119. // // So Arctangent b/a is the basis of the angle of a row in the image data - idata.hRotation = atan2 (ASFixedToFloat (idata.finalMatrix.b), ASFixedToFloat (idata.finalMatrix.a)) / degrees_to_radians; + idata.hRotation = atan2(ASFixedToFloat(idata.finalMatrix.b), ASFixedToFloat(idata.finalMatrix.a)) / degrees_to_radians; - // Then we do the same thing, for the vertical movement (columns) + // Then we do the same thing, for the vertical movement (columns) // Normally, we would expect to get an angle of 90 degrees to the horizontal angle. However, because some images are scanned - // top to bottom, and PDF expects data to be bottom to top, we see an angle of -90 degrees between the two. If we make the same + // top to bottom, and PDF expects data to be bottom to top, we see an angle of -90 degrees between the two. If we make the same // calculations, then we should rotate such that we will have a positive movement in both planes, regardless of skew or mirroring. - idata.vRotation = atan2 (ASFixedToFloat (idata.finalMatrix.d), ASFixedToFloat (idata.finalMatrix.c)) / degrees_to_radians - 90; + idata.vRotation = + atan2(ASFixedToFloat(idata.finalMatrix.d), ASFixedToFloat(idata.finalMatrix.c)) / degrees_to_radians - 90; - // If the two angles are not the same, then we have a shear applied to one or the other of the + // If the two angles are not the same, then we have a shear applied to one or the other of the // components (or both). To find that shear, we need to de-rotate - memmove ((char *)&idata.erectHMatrix, (char *)&idata.finalMatrix, sizeof (ASFixedMatrix)); - memmove ((char *)&idata.erectVMatrix, (char *)&idata.finalMatrix, sizeof (ASFixedMatrix)); + memmove((char *)&idata.erectHMatrix, (char *)&idata.finalMatrix, sizeof(ASFixedMatrix)); + memmove((char *)&idata.erectVMatrix, (char *)&idata.finalMatrix, sizeof(ASFixedMatrix)); idata.sheared = false; idata.xShear = idata.yShear = 0; @@ -221,74 +213,76 @@ void FindImageDPI (PDEImage image,ASFixedMatrix *matrix, double userScale, ASInt // record it,and remove it. // // Complete the test with a set of angles normalized to be between 0 and 359, and - // round the result to no more than two decimal points. This is enough precision, and + // round the result to no more than two decimal points. This is enough precision, and // it avoids trying to make skew calculations with numbers showing very long floating // point decimal ranges. But preserve the real values for conversion. // // If the user has sheared in both planes, and rotated the image, the process to calculate - // the skew value will fail. - double testX = NormalizeRotation (idata.hRotation); - double testY = NormalizeRotation (idata.vRotation); - if ( (testX != testY) && (fabs (testX - testY) != 180) ) - { + // the skew value will fail. + double testX = NormalizeRotation(idata.hRotation); + double testY = NormalizeRotation(idata.vRotation); + if ((testX != testY) && (fabs(testX - testY) != 180)) { idata.sheared = true; - ASFixedMatrixRotate (&idata.erectHMatrix, idata.hRotation); - if (idata.erectHMatrix.b != 0) - { + ASFixedMatrixRotate(&idata.erectHMatrix, idata.hRotation); + if (idata.erectHMatrix.b != 0) { // We are sheared horizontally - idata.xShear = -(atan2 (ASFixedToFloat (idata.finalMatrix.d), ASFixedToFloat (idata.finalMatrix.b)) / degrees_to_radians) + 90; - memmove ((char *)&idata.erectHMatrix, (char *)&idata.finalMatrix, sizeof (ASFixedMatrix)); - ASFixedMatrixRotate (&idata.erectHMatrix, -idata.xShear); + idata.xShear = + -(atan2(ASFixedToFloat(idata.finalMatrix.d), ASFixedToFloat(idata.finalMatrix.b)) / degrees_to_radians) + + 90; + memmove((char *)&idata.erectHMatrix, (char *)&idata.finalMatrix, sizeof(ASFixedMatrix)); + ASFixedMatrixRotate(&idata.erectHMatrix, -idata.xShear); idata.finalMatrix.b = idata.erectHMatrix.b; idata.xShear = floor((idata.xShear * 100) + 0.5) / 100; - idata.hRotation = atan2 (ASFixedToFloat (idata.finalMatrix.b), ASFixedToFloat (idata.finalMatrix.a)) / degrees_to_radians; + idata.hRotation = + atan2(ASFixedToFloat(idata.finalMatrix.b), ASFixedToFloat(idata.finalMatrix.a)) / degrees_to_radians; } - ASFixedMatrixRotate (&idata.erectVMatrix, -idata.vRotation); - if (idata.erectVMatrix.c != 0) - { - idata.yShear = atan2 (ASFixedToFloat (idata.finalMatrix.c), ASFixedToFloat (idata.finalMatrix.a)) / degrees_to_radians; + ASFixedMatrixRotate(&idata.erectVMatrix, -idata.vRotation); + if (idata.erectVMatrix.c != 0) { + idata.yShear = + atan2(ASFixedToFloat(idata.finalMatrix.c), ASFixedToFloat(idata.finalMatrix.a)) / degrees_to_radians; - memmove ((char *)&idata.erectVMatrix, (char *)&idata.finalMatrix, sizeof (ASFixedMatrix)); - ASFixedMatrixRotate (&idata.erectVMatrix, idata.yShear); + memmove((char *)&idata.erectVMatrix, (char *)&idata.finalMatrix, sizeof(ASFixedMatrix)); + ASFixedMatrixRotate(&idata.erectVMatrix, idata.yShear); idata.finalMatrix.c = idata.erectVMatrix.c; idata.yShear = floor((idata.yShear * 100) + 0.5) / 100; - idata.vRotation = atan2 (ASFixedToFloat (idata.finalMatrix.d), ASFixedToFloat (idata.finalMatrix.c)) / degrees_to_radians - 90; + idata.vRotation = + atan2(ASFixedToFloat(idata.finalMatrix.d), ASFixedToFloat(idata.finalMatrix.c)) / degrees_to_radians - 90; } } - + // Normalize rotations between 0 and 360 with a lower (0.01) resolution - idata.hRotation = NormalizeRotation (idata.hRotation); - idata.vRotation = NormalizeRotation (idata.vRotation); + idata.hRotation = NormalizeRotation(idata.hRotation); + idata.vRotation = NormalizeRotation(idata.vRotation); if (idata.finalMatrix.a != 0) - idata.widthInPoints = ASFixedToFloat (idata.finalMatrix.a) / cos (idata.hRotation * degrees_to_radians); + idata.widthInPoints = ASFixedToFloat(idata.finalMatrix.a) / cos(idata.hRotation * degrees_to_radians); else - idata.widthInPoints = ASFixedToFloat (idata.finalMatrix.b) / sin (idata.hRotation * degrees_to_radians); + idata.widthInPoints = ASFixedToFloat(idata.finalMatrix.b) / sin(idata.hRotation * degrees_to_radians); if (idata.finalMatrix.d != 0) - idata.depthInPoints = ASFixedToFloat (idata.finalMatrix.d) / cos (idata.vRotation * degrees_to_radians); + idata.depthInPoints = ASFixedToFloat(idata.finalMatrix.d) / cos(idata.vRotation * degrees_to_radians); else - idata.depthInPoints = ASFixedToFloat (idata.finalMatrix.c) / -sin (idata.vRotation * degrees_to_radians); + idata.depthInPoints = ASFixedToFloat(idata.finalMatrix.c) / -sin(idata.vRotation * degrees_to_radians); // Get the image attributes - PDEImageGetAttrs (image, &idata.attrs, sizeof (PDEImageAttrs)); + PDEImageGetAttrs(image, &idata.attrs, sizeof(PDEImageAttrs)); // Horizontal DPI is width in pixels divided by width in points divided by 72. // Round these to an even integer, just to make comparison easier. // - // User scale is a scale factor the page creator can apply to the page. It is normally - // used for very large pages, to allow a larger range for an ASFixed value. When we - // calculate this DPI, it is in user units. So we need to multiply by user scale to - // find the actual DPI in absolute space. - // UserScale is not used often, but it must be allowed for. - idata.hDPI = floor (idata.attrs.width / (idata.widthInPoints / 72.0)+0.5) * userScale; + // User scale is a scale factor the page creator can apply to the page. It is normally + // used for very large pages, to allow a larger range for an ASFixed value. When we + // calculate this DPI, it is in user units. So we need to multiply by user scale to + // find the actual DPI in absolute space. + // UserScale is not used often, but it must be allowed for. + idata.hDPI = floor(idata.attrs.width / (idata.widthInPoints / 72.0) + 0.5) * userScale; // Vertical DPI is depth in pixels divided by depth in points divided by 72. // Round these to an even integer, just to make comparision easier. - idata.vDPI = floor (idata.attrs.height / (idata.depthInPoints / 72.0)+0.5) * userScale; + idata.vDPI = floor(idata.attrs.height / (idata.depthInPoints / 72.0) + 0.5) * userScale; - imageTable.push_back ( idata ); + imageTable.push_back(idata); } // Walk through the elements in a single content, recursing into forms and containers, @@ -296,53 +290,48 @@ void FindImageDPI (PDEImage image,ASFixedMatrix *matrix, double userScale, ASInt // // Keep track of matrix changes caused by calling through a form and // carry the user scale amount from the root. -void WalkContent (PDEContent content, ASFixedMatrix *matrix, double userScale, ASInt16 pageNumb, ASInt16 *sequence, std::vector& imageTable) -{ +void WalkContent(PDEContent content, ASFixedMatrix *matrix, double userScale, ASInt16 pageNumb, + ASInt16 *sequence, std::vector &imageTable) { if (!content) return; // Process each element of content - ASInt32 numbElems = PDEContentGetNumElems (content); - for (ASInt32 elemNumb = 0; elemNumb < numbElems; elemNumb++) - { - PDEElement elem = PDEContentGetElem (content, elemNumb); - PDEType type = (PDEType)PDEObjectGetType ((PDEObject)elem); - switch (type) - { - case kPDEImage: - FindImageDPI ((PDEImage)elem, matrix, userScale, pageNumb, *sequence, imageTable ); - (*sequence)++; - break; - - case kPDEForm: - { - // For a form, obtain it's content, and scan it. - // Displace it's position and scale by the form's parents. - ASFixedMatrix innerMatrix; - PDEElementGetMatrix (elem, &innerMatrix); - ASFixedMatrixConcat (&innerMatrix, matrix, &innerMatrix); - PDEContent inner = PDEFormGetContent ((PDEForm)elem); - WalkContent (inner, &innerMatrix, userScale, pageNumb, sequence, imageTable); - // Rememeber to release the content - PDERelease ((PDEObject)inner); - break; - } - - case kPDEContainer: - { - // For a container, simply descend into the container. - // Containers do not displace or scale. Nor does the - // content of a container need to be released. - PDEContent inner = PDEContainerGetContent ((PDEContainer)elem); - WalkContent (inner, matrix, userScale, pageNumb, sequence, imageTable); - break; - } - - default: - // For current purposes, ignore everything else - break; + ASInt32 numbElems = PDEContentGetNumElems(content); + for (ASInt32 elemNumb = 0; elemNumb < numbElems; elemNumb++) { + PDEElement elem = PDEContentGetElem(content, elemNumb); + PDEType type = (PDEType)PDEObjectGetType((PDEObject)elem); + switch (type) { + case kPDEImage: + FindImageDPI((PDEImage)elem, matrix, userScale, pageNumb, *sequence, imageTable); + (*sequence)++; + break; + + case kPDEForm: { + // For a form, obtain it's content, and scan it. + // Displace it's position and scale by the form's parents. + ASFixedMatrix innerMatrix; + PDEElementGetMatrix(elem, &innerMatrix); + ASFixedMatrixConcat(&innerMatrix, matrix, &innerMatrix); + PDEContent inner = PDEFormGetContent((PDEForm)elem); + WalkContent(inner, &innerMatrix, userScale, pageNumb, sequence, imageTable); + // Rememeber to release the content + PDERelease((PDEObject)inner); + break; + } + + case kPDEContainer: { + // For a container, simply descend into the container. + // Containers do not displace or scale. Nor does the + // content of a container need to be released. + PDEContent inner = PDEContainerGetContent((PDEContainer)elem); + WalkContent(inner, matrix, userScale, pageNumb, sequence, imageTable); + break; + } + + default: + // For current purposes, ignore everything else + break; } } return; } - diff --git a/CPlusPlus/Sample_Source/Images/CreateImageWithTransparency/CreateImageWithTransparency.cpp b/CPlusPlus/Sample_Source/Images/CreateImageWithTransparency/CreateImageWithTransparency.cpp index 299bbab8..120e7e60 100644 --- a/CPlusPlus/Sample_Source/Images/CreateImageWithTransparency/CreateImageWithTransparency.cpp +++ b/CPlusPlus/Sample_Source/Images/CreateImageWithTransparency/CreateImageWithTransparency.cpp @@ -9,7 +9,7 @@ // transparent, and thus can blend in various ways with objects behind them. Transparent graphics // or images can be stacked in a PDF file, with each one blending to contribute to the final result // that appears on the page. In this sample the text behind the image is partially visible. -// +// // The PDFEdit Layer (PDE) of the Adobe Acrobat API contains classes that provide a means for editing // objects in PDF documents, including images. The program creates a PDEImage object, using a JPG image // with an adjustable compression level. The program also provides for creating a soft mask with the @@ -34,210 +34,195 @@ #define OUTPUT_FILE "CreateImageWithTransparency-out.pdf" -int main (int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { // Initialize the library - APDFLib libInit; - if (libInit.isValid() == false) - { + APDFLib libInit; + if (libInit.isValid() == false) { ASErrorCode errCode = libInit.getInitError(); - APDFLib::displayError ( errCode ); + APDFLib::displayError(errCode); return errCode; } const char *HelloWorldStr = "Hello World!"; - std::string csOutputFileName ( argc > 1 ? argv[1] : OUTPUT_FILE ); + std::string csOutputFileName(argc > 1 ? argv[1] : OUTPUT_FILE); std::cout << "CreateImageWithTransparency: writing output file " << csOutputFileName.c_str() << std::endl; // Create color spaces that will be needed - PDEColorSpace ImageColorSpace = PDEColorSpaceCreateFromName(ASAtomFromString ("DeviceRGB")); - PDEColorSpace MaskColorSpace = PDEColorSpaceCreateFromName(ASAtomFromString ("DeviceGray")); - -DURING - - // Create an output document - PDDoc outputPDDoc = PDDocCreate(); - - // Create the image data - PDEImageAttrs attrs; - memset(&attrs, 0, sizeof(attrs)); - attrs.flags = kPDEImageExternal; - attrs.height = 288; // in pixels, = 4 in. x 72 pixels/in. - attrs.width = 648; // in pixels, = 9 in. x 72 pixels/in. - attrs.bitsPerComponent = 8; - - // Set the image encoding filter to JPEG - PDEFilterArray filterArrayImage; - memset(&filterArrayImage, 0, sizeof(filterArrayImage)); - filterArrayImage.numFilters = 1; - filterArrayImage.spec[0].name = ASAtomFromString("DCTDecode"); - - CosDoc outCosDoc = PDDocGetCosDoc(outputPDDoc); - CosObj dctParams = CosNewDict(outCosDoc, false, 5); - CosDictPut(dctParams, ASAtomFromString("Columns"), - CosNewInteger( outCosDoc, false, attrs.width)); - CosDictPut(dctParams, ASAtomFromString("Rows"), - CosNewInteger( outCosDoc, false, attrs.height)); - CosDictPut(dctParams, ASAtomFromString("Colors"), - CosNewInteger( outCosDoc, false, PDEColorSpaceGetNumComps(ImageColorSpace))); - - // The QFactor controls the quality/compression tradeoff. - // These values describe the approximate image quality: - // 0.15: Superior - // 0.3: Excellent - // 0.5 - 0.7: Very Good - // 1.3: Fair - CosDictPut(dctParams, ASAtomFromString("QFactor"), - CosNewFixed(outCosDoc, false, FloatToASFixed(1.3)) ); - filterArrayImage.spec[0].encodeParms = dctParams; - - // Set the mask encoding filter to Flate - PDEFilterArray filterArrayMask; - memset(&filterArrayMask, 0, sizeof(filterArrayMask)); - filterArrayMask.numFilters = 1; - filterArrayMask.spec[0].name = ASAtomFromString("FlateDecode"); - - ASFixedMatrix imageMatrix; - imageMatrix.a = attrs.width * fixedOne; - imageMatrix.d = attrs.height * fixedOne; - imageMatrix.b = imageMatrix.c = 0; - imageMatrix.h = imageMatrix.v = 0; - - ASInt32 ImageSize = attrs.height * attrs.width * 3; - ASInt32 MaskSize = attrs.height * attrs.width; - ASInt32 Line, Row; - ASUns8 pixelValR = 0, pixelValG = 0, pixelValB = 0; - - ASUns8* ImageBuffer = new ASUns8[ImageSize]; - ASUns8* MaskBuffer = new ASUns8[MaskSize]; - - // Image data - Create a 9 x 4 inch yellow rectangle - for (Line = 0; Line < attrs.height; Line++) - { - for (Row = 0; Row < attrs.width; Row++) - { - ASUns8 *Pixel = &ImageBuffer[(Line * attrs.width * 3) + (Row * 3)]; - pixelValR = 0xFF; - pixelValG = 0xFF; - Pixel[0] = pixelValR; - Pixel[1] = pixelValG; - Pixel[2] = pixelValB; + PDEColorSpace ImageColorSpace = PDEColorSpaceCreateFromName(ASAtomFromString("DeviceRGB")); + PDEColorSpace MaskColorSpace = PDEColorSpaceCreateFromName(ASAtomFromString("DeviceGray")); + + DURING + + // Create an output document + PDDoc outputPDDoc = PDDocCreate(); + + // Create the image data + PDEImageAttrs attrs; + memset(&attrs, 0, sizeof(attrs)); + attrs.flags = kPDEImageExternal; + attrs.height = 288; // in pixels, = 4 in. x 72 pixels/in. + attrs.width = 648; // in pixels, = 9 in. x 72 pixels/in. + attrs.bitsPerComponent = 8; + + // Set the image encoding filter to JPEG + PDEFilterArray filterArrayImage; + memset(&filterArrayImage, 0, sizeof(filterArrayImage)); + filterArrayImage.numFilters = 1; + filterArrayImage.spec[0].name = ASAtomFromString("DCTDecode"); + + CosDoc outCosDoc = PDDocGetCosDoc(outputPDDoc); + CosObj dctParams = CosNewDict(outCosDoc, false, 5); + CosDictPut(dctParams, ASAtomFromString("Columns"), CosNewInteger(outCosDoc, false, attrs.width)); + CosDictPut(dctParams, ASAtomFromString("Rows"), CosNewInteger(outCosDoc, false, attrs.height)); + CosDictPut(dctParams, ASAtomFromString("Colors"), + CosNewInteger(outCosDoc, false, PDEColorSpaceGetNumComps(ImageColorSpace))); + + // The QFactor controls the quality/compression tradeoff. + // These values describe the approximate image quality: + // 0.15: Superior + // 0.3: Excellent + // 0.5 - 0.7: Very Good + // 1.3: Fair + CosDictPut(dctParams, ASAtomFromString("QFactor"), CosNewFixed(outCosDoc, false, FloatToASFixed(1.3))); + filterArrayImage.spec[0].encodeParms = dctParams; + + // Set the mask encoding filter to Flate + PDEFilterArray filterArrayMask; + memset(&filterArrayMask, 0, sizeof(filterArrayMask)); + filterArrayMask.numFilters = 1; + filterArrayMask.spec[0].name = ASAtomFromString("FlateDecode"); + + ASFixedMatrix imageMatrix; + imageMatrix.a = attrs.width * fixedOne; + imageMatrix.d = attrs.height * fixedOne; + imageMatrix.b = imageMatrix.c = 0; + imageMatrix.h = imageMatrix.v = 0; + + ASInt32 ImageSize = attrs.height * attrs.width * 3; + ASInt32 MaskSize = attrs.height * attrs.width; + ASInt32 Line, Row; + ASUns8 pixelValR = 0, pixelValG = 0, pixelValB = 0; + + ASUns8 *ImageBuffer = new ASUns8[ImageSize]; + ASUns8 *MaskBuffer = new ASUns8[MaskSize]; + + // Image data - Create a 9 x 4 inch yellow rectangle + for (Line = 0; Line < attrs.height; Line++) { + for (Row = 0; Row < attrs.width; Row++) { + ASUns8 *Pixel = &ImageBuffer[(Line * attrs.width * 3) + (Row * 3)]; + pixelValR = 0xFF; + pixelValG = 0xFF; + Pixel[0] = pixelValR; + Pixel[1] = pixelValG; + Pixel[2] = pixelValB; + } } - } - // Mask data - Set a 7 x 2 inch hole in the middle of the 9 x 4 inch rectangle. - // Initially set the mask to all black (on) - memset(MaskBuffer, 0xFF, MaskSize); - - // Also set a gradation in the middle of the hole. - ASUns8 pixelVal = 0; - // Blend color from one inch (72 points) from the bottom to one inch from the top. - for (Line = 72; Line < attrs.height - 72; Line++) - { - // Blend color from one inch from the left to one inch from the right. - for (Row = 72; Row < attrs.width - 72; Row++) - { - // From one inch from the left, gradiate from full color (0xFF) to (near) zero color. - pixelVal = 0xFF - (ASUns8)((Row * 0xFF) / (attrs.width - 72)); - ASUns8 *Pixel = &MaskBuffer[(Line * attrs.width) + (Row)]; - Pixel[0] = pixelVal; + // Mask data - Set a 7 x 2 inch hole in the middle of the 9 x 4 inch rectangle. + // Initially set the mask to all black (on) + memset(MaskBuffer, 0xFF, MaskSize); + + // Also set a gradation in the middle of the hole. + ASUns8 pixelVal = 0; + // Blend color from one inch (72 points) from the bottom to one inch from the top. + for (Line = 72; Line < attrs.height - 72; Line++) { + // Blend color from one inch from the left to one inch from the right. + for (Row = 72; Row < attrs.width - 72; Row++) { + // From one inch from the left, gradiate from full color (0xFF) to (near) zero color. + pixelVal = 0xFF - (ASUns8)((Row * 0xFF) / (attrs.width - 72)); + ASUns8 *Pixel = &MaskBuffer[(Line * attrs.width) + (Row)]; + Pixel[0] = pixelVal; + } } - } - // Create the PDEImage objects - PDEImage pdeImageMain = PDEImageCreate(&attrs, sizeof(attrs),&imageMatrix, 0, - ImageColorSpace, NULL, - &filterArrayImage, 0, - (unsigned char*) ImageBuffer, ImageSize); - - PDEImage pdeImageMask = PDEImageCreate(&attrs, sizeof(attrs),&imageMatrix, 0, - MaskColorSpace, NULL, - &filterArrayMask, 0, - (unsigned char*) MaskBuffer, MaskSize); - - // Associate the mask to the image - PDEImageSetSMask(pdeImageMain, pdeImageMask); - - // Create a PDEText object to set text on the page - PDEFontAttrs pdeFontAttrs; - memset(&pdeFontAttrs, 0, sizeof(pdeFontAttrs)); - pdeFontAttrs.name = ASAtomFromString("CourierStd"); - pdeFontAttrs.type = ASAtomFromString("Type1"); - - PDSysFont sysFont = PDFindSysFont(&pdeFontAttrs, sizeof(PDEFontAttrs), 0); - PDEFont pdeFont = PDEFontCreateFromSysFont(sysFont, kPDEFontDoNotEmbed); - - PDEColorSpace pdeColorSpace = PDEColorSpaceCreateFromName(ASAtomFromString("DeviceGray")); - PDEGraphicState gState; // graphic state to apply to operation - memset(&gState, 0, sizeof(PDEGraphicState)); - gState.strokeColorSpec.space = gState.fillColorSpec.space = pdeColorSpace; - gState.miterLimit = fixedTen; - gState.flatness = fixedOne; - gState.lineWidth = fixedOne; - - ASFixedMatrix textMatrix; // transformation matrix for text - memset(&textMatrix, 0, sizeof(textMatrix)); // clear structure - textMatrix.a = Int16ToFixed(24); // set font width and height - textMatrix.d = Int16ToFixed(24); // to 24 point size - textMatrix.h = Int16ToFixed(0.75*72); // x,y coordinate on page - textMatrix.v = Int16ToFixed(1.5*72); - PDEText pdeText = PDETextCreate(); // create new text run - PDETextAdd(pdeText, // text container to add to - kPDETextRun, // kPDETextRun, kPDETextChar - 0, // index - (Uns8 *)HelloWorldStr, // text to add - strlen(HelloWorldStr), // length of text - pdeFont, // font to apply to text - &gState, sizeof(gState), // graphic state to apply to text - NULL, 0, // text state and size of structure - &textMatrix, // transformation matrix for text - NULL); // stroke matrix - - // Create the output page, 9 x 4 inch - ASFixedRect pageRect; - pageRect.left = pageRect.bottom = 0; - pageRect.right = 72 * fixedNine; - pageRect.top = 72 * fixedFour; - - PDPage outputPDPage = PDDocCreatePage(outputPDDoc, PDDocGetNumPages (outputPDDoc) - 1, - pageRect); - PDEContent content = PDPageAcquirePDEContent (outputPDPage, 0); - - // Add PDEText and PDEImage objects to page content - PDEContentAddElem(content, kPDEAfterLast, (PDEElement) pdeText); - PDEContentAddElem(content, 0, (PDEElement) pdeImageMain); - - PDPageSetPDEContent (outputPDPage, 0); - - // Cleanup - PDPageReleasePDEContent (outputPDPage, 0); - PDPageRelease (outputPDPage); - - PDERelease((PDEObject) pdeFont); - PDERelease((PDEObject) pdeText); - PDERelease((PDEObject) pdeImageMain); - PDERelease((PDEObject) pdeImageMask); - PDERelease((PDEObject) ImageColorSpace); - PDERelease((PDEObject) MaskColorSpace); - PDERelease((PDEObject) pdeColorSpace); - - delete[] ImageBuffer; - delete[] MaskBuffer; - - ASPathName outputPathName = APDFLDoc::makePath ( csOutputFileName.c_str() ); - PDDocSave(outputPDDoc, PDSaveFull | PDSaveCollectGarbage, outputPathName, 0, 0, 0); - if (outputPathName) - ASFileSysReleasePath(0, outputPathName); - - PDDocClose(outputPDDoc); - -HANDLER - APDFLib::displayError(ERRORCODE); - return ERRORCODE; -END_HANDLER + // Create the PDEImage objects + PDEImage pdeImageMain = + PDEImageCreate(&attrs, sizeof(attrs), &imageMatrix, 0, ImageColorSpace, NULL, + &filterArrayImage, 0, (unsigned char *)ImageBuffer, ImageSize); + + PDEImage pdeImageMask = PDEImageCreate(&attrs, sizeof(attrs), &imageMatrix, 0, MaskColorSpace, NULL, + &filterArrayMask, 0, (unsigned char *)MaskBuffer, MaskSize); + + // Associate the mask to the image + PDEImageSetSMask(pdeImageMain, pdeImageMask); + + // Create a PDEText object to set text on the page + PDEFontAttrs pdeFontAttrs; + memset(&pdeFontAttrs, 0, sizeof(pdeFontAttrs)); + pdeFontAttrs.name = ASAtomFromString("CourierStd"); + pdeFontAttrs.type = ASAtomFromString("Type1"); + + PDSysFont sysFont = PDFindSysFont(&pdeFontAttrs, sizeof(PDEFontAttrs), 0); + PDEFont pdeFont = PDEFontCreateFromSysFont(sysFont, kPDEFontDoNotEmbed); + + PDEColorSpace pdeColorSpace = PDEColorSpaceCreateFromName(ASAtomFromString("DeviceGray")); + PDEGraphicState gState; // graphic state to apply to operation + memset(&gState, 0, sizeof(PDEGraphicState)); + gState.strokeColorSpec.space = gState.fillColorSpec.space = pdeColorSpace; + gState.miterLimit = fixedTen; + gState.flatness = fixedOne; + gState.lineWidth = fixedOne; + + ASFixedMatrix textMatrix; // transformation matrix for text + memset(&textMatrix, 0, sizeof(textMatrix)); // clear structure + textMatrix.a = Int16ToFixed(24); // set font width and height + textMatrix.d = Int16ToFixed(24); // to 24 point size + textMatrix.h = Int16ToFixed(0.75 * 72); // x,y coordinate on page + textMatrix.v = Int16ToFixed(1.5 * 72); + PDEText pdeText = PDETextCreate(); // create new text run + PDETextAdd(pdeText, // text container to add to + kPDETextRun, // kPDETextRun, kPDETextChar + 0, // index + (Uns8 *)HelloWorldStr, // text to add + strlen(HelloWorldStr), // length of text + pdeFont, // font to apply to text + &gState, sizeof(gState), // graphic state to apply to text + NULL, 0, // text state and size of structure + &textMatrix, // transformation matrix for text + NULL); // stroke matrix + + // Create the output page, 9 x 4 inch + ASFixedRect pageRect; + pageRect.left = pageRect.bottom = 0; + pageRect.right = 72 * fixedNine; + pageRect.top = 72 * fixedFour; + + PDPage outputPDPage = PDDocCreatePage(outputPDDoc, PDDocGetNumPages(outputPDDoc) - 1, pageRect); + PDEContent content = PDPageAcquirePDEContent(outputPDPage, 0); + + // Add PDEText and PDEImage objects to page content + PDEContentAddElem(content, kPDEAfterLast, (PDEElement)pdeText); + PDEContentAddElem(content, 0, (PDEElement)pdeImageMain); + + PDPageSetPDEContent(outputPDPage, 0); + + // Cleanup + PDPageReleasePDEContent(outputPDPage, 0); + PDPageRelease(outputPDPage); + + PDERelease((PDEObject)pdeFont); + PDERelease((PDEObject)pdeText); + PDERelease((PDEObject)pdeImageMain); + PDERelease((PDEObject)pdeImageMask); + PDERelease((PDEObject)ImageColorSpace); + PDERelease((PDEObject)MaskColorSpace); + PDERelease((PDEObject)pdeColorSpace); + + delete[] ImageBuffer; + delete[] MaskBuffer; + + ASPathName outputPathName = APDFLDoc::makePath(csOutputFileName.c_str()); + PDDocSave(outputPDDoc, PDSaveFull | PDSaveCollectGarbage, outputPathName, 0, 0, 0); + if (outputPathName) + ASFileSysReleasePath(0, outputPathName); + + PDDocClose(outputPDDoc); + + HANDLER + APDFLib::displayError(ERRORCODE); + return ERRORCODE; + END_HANDLER return 0; - } - diff --git a/CPlusPlus/Sample_Source/Images/CreateSeparations/CreateSeparations.cpp b/CPlusPlus/Sample_Source/Images/CreateSeparations/CreateSeparations.cpp index f7dced47..629a5cd3 100644 --- a/CPlusPlus/Sample_Source/Images/CreateSeparations/CreateSeparations.cpp +++ b/CPlusPlus/Sample_Source/Images/CreateSeparations/CreateSeparations.cpp @@ -5,7 +5,7 @@ // http://dev.datalogics.com/adobe-pdf-library/adobe-pdf-library-c-language-interface/license-for-downloaded-pdf-samples/ // // The sample demonstrates how to create color separations for spot color images. -// +// // Color separation is part of high volume offset printing processing. The original digital content // is color separated to create a set of plates for printing, generally one plate per page for each // of the primary colors—Cyan, Magenta, Yellow, and Black (CMYK). During printing each color layer is @@ -13,15 +13,15 @@ // color in the final images. A spot color is a separate color added on top of the image after the // four color plates are used to create the initial print run. // -// For more detail see the description of the CreateSeparations sample program on our Developer’s site, +// For more detail see the description of the CreateSeparations sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#createseparations -// This sample will read each page from a document, and create a set of bitmap images for each page. +// This sample will read each page from a document, and create a set of bitmap images for each page. // the first image will show the entire page, in CMYK. It will then create separations for the page -// into Cyan, Magenta, Yellow, Black, and spot colors. NOTE: separation will be created for each spot -// color DEFINED in a page, Whether or not that color is USED in the page. All of these images will -// be inserted, one page per image, into the output document created. The process and spot color -// plated will be rendered visually in DeviceGray. +// into Cyan, Magenta, Yellow, Black, and spot colors. NOTE: separation will be created for each +// spot color DEFINED in a page, Whether or not that color is USED in the page. All of these images +// will be inserted, one page per image, into the output document created. The process and spot +// color plated will be rendered visually in DeviceGray. #include #include "PERCalls.h" @@ -35,8 +35,7 @@ #include "CosCalls.h" #include - -// Resolution of image desired for plates. +// Resolution of image desired for plates. #define RESOLUTION (300.0) // Font used to label plates @@ -49,187 +48,176 @@ #define DEF_INPUT "RenderPage.pdf" #define DEF_OUTPUT "Out.pdf" -// This is a structure used to carry information between functions, so as to lower the requirements -// for obtaining this info in each function. It carries information about the page currently being +// This is a structure used to carry information between functions, so as to lower the requirements +// for obtaining this info in each function. It carries information about the page currently being // rendered, as well as information used in rendering -typedef struct pageInfo -{ - PDPage page; - ASUns8 numberOfColorants; +typedef struct pageInfo { + PDPage page; + ASUns8 numberOfColorants; // Width and Depth in pixels - ASInt32 rows; - ASInt32 cols; - ASUns32 rowWidth; + ASInt32 rows; + ASInt32 cols; + ASUns32 rowWidth; // Referenced from drawParams; - ASRealRect drawWindow; - ASRealMatrix drawMatrix; + ASRealRect drawWindow; + ASRealMatrix drawMatrix; // Structure used to control the drawing of the page - PDPageDrawMParamsRec drawParams; + PDPageDrawMParamsRec drawParams; // Information needed to add text to page - PDEFont textFont; - PDEGraphicState textGState; - PDETextState textTState; - ASDoubleMatrix textMatrix; + PDEFont textFont; + PDEGraphicState textGState; + PDETextState textTState; + ASDoubleMatrix textMatrix; } PageInfo; - -void FillPageInfo (PageInfo *pageInfo, PDPage page); -void WriteCMYKImage (PageInfo *pageInfo, PDDoc outputDoc); -void WriteDeviceNImage (PageInfo *pageInfo, PDDoc outputDoc); -void WriteSeparationImage (PageInfo *pageInfo, PDDoc outputDoc, int separationNumber); -void AddImageToDoc (PageInfo *pageInfo, PDDoc outputDoc, PDEColorSpace color, char *buffer, size_t bufferSize, ASInt16 channels, char *Name, - ASBool invertColor = false); +void FillPageInfo(PageInfo *pageInfo, PDPage page); +void WriteCMYKImage(PageInfo *pageInfo, PDDoc outputDoc); +void WriteDeviceNImage(PageInfo *pageInfo, PDDoc outputDoc); +void WriteSeparationImage(PageInfo *pageInfo, PDDoc outputDoc, int separationNumber); +void AddImageToDoc(PageInfo *pageInfo, PDDoc outputDoc, PDEColorSpace color, char *buffer, + size_t bufferSize, ASInt16 channels, const char *Name, ASBool invertColor = false); // // The main process will intialize the library, open the input document, create the output document, // and initialize the communication structure. Then, for each page, it will render the page to CMYK, and insert -// this image into the output document, then render to DeviceN, and separate out the colorants, writing them +// this image into the output document, then render to DeviceN, and separate out the colorants, writing them // one-by-one to the output. It will then release global resources, save the output, and terminate the library. -int main ( int argc, char *argv[] ) -{ - APDFLib libInit; // Initialize the Adobe PDF Library. (Going out of scope will terminate.) +int main(int argc, char *argv[]) { + APDFLib libInit; // Initialize the Adobe PDF Library. (Going out of scope will terminate.) ASErrorCode errCode = 0; - if (libInit.isValid () == false) - { - errCode = libInit.getInitError (); + if (libInit.isValid() == false) { + errCode = libInit.getInitError(); std::cout << "Initialization failed with code " << errCode << std::endl; return errCode; } DURING - std::string csInputFileName (argc > 1 ? argv[1] : INPUT_LOC DEF_INPUT); - std::string csOutputFileName (argc > 2 ? argv[2] : DEF_OUTPUT); + std::string csInputFileName(argc > 1 ? argv[1] : INPUT_LOC DEF_INPUT); + std::string csOutputFileName(argc > 2 ? argv[2] : DEF_OUTPUT); - std::cout << "Creating separations for " << csInputFileName.c_str() << - " in files starting with " << csOutputFileName.c_str () << std::endl; + std::cout << "Creating separations for " << csInputFileName.c_str() + << " in files starting with " << csOutputFileName.c_str() << std::endl; // Open the input as a PDF file - APDFLDoc papdflDoc ( csInputFileName.c_str(), true ); + APDFLDoc papdflDoc(csInputFileName.c_str(), true); PDDoc doc = papdflDoc.getPDDoc(); // Create an output Document - PDDoc outputDoc = PDDocCreate (); + PDDoc outputDoc = PDDocCreate(); // Create a page Info Structure, and populate it with page // independent information PageInfo pageInfo; - memset ((char *)&pageInfo, 0, sizeof (PageInfo)); + memset((char *)&pageInfo, 0, sizeof(PageInfo)); // We create here the structures needed to add text to output pages PDEFontAttrs FontAttrs; - memset (&FontAttrs, 0, sizeof (FontAttrs)); - FontAttrs.name = ASAtomFromString (FONT_NAME); - FontAttrs.type = ASAtomFromString (FONT_TYPE); - PDSysFont SysFont = PDFindSysFont (&FontAttrs, sizeof (PDEFontAttrs), 0); - if (!SysFont) - { + memset(&FontAttrs, 0, sizeof(FontAttrs)); + FontAttrs.name = ASAtomFromString(FONT_NAME); + FontAttrs.type = ASAtomFromString(FONT_TYPE); + PDSysFont SysFont = PDFindSysFont(&FontAttrs, sizeof(PDEFontAttrs), 0); + if (!SysFont) { std::cout << "Cannot obtain System Font " << FONT_NAME << " " << FONT_TYPE << std::endl; return 1; } - PDSysFontGetAttrs (SysFont, &FontAttrs, sizeof (PDEFontAttrs)); - pageInfo.textFont = PDEFontCreateFromSysFont (SysFont, kPDEFontDoNotEmbed); - - PDEDefaultGState (&pageInfo.textGState, sizeof (PDEGraphicState)); - memset ((char *)&pageInfo.textTState, 0, sizeof (PDETextState)); + PDSysFontGetAttrs(SysFont, &FontAttrs, sizeof(PDEFontAttrs)); + pageInfo.textFont = PDEFontCreateFromSysFont(SysFont, kPDEFontDoNotEmbed); + PDEDefaultGState(&pageInfo.textGState, sizeof(PDEGraphicState)); + memset((char *)&pageInfo.textTState, 0, sizeof(PDETextState)); pageInfo.textMatrix.a = pageInfo.textMatrix.d = 62.0; pageInfo.textMatrix.b = pageInfo.textMatrix.c = 0.0; pageInfo.textMatrix.h = 72.0; - // Create separations for each page - // To the output file, draw a CMYK rendering of the entire file, and + // To the output file, draw a CMYK rendering of the entire file, and // a DeviceN Composite rendering, then a separation plate for each colorant. - for (int page = 0; page < PDDocGetNumPages (doc); page++) - { + for (int page = 0; page < PDDocGetNumPages(doc); page++) { // Acquire the page to render - PDPage pdPage = PDDocAcquirePage (doc, page); + PDPage pdPage = PDDocAcquirePage(doc, page); // Fill in the information needed to render the page - FillPageInfo (&pageInfo, pdPage); + FillPageInfo(&pageInfo, pdPage); // Create, and write to the output document, the CMYK rendering of this page - WriteCMYKImage (&pageInfo, outputDoc); + WriteCMYKImage(&pageInfo, outputDoc); - //Create the DeviceN rendering of this page - WriteDeviceNImage (&pageInfo, outputDoc); + // Create the DeviceN rendering of this page + WriteDeviceNImage(&pageInfo, outputDoc); - //Divide the DeviceN image into separations, and write each to the output document + // Divide the DeviceN image into separations, and write each to the output document for (int color = 0; color < pageInfo.numberOfColorants; color++) - WriteSeparationImage (&pageInfo, outputDoc, color); + WriteSeparationImage(&pageInfo, outputDoc, color); // Release the page. - PDPageRelease (pdPage); + PDPageRelease(pdPage); } // Release the information used for all pages - PDERelease ((PDEObject)pageInfo.textFont); - PDERelease ((PDEObject)pageInfo.textGState.fillColorSpec.space); - PDERelease ((PDEObject)pageInfo.textGState.strokeColorSpec.space); + PDERelease((PDEObject)pageInfo.textFont); + PDERelease((PDEObject)pageInfo.textGState.fillColorSpec.space); + PDERelease((PDEObject)pageInfo.textGState.strokeColorSpec.space); // Release the buffer for the last bitmap drawn if (pageInfo.drawParams.buffer != NULL) - ASfree (pageInfo.drawParams.buffer); + ASfree(pageInfo.drawParams.buffer); // Release the ink list for the last DeviceN rendering if (pageInfo.drawParams.deviceNColorInks) - ASfree (pageInfo.drawParams.deviceNColorInks); + ASfree(pageInfo.drawParams.deviceNColorInks); // Save the output document - ASPathName outputPathName = APDFLDoc::makePath (csOutputFileName.c_str ()); - PDDocSave (outputDoc, PDSaveFull | PDSaveCollectGarbage, outputPathName, 0, 0, 0); - ASFileSysReleasePath (NULL, outputPathName); - PDDocClose (outputDoc); + ASPathName outputPathName = APDFLDoc::makePath(csOutputFileName.c_str()); + PDDocSave(outputDoc, PDSaveFull | PDSaveCollectGarbage, outputPathName, 0, 0, 0); + ASFileSysReleasePath(NULL, outputPathName); + PDDocClose(outputDoc); HANDLER - APDFLib::displayError ( ERRORCODE ); - return ERRORCODE; + APDFLib::displayError(ERRORCODE); + return ERRORCODE; END_HANDLER - return (0); } -// This will fill in the information needed to render the given page, in the +// This will fill in the information needed to render the given page, in the // given resolution. The page will always be displayed upright. -void FillPageInfo (PageInfo *pageInfo, PDPage page) -{ +void FillPageInfo(PageInfo *pageInfo, PDPage page) { // Save the page in the collected information pageInfo->page = page; - // Obtain the page size, and the matrix needed to draw + // Obtain the page size, and the matrix needed to draw // the page from top to bottom ASFixedMatrix pageMatrix; - ASFixedRect pageRect; - PDPageGetFlippedMatrix (page, &pageMatrix); - PDPageGetCropBox (page, &pageRect); + ASFixedRect pageRect; + PDPageGetFlippedMatrix(page, &pageMatrix); + PDPageGetCropBox(page, &pageRect); - // Convert the size and matrix from + // Convert the size and matrix from // ASFixed values to double values double left, right, top, bottom; - left = ASFixedToFloat (pageRect.left); - right = ASFixedToFloat (pageRect.right); - top = ASFixedToFloat (pageRect.top); - bottom = ASFixedToFloat (pageRect.bottom); + left = ASFixedToFloat(pageRect.left); + right = ASFixedToFloat(pageRect.right); + top = ASFixedToFloat(pageRect.top); + bottom = ASFixedToFloat(pageRect.bottom); /* Draw Window is the SIZE of the resultant image. we want it ** always to be based at (0,0), and extend right by width, and up by height */ pageInfo->drawWindow.left = 0; pageInfo->drawWindow.bottom = 0; - pageInfo->drawWindow.top = (ASReal)floor ((ASReal)((top - bottom) * RESOLUTION / 72.0) + 0.5); - pageInfo->drawWindow.right = (ASReal)floor ((ASReal)((right - left) * RESOLUTION / 72.0) + 0.5); + pageInfo->drawWindow.top = (ASReal)floor((ASReal)((top - bottom) * RESOLUTION / 72.0) + 0.5); + pageInfo->drawWindow.right = (ASReal)floor((ASReal)((right - left) * RESOLUTION / 72.0) + 0.5); - // If the page has a 90 or 270 degree rotation, + // If the page has a 90 or 270 degree rotation, // we need to swap the width and depth - ASUns16 rotation = PDPageGetRotate (page); - if ((rotation == 90) || (rotation == 270)) - { + ASUns16 rotation = PDPageGetRotate(page); + if ((rotation == 90) || (rotation == 270)) { ASReal save = pageInfo->drawWindow.top; pageInfo->drawWindow.top = pageInfo->drawWindow.right; pageInfo->drawWindow.right = save; @@ -249,15 +237,14 @@ void FillPageInfo (PageInfo *pageInfo, PDPage page) ** image. We draw here from bottom to top, and note in creating the image to be put into ** the page that we are drawing from bottom to top */ - pageInfo->drawMatrix.a = (ASReal)(RESOLUTION / 72.0 * ASFixedToFloat (pageMatrix.a)); - pageInfo->drawMatrix.b = (ASReal)(RESOLUTION / 72.0 * ASFixedToFloat (pageMatrix.b)); - pageInfo->drawMatrix.c = (ASReal)(RESOLUTION / 72.0 * ASFixedToFloat (pageMatrix.c)); - pageInfo->drawMatrix.d = (ASReal)(RESOLUTION / 72.0 * ASFixedToFloat (pageMatrix.d)); - pageInfo->drawMatrix.tx = (ASReal)(RESOLUTION / 72.0 * ASFixedToFloat (pageMatrix.h)); - pageInfo->drawMatrix.ty = (ASReal)(RESOLUTION / 72.0 * ASFixedToFloat (pageMatrix.v)); - - - pageInfo->drawParams.size = sizeof (PDPageDrawMParamsRec); + pageInfo->drawMatrix.a = (ASReal)(RESOLUTION / 72.0 * ASFixedToFloat(pageMatrix.a)); + pageInfo->drawMatrix.b = (ASReal)(RESOLUTION / 72.0 * ASFixedToFloat(pageMatrix.b)); + pageInfo->drawMatrix.c = (ASReal)(RESOLUTION / 72.0 * ASFixedToFloat(pageMatrix.c)); + pageInfo->drawMatrix.d = (ASReal)(RESOLUTION / 72.0 * ASFixedToFloat(pageMatrix.d)); + pageInfo->drawMatrix.tx = (ASReal)(RESOLUTION / 72.0 * ASFixedToFloat(pageMatrix.h)); + pageInfo->drawMatrix.ty = (ASReal)(RESOLUTION / 72.0 * ASFixedToFloat(pageMatrix.v)); + + pageInfo->drawParams.size = sizeof(PDPageDrawMParamsRec); pageInfo->drawParams.asRealMatrix = &pageInfo->drawMatrix; pageInfo->drawParams.asRealDestRect = &pageInfo->drawWindow; pageInfo->drawParams.bpc = 8; @@ -275,62 +262,63 @@ void FillPageInfo (PageInfo *pageInfo, PDPage page) } // Draw the page to CMYK, and insert into the destination document. -void WriteCMYKImage (PageInfo *pageInfo, PDDoc outputDoc) -{ +void WriteCMYKImage(PageInfo *pageInfo, PDDoc outputDoc) { // First, draw the image to a buffer using PDDrawContentsToMemoryWithParams - // All of the params relevant to positioning and scaling the page are already set. + // All of the params relevant to positioning and scaling the page are already set. // Here, we need to set color space to CMYK - pageInfo->drawParams.csAtom = ASAtomFromString ("DeviceCMYK"); - + pageInfo->drawParams.csAtom = ASAtomFromString("DeviceCMYK"); + // If a buffer already exists, free it, and null the pointer if (pageInfo->drawParams.buffer != NULL) - ASfree (pageInfo->drawParams.buffer); + ASfree(pageInfo->drawParams.buffer); pageInfo->drawParams.buffer = NULL; - // Call PDPageDrawContentsToMemoryWithParams with a null pointer to the buffer, + // Call PDPageDrawContentsToMemoryWithParams with a null pointer to the buffer, // in order to find the required buffer size - pageInfo->drawParams.bufferSize = PDPageDrawContentsToMemoryWithParams (pageInfo->page, &pageInfo->drawParams); + pageInfo->drawParams.bufferSize = + PDPageDrawContentsToMemoryWithParams(pageInfo->page, &pageInfo->drawParams); // Allocate a buffer of that size - pageInfo->drawParams.buffer = (char *)ASmalloc (pageInfo->drawParams.bufferSize); + pageInfo->drawParams.buffer = (char *)ASmalloc(pageInfo->drawParams.bufferSize); // Actually draw the page into the buffer. - pageInfo->drawParams.bufferSize = PDPageDrawContentsToMemoryWithParams (pageInfo->page, &pageInfo->drawParams); + pageInfo->drawParams.bufferSize = + PDPageDrawContentsToMemoryWithParams(pageInfo->page, &pageInfo->drawParams); - // APDFL will pad each row to an even 32 bit boundary. For this reason, row width may not be equal to + // APDFL will pad each row to an even 32 bit boundary. For this reason, row width may not be equal to // pixels wide * channels. However, for CMYK, each pixel is 32 bits, so they are always the same pageInfo->rowWidth = pageInfo->cols * 4; // This color space is easy, it is just CMYK - PDEColorSpace cmyk = PDEColorSpaceCreateFromName (ASAtomFromString ("DeviceCMYK")); + PDEColorSpace cmyk = PDEColorSpaceCreateFromName(ASAtomFromString("DeviceCMYK")); // Add the image to the output document - AddImageToDoc (pageInfo, outputDoc, cmyk, pageInfo->drawParams.buffer, pageInfo->drawParams.bufferSize, 4, "CMYK"); + AddImageToDoc(pageInfo, outputDoc, cmyk, pageInfo->drawParams.buffer, + pageInfo->drawParams.bufferSize, 4, const_cast("CMYK")); // Release the color space - PDERelease ((PDEObject)cmyk); + PDERelease((PDEObject)cmyk); return; } // Create the separations as a DeviceN bitmap -void WriteDeviceNImage (PageInfo *pageInfo, PDDoc outputDoc) -{ +void WriteDeviceNImage(PageInfo *pageInfo, PDDoc outputDoc) { // First, draw the image to a buffer using PDDrawContentsToMemoryWithParams - // All of the params relevant to positioning and scaling the page are already set. + // All of the params relevant to positioning and scaling the page are already set. // Here, we need to set color space to CMYK - pageInfo->drawParams.csAtom = ASAtomFromString ("DeviceN"); + pageInfo->drawParams.csAtom = ASAtomFromString("DeviceN"); // If a buffer already exists, free it, and null the pointer if (pageInfo->drawParams.buffer != NULL) - ASfree (pageInfo->drawParams.buffer); + ASfree(pageInfo->drawParams.buffer); pageInfo->drawParams.buffer = NULL; // reset numberofColorants to force generation of color list pageInfo->numberOfColorants = 0; // Set up for color list - // The easiest way to do this is to NOT provide a colorant list, + // The easiest way to do this is to NOT provide a colorant list, // but instead, allow PDPageDrawContentsToMemory to construct the // colorant list. Provide a block of memory large enough to hold // 32 colorants (No more than 31 will ever be used). @@ -338,74 +326,76 @@ void WriteDeviceNImage (PageInfo *pageInfo, PDDoc outputDoc) // CAUTION: APDFL will not support more than 27 spot colors in any DeviceN rendering! // If your page contains more spot colorants than this, you will need to create and populate // the DeviceNColorInks array within your application, and render multiple times, to obtain - // separations for all colorants. + // separations for all colorants. // The first 4 inks should always the Cyan, Magenta, Yelow, and Black, in that order. pageInfo->drawParams.deviceNColorSize = 32; pageInfo->drawParams.deviceNColorCount = &pageInfo->numberOfColorants; if (!pageInfo->drawParams.deviceNColorInks) - pageInfo->drawParams.deviceNColorInks = (PDPageInk)ASmalloc (pageInfo->drawParams.deviceNColorSize * sizeof (PDPageInkRec)); + pageInfo->drawParams.deviceNColorInks = + (PDPageInk)ASmalloc(pageInfo->drawParams.deviceNColorSize * sizeof(PDPageInkRec)); - // Call PDPageDrawContentsToMemoryWithParams with zeros for the ink information. + // Call PDPageDrawContentsToMemoryWithParams with zeros for the ink information. // This will cause ink information for all inks to be added - PDPageDrawContentsToMemoryWithParams (pageInfo->page, &pageInfo->drawParams); + PDPageDrawContentsToMemoryWithParams(pageInfo->page, &pageInfo->drawParams); - // Call PDPageDrawContentsToMemoryWithParams with a null pointer to the buffer, + // Call PDPageDrawContentsToMemoryWithParams with a null pointer to the buffer, // in order to find the required buffer size - pageInfo->drawParams.bufferSize = PDPageDrawContentsToMemoryWithParams (pageInfo->page, &pageInfo->drawParams); + pageInfo->drawParams.bufferSize = + PDPageDrawContentsToMemoryWithParams(pageInfo->page, &pageInfo->drawParams); // Allocate a buffer of that size - pageInfo->drawParams.buffer = (char *)ASmalloc (pageInfo->drawParams.bufferSize); + pageInfo->drawParams.buffer = (char *)ASmalloc(pageInfo->drawParams.bufferSize); // Actually draw the page into the buffer. - pageInfo->drawParams.bufferSize = PDPageDrawContentsToMemoryWithParams (pageInfo->page, &pageInfo->drawParams); + pageInfo->drawParams.bufferSize = + PDPageDrawContentsToMemoryWithParams(pageInfo->page, &pageInfo->drawParams); - // APDFL will pad each row to an even 32 bit boundary. For this reason, row width may not be equal to - // pixels wide * channels. Calculate the actual width of a row here + // APDFL will pad each row to an even 32 bit boundary. For this reason, row width may not be + // equal to pixels wide * channels. Calculate the actual width of a row here pageInfo->rowWidth = (((pageInfo->cols * pageInfo->numberOfColorants * 8) + 31) / 32) * 4; - // NOTE: We do not here render the DeviceN bitmap to an image. The construction of the DeviceN color space needed to do so - // is quite complex, and for prepartion of printing plates, this is not needed!. If you do wish to directly render this + // NOTE: We do not here render the DeviceN bitmap to an image. The construction of the DeviceN color space needed to do so + // is quite complex, and for prepartion of printing plates, this is not needed!. If you do wish to directly render this // bitmap, in "true colors", see the example "OutputPreview" which contains a sample for creating such color spaces. return; } // Separate out one colorant from a DeviceN bitmap into a single plate. -void WriteSeparationImage (PageInfo *pageInfo, PDDoc outputDoc, int separationNumber) -{ +void WriteSeparationImage(PageInfo *pageInfo, PDDoc outputDoc, int separationNumber) { /* Allocate a buffer to hold the separation image only */ - char *buffer = (char *)ASmalloc (pageInfo->cols * pageInfo->rows); + char *buffer = (char *)ASmalloc(pageInfo->cols * pageInfo->rows); // Separate out just one colorant for (int row = 0; row < pageInfo->rows; row++) for (int col = 0; col < pageInfo->cols; col++) - buffer[(row * pageInfo->cols) + col] = pageInfo->drawParams.buffer[(row * pageInfo->rowWidth) + (col * pageInfo->numberOfColorants) + separationNumber]; - - // Display the colorant name in the page - char *colorantName = (char *)ASAtomGetString (pageInfo->drawParams.deviceNColorInks[separationNumber].colorantName); - - // Normally, we would create plates for printing by using DeviceGray to render the plate. - PDEColorSpace gray = PDEColorSpaceCreateFromName (ASAtomFromString ("DeviceGray")); - AddImageToDoc (pageInfo, outputDoc, gray, buffer, (pageInfo->cols * pageInfo->rows), 1, colorantName, true); - PDERelease ((PDEObject)gray); - ASfree (buffer); - + buffer[(row * pageInfo->cols) + col] = + pageInfo->drawParams.buffer[(row * pageInfo->rowWidth) + (col * pageInfo->numberOfColorants) + separationNumber]; + + // Display the colorant name in the page + char *colorantName = + (char *)ASAtomGetString(pageInfo->drawParams.deviceNColorInks[separationNumber].colorantName); + + // Normally, we would create plates for printing by using DeviceGray to render the plate. + PDEColorSpace gray = PDEColorSpaceCreateFromName(ASAtomFromString("DeviceGray")); + AddImageToDoc(pageInfo, outputDoc, gray, buffer, (pageInfo->cols * pageInfo->rows), 1, colorantName, true); + PDERelease((PDEObject)gray); + ASfree(buffer); } // Add a bitmap to the output document, as a single page, the size of the image, in that document. -void AddImageToDoc (PageInfo *pageInfo, PDDoc outputDoc, PDEColorSpace space, char *buffer, size_t bufferSize, ASInt16 channels, char *Name, ASBool invertColor) -{ - // If the image row size is greater than the packed row size, - // pack the image here. - // Since it will always be smaller than the original image, we can pack it in place +void AddImageToDoc(PageInfo *pageInfo, PDDoc outputDoc, PDEColorSpace space, char *buffer, + size_t bufferSize, ASInt16 channels, const char *Name, ASBool invertColor) { + // If the image row size is greater than the packed row size, + // pack the image here. + // Since it will always be smaller than the original image, we can pack it in place size_t packedRow = pageInfo->cols * channels; - if ((channels > 1) && (packedRow != pageInfo->rowWidth)) - { + if ((channels > 1) && (packedRow != pageInfo->rowWidth)) { for (int row = 1; row < pageInfo->rows; row++) - memmove ((char *)&buffer[row * packedRow], (char *)&buffer[row * pageInfo->rowWidth], packedRow); + memmove((char *)&buffer[row * packedRow], (char *)&buffer[row * pageInfo->rowWidth], packedRow); - //Update image and row width to reflect packing + // Update image and row width to reflect packing bufferSize = packedRow * pageInfo->cols; if (buffer == pageInfo->drawParams.buffer) pageInfo->drawParams.bufferSize = bufferSize; @@ -414,88 +404,84 @@ void AddImageToDoc (PageInfo *pageInfo, PDDoc outputDoc, PDEColorSpace space, ch // Convert the bitmap to a PDEImage PDEImageAttrs attrs; - memset (&attrs, 0, sizeof (attrs)); - attrs.flags = kPDEImageExternal; // Make an XObject image - attrs.height = pageInfo->rows; // Image depth in pixels - attrs.width = pageInfo->cols; // Image width in pixels - attrs.bitsPerComponent = 8; // Bits per channel + memset(&attrs, 0, sizeof(attrs)); + attrs.flags = kPDEImageExternal; // Make an XObject image + attrs.height = pageInfo->rows; // Image depth in pixels + attrs.width = pageInfo->cols; // Image width in pixels + attrs.bitsPerComponent = 8; // Bits per channel - // Normally, separation colors are additive, so "0" is white, and "1" is + // Normally, separation colors are additive, so "0" is white, and "1" is // 100% saturation of the colorant. However, when we display a separation // using DeviceGray, we need to invert this, since DeviceGray is subtractive // We do this here, by manipulating the color decode array - if (invertColor) - { + if (invertColor) { attrs.decode[0] = fixedOne; attrs.decode[1] = 0; attrs.flags |= kPDEImageHaveDecode; } - // If the image is for use internal to this process, we may want to avoid compressing it // If it is for use in a document, then we probably should compress. // If we do not compress, we can omit this block, and use "NULL" for the // pointer to a filter, below PDEFilterArray filterArray; - memset (&filterArray, 0, sizeof (filterArray)); + memset(&filterArray, 0, sizeof(filterArray)); filterArray.numFilters = 1; - filterArray.spec[0].name = ASAtomFromString ("FlateDecode"); + filterArray.spec[0].name = ASAtomFromString("FlateDecode"); - // This matrix is internal to the image. Not neccesarily + // This matrix is internal to the image. Not neccesarily // to its placement. As written here, it places the images // lower left corner at (0, 0), draws the image erect, and // scales it at 1 pixel per point. ASFixedMatrix imageMatrix; - imageMatrix.a = ASInt16ToFixed (attrs.width); - imageMatrix.d = ASInt16ToFixed (attrs.height); + imageMatrix.a = ASInt16ToFixed(attrs.width); + imageMatrix.d = ASInt16ToFixed(attrs.height); imageMatrix.b = imageMatrix.c = 0; imageMatrix.h = 0; imageMatrix.v = 0; // Create the image - PDEImage image = PDEImageCreate (&attrs, sizeof (attrs), - &imageMatrix, 0, space, NULL, &filterArray, 0, - (ASUns8 *)buffer, bufferSize); + PDEImage image = PDEImageCreate(&attrs, sizeof(attrs), &imageMatrix, 0, space, NULL, + &filterArray, 0, (ASUns8 *)buffer, bufferSize); // Create a page to hold the image // The page will be precisely the size of the image. ASFixedRect pageWindow; - pageWindow.left = FloatToASFixed (pageInfo->drawWindow.left); - pageWindow.right = FloatToASFixed (pageInfo->drawWindow.right); - pageWindow.top = FloatToASFixed (pageInfo->drawWindow.top); - pageWindow.bottom = FloatToASFixed (pageInfo->drawWindow.bottom); - PDPage outputPage = PDDocCreatePage (outputDoc, PDDocGetNumPages (outputDoc) - 1, pageWindow); + pageWindow.left = FloatToASFixed(pageInfo->drawWindow.left); + pageWindow.right = FloatToASFixed(pageInfo->drawWindow.right); + pageWindow.top = FloatToASFixed(pageInfo->drawWindow.top); + pageWindow.bottom = FloatToASFixed(pageInfo->drawWindow.bottom); + PDPage outputPage = PDDocCreatePage(outputDoc, PDDocGetNumPages(outputDoc) - 1, pageWindow); // Get the pages content - PDEContent content = PDPageAcquirePDEContent (outputPage, 0); + PDEContent content = PDPageAcquirePDEContent(outputPage, 0); // Add the image to it - PDEContentAddElem (content, 0, (PDEElement)image); + PDEContentAddElem(content, 0, (PDEElement)image); - // Release the image - PDERelease ((PDEObject)image); + // Release the image + PDERelease((PDEObject)image); /* Create the line of text to ID the page */ - PDEText text = PDETextCreate (); - PDETextAddEx (text, kPDETextRun, 0, (ASUns8 *)Name, strlen (Name), pageInfo->textFont, - &pageInfo->textGState, sizeof (PDEGraphicState), - &pageInfo->textTState, sizeof (PDETextState), &pageInfo->textMatrix, NULL); + PDEText text = PDETextCreate(); + PDETextAddEx(text, kPDETextRun, 0, (ASUns8 *)Name, strlen(Name), pageInfo->textFont, + &pageInfo->textGState, sizeof(PDEGraphicState), &pageInfo->textTState, + sizeof(PDETextState), &pageInfo->textMatrix, NULL); - //Add it to the page, over the image - PDEContentAddElem (content, 1, (PDEElement)text); + // Add it to the page, over the image + PDEContentAddElem(content, 1, (PDEElement)text); // Release the text - PDERelease ((PDEObject)text); + PDERelease((PDEObject)text); // Set the content in the page - PDPageSetPDEContent (outputPage, 0); + PDPageSetPDEContent(outputPage, 0); // Release the page content - PDPageReleasePDEContent (outputPage, 0); + PDPageReleasePDEContent(outputPage, 0); // release the page - PDPageRelease (outputPage); + PDPageRelease(outputPage); return; } - diff --git a/CPlusPlus/Sample_Source/Images/FindImageResolutions/FindImageResolutions.cpp b/CPlusPlus/Sample_Source/Images/FindImageResolutions/FindImageResolutions.cpp index ee494e4f..936724e3 100644 --- a/CPlusPlus/Sample_Source/Images/FindImageResolutions/FindImageResolutions.cpp +++ b/CPlusPlus/Sample_Source/Images/FindImageResolutions/FindImageResolutions.cpp @@ -6,7 +6,7 @@ // // This sample creates a list of all of the images found within a PDF document. It also describes where // these images are found and the resolution for each one. The program will rotate any images it finds, -// as needed, to orient the image properly for calculating the resolution. +// as needed, to orient the image properly for calculating the resolution. // // The resolution is calculated for both the vertical and horizontal sides of each image, in Dots per Inch (DPI). // You can enter an input file name on a command line, or use the default input file named in the program. @@ -37,103 +37,93 @@ #include "FindImageResolutions.h" -#define SAMPLE_FILE "FindImageResolutions.pdf" +#define SAMPLE_FILE "FindImageResolutions.pdf" #define OUTPUT_FILE "FindImageResolutions-out.txt" - -int main(int argc, char* argv[]) -{ - APDFLib libInit; //Initialize the Adobe PDF Library. - if (libInit.isValid() == false) //If there was a problem in initialization, return the error code. +int main(int argc, char *argv[]) { + APDFLib libInit; // Initialize the Adobe PDF Library. + if (libInit.isValid() == false) // If there was a problem in initialization, return the error code. { int errCode = libInit.getInitError(); - APDFLib::displayError ( errCode ); + APDFLib::displayError(errCode); return errCode; - } + } // If a file name was specified on the command line, we will process that file. // Without a file name specified, we will produce the canned sample file and process it. - bool fMakeSample ( false); - std::string csInputFile; - if ( argc > 1 ) - { + bool fMakeSample(false); + std::string csInputFile; + if (argc > 1) { csInputFile = argv[1]; - } - else - { + } else { csInputFile = SAMPLE_FILE; fMakeSample = true; } - std::string csOutputFileName ( OUTPUT_FILE ); + std::string csOutputFileName(OUTPUT_FILE); // Step 1: Produce the input file. Optional, used when no input file is entered on the command line. - if ( fMakeSample ) - { + if (fMakeSample) { std::cout << "Producing sample file " << SAMPLE_FILE << std::endl; - if ( MakeSample() ) - { + if (MakeSample()) { std::cout << "Failed creating the sample file." << std::endl; return -1; } } - ImageList imageList; // The list of all images in this document + ImageList imageList; // The list of all images in this document -DURING + DURING - std::cout << "Analyzing file " << csInputFile.c_str() << "; writing results to " - << csOutputFileName.c_str() << std::endl; - APDFLDoc document (csInputFile.c_str(), true); //Open the document to be analyzed + std::cout << "Analyzing file " << csInputFile.c_str() << "; writing results to " + << csOutputFileName.c_str() << std::endl; + APDFLDoc document(csInputFile.c_str(), true); // Open the document to be analyzed - // Step 2: Locate all of the images in the input file by walking the document and saving images and references - for (ASSize_t pageNo = 0; pageNo < document.numPages(); pageNo++) - { - PDPage page = document.getPage (pageNo); // Acquire the page - PDEContent content = PDPageAcquirePDEContent (page, 0); // Acquire the page content + // Step 2: Locate all of the images in the input file by walking the document and saving images and references + for (ASSize_t pageNo = 0; pageNo < document.numPages(); pageNo++) { + PDPage page = document.getPage(pageNo); // Acquire the page + PDEContent content = PDPageAcquirePDEContent(page, 0); // Acquire the page content - ASDoubleMatrix unity = { 1.0, 0, 0, 1.0, 0, 0 }; // Initial matrix is Unity + ASDoubleMatrix unity = {1.0, 0, 0, 1.0, 0, 0}; // Initial matrix is Unity - // This call will find all images on the current page, and add them to the image list - FindImagesInContent (pageNo, content, unity, &imageList, false); + // This call will find all images on the current page, and add them to the image list + FindImagesInContent(pageNo, content, unity, &imageList, false); - PDPageReleasePDEContent (page, 0); // Release the page content - PDPageRelease (page); // Release the page - } + PDPageReleasePDEContent(page, 0); // Release the page content + PDPageRelease(page); // Release the page + } - // Step 3: Output the results - std::ofstream ofs ( csOutputFileName.c_str() ); - ofs << "Processing file " << csInputFile.c_str() << std::endl - << "We found a total of " << imageList.size() << " images, referended " - << std::accumulate ( imageList.begin(), imageList.end(), 0, RefAccumulator() ) << " times\n\n"; - int cnt; - std::vector::const_iterator it, itE = imageList.end(); - for ( cnt = 1, it = imageList.begin(); it != itE; ++it, ++cnt ) - { - ofs << " Image " << cnt << *it; - } + // Step 3: Output the results + std::ofstream ofs(csOutputFileName.c_str()); + ofs << "Processing file " << csInputFile.c_str() << std::endl + << "We found a total of " << imageList.size() << " images, referended " + << std::accumulate(imageList.begin(), imageList.end(), 0, RefAccumulator()) << " times\n\n"; + int cnt; + std::vector::const_iterator it, itE = imageList.end(); + for (cnt = 1, it = imageList.begin(); it != itE; ++it, ++cnt) { + ofs << " Image " << cnt << *it; + } - ReleaseSample(); + ReleaseSample(); -HANDLER - APDFLib::displayError(ERRORCODE); - return ERRORCODE; -END_HANDLER + HANDLER + APDFLib::displayError(ERRORCODE); + return ERRORCODE; + END_HANDLER - return 0; //The APDFL destructor terminates the library. + return 0; // The APDFL destructor terminates the library. } -// This routine calculates the horizontal and vertical resolution of +// This routine calculates the horizontal and vertical resolution of // each reference to each image. Note that different references may have // different effective resolutions. -void CalculateResolution (ImageDef *image, ImageRef *reference) -{ +void CalculateResolution(ImageDef *image, ImageRef *reference) { // Find the resolution of the image as if it had not been rotated. // To that end, the program needs to determine if it is rotated, and create a Matrix // as it would be if the image were not rotated. // Discover the rotation and horizontally, and vertically - double theta1 = atan2 (reference->m_matrix.a, -reference->m_matrix.c); - double theta2 = atan2 (reference->m_matrix.d, reference->m_matrix.b); + double theta1 = atan2(reference->m_matrix.a, -reference->m_matrix.c); + double theta2 = atan2(reference->m_matrix.d, reference->m_matrix.b); // Convert these to degrees, as an aid in understanding the actual angles used. // Note that a 90 degree angle from horizontal to vertical is "erect". @@ -144,15 +134,14 @@ void CalculateResolution (ImageDef *image, ImageRef *reference) if (degrees2 < 0) degrees2 = 360.0 + degrees2; - double shear = fabs (fabs (degrees1) - fabs (degrees2)); + double shear = fabs(fabs(degrees1) - fabs(degrees2)); - reference->m_rotation = (std::max) (degrees1, degrees2); + reference->m_rotation = (std::max)(degrees1, degrees2); reference->m_shear = shear; // m_shear of 180% is most likely a mirroring, in H or V // Subtract shear from angle, and zero shear - if (shear == 180.0) - { + if (shear == 180.0) { reference->m_shear = 0; reference->m_rotation -= 180.0; if (reference->m_rotation < 0) @@ -160,172 +149,154 @@ void CalculateResolution (ImageDef *image, ImageRef *reference) } // "de-rotate" the image matrix - ASDoubleMatrix derotating = { 1, 0, 0, 1, 0, 0 }; - DoubleMatrixRotate (&derotating, -reference->m_rotation); + ASDoubleMatrix derotating = {1, 0, 0, 1, 0, 0}; + DoubleMatrixRotate(&derotating, -reference->m_rotation); ASDoubleMatrix erect; - ASDoubleMatrixConcat (&erect, &reference->m_matrix, &derotating); + ASDoubleMatrixConcat(&erect, &reference->m_matrix, &derotating); // Use the largest of each of the horizontal components to find // horizontal resolution, and of each of the vertical components to find vertical - // resolution. In essence, the program finds the width of any horizontal, 1 pixel, - // "slice" of the image, as it intersects a row of the render media. The same is true - // for a vertical slice as it intersects a column. The program uses absolute values. + // resolution. In essence, the program finds the width of any horizontal, 1 pixel, + // "slice" of the image, as it intersects a row of the render media. The same is true + // for a vertical slice as it intersects a column. The program uses absolute values. // The "direction" the lines are drawn in does not matter. - double hScale = (std::max) (fabs (erect.a), fabs (erect.c)); - double vScale = (std::max) (fabs (erect.d), fabs (erect.b)); - reference->m_hRes = fabs (image->m_width / hScale) * 72.0; - reference->m_vRes = fabs (image->m_depth / vScale) * 72.0; - + double hScale = (std::max)(fabs(erect.a), fabs(erect.c)); + double vScale = (std::max)(fabs(erect.d), fabs(erect.b)); + reference->m_hRes = fabs(image->m_width / hScale) * 72.0; + reference->m_vRes = fabs(image->m_depth / vScale) * 72.0; // Round both resolutions to a whole number - reference->m_hRes = floor (reference->m_hRes + 0.5); - reference->m_vRes = floor (reference->m_vRes + 0.5); + reference->m_hRes = floor(reference->m_hRes + 0.5); + reference->m_vRes = floor(reference->m_vRes + 0.5); return; } // This routine creates an entry in the image list, and/or an existing images reference list. // This also checks for masks on an image, and calls itself recursively to process the mask, if there is one. -void CreateImageEntry (ASSize_t pageNo, PDEImage image, ASDoubleMatrix matrix, ImageList *imageList, ASBool mask, ASBool smask) -{ - ImageDef newImage ( image, mask, smask ); +void CreateImageEntry(ASSize_t pageNo, PDEImage image, ASDoubleMatrix matrix, ImageList *imageList, + ASBool mask, ASBool smask) { + ImageDef newImage(image, mask, smask); // Check if there is a "stencil mask" applied to this image - if (((CosObjGetType (newImage.m_cos_object)) != 0 ) && - (CosDictKnownKeyString (newImage.m_cos_object, "Mask"))) - { - // There is a Mask applied to the image. It may be a "Stencil" mask or a "Chroma" mask. + if (((CosObjGetType(newImage.m_cos_object)) != 0) && (CosDictKnownKeyString(newImage.m_cos_object, "Mask"))) { + // There is a Mask applied to the image. It may be a "Stencil" mask or a "Chroma" mask. // The program disregards a Chroma mask. It will be a stencil if the object is a stream. - CosObj mask = CosDictGetKeyString (newImage.m_cos_object, "Mask"); - if (CosObjGetType (mask) == CosStream) - { - ASFixedMatrix unity = { 1, 0, 0, 1, 0, 0 }; - PDEImage imageMask = PDEImageCreateFromCosObj (&mask, &unity, NULL, NULL); - CreateImageEntry (pageNo, imageMask, matrix, imageList, true, false); - PDERelease ((PDEObject)imageMask); + CosObj mask = CosDictGetKeyString(newImage.m_cos_object, "Mask"); + if (CosObjGetType(mask) == CosStream) { + ASFixedMatrix unity = {1, 0, 0, 1, 0, 0}; + PDEImage imageMask = PDEImageCreateFromCosObj(&mask, &unity, NULL, NULL); + CreateImageEntry(pageNo, imageMask, matrix, imageList, true, false); + PDERelease((PDEObject)imageMask); } } // Check to see if there is a soft mask image - PDEImage softMask = PDEImageGetSMask (image); - if (softMask) - { + PDEImage softMask = PDEImageGetSMask(image); + if (softMask) { // If there is a soft mask, then add it to the image list - CreateImageEntry (pageNo, softMask, matrix, imageList, false, true); - PDERelease ((PDEObject)softMask); + CreateImageEntry(pageNo, softMask, matrix, imageList, false, true); + PDERelease((PDEObject)softMask); } ImageRef newImageRef; - PDEImageGetAttrs (image, &newImageRef.m_attrs, sizeof (PDEImageAttrs)); + PDEImageGetAttrs(image, &newImageRef.m_attrs, sizeof(PDEImageAttrs)); newImageRef.m_matrix = matrix; newImageRef.m_reference = image; newImageRef.m_page = pageNo; - if (newImageRef.m_attrs.flags & kPDEImageExternal) - { + if (newImageRef.m_attrs.flags & kPDEImageExternal) { // This is an XObject image. There may be multiple entries, and there MUST be a CosObj newImage.m_inline = false; - newImage.m_width = CosIntegerValue (CosDictGetKeyString (newImage.m_cos_object, "Width")); - newImage.m_depth = CosIntegerValue (CosDictGetKeyString (newImage.m_cos_object, "Height")); + newImage.m_width = CosIntegerValue(CosDictGetKeyString(newImage.m_cos_object, "Width")); + newImage.m_depth = CosIntegerValue(CosDictGetKeyString(newImage.m_cos_object, "Height")); - CalculateResolution (&newImage, &newImageRef); + CalculateResolution(&newImage, &newImageRef); // Verify if an image entry for this image is present - for (ASSize_t count = 0; count < imageList->size (); count++) - { - if (CosObjEqual (imageList->at(count).m_cos_object, newImage.m_cos_object)) - { - imageList->at(count).m_refs.push_back (newImageRef); + for (ASSize_t count = 0; count < imageList->size(); count++) { + if (CosObjEqual(imageList->at(count).m_cos_object, newImage.m_cos_object)) { + imageList->at(count).m_refs.push_back(newImageRef); return; } } - newImage.m_refs.push_back (newImageRef); - imageList->push_back (newImage); - } - else - { + newImage.m_refs.push_back(newImageRef); + imageList->push_back(newImage); + } else { // This is an InLine image. There may be only a single reference too it, and there is no CosObj. newImage.m_inline = true; - newImage.m_cos_object = CosNewNull (); + newImage.m_cos_object = CosNewNull(); newImage.m_width = newImageRef.m_attrs.width; newImage.m_depth = newImageRef.m_attrs.height; - CalculateResolution (&newImage, &newImageRef); + CalculateResolution(&newImage, &newImageRef); - newImage.m_refs.push_back (newImageRef); - imageList->push_back (newImage); + newImage.m_refs.push_back(newImageRef); + imageList->push_back(newImage); } } // This is a PDE tree walk through a content block. It will always be called with the page content, // and may be recursive to include the contents of elements which are containers. -void FindImagesInContent (ASSize_t pageNumber, PDEContent content, ASDoubleMatrix matrix, ImageList *imageList, ASBool inSoftMask) -{ - for (ASInt32 count = 0; count < PDEContentGetNumElems (content); count++) - { - PDEElement elem = PDEContentGetElem (content, count); +void FindImagesInContent(ASSize_t pageNumber, PDEContent content, ASDoubleMatrix matrix, + ImageList *imageList, ASBool inSoftMask) { + for (ASInt32 count = 0; count < PDEContentGetNumElems(content); count++) { + PDEElement elem = PDEContentGetElem(content, count); // Locate images, and elements that contain contents. - switch (PDEObjectGetType ((PDEObject)elem)) - { - // In the case of a PDEImage, create an image entry. - case kPDEImage: - { - ASDoubleMatrix imageMatrix; - PDEElementGetMatrixEx (elem, &imageMatrix); - ASDoubleMatrixConcat (&imageMatrix, &imageMatrix, &matrix); - CreateImageEntry (pageNumber, (PDEImage)elem, imageMatrix, imageList, false, inSoftMask); - break; - } - - // In the case of a PDEForm, the program parses the forms content, - // concatenating the forms matrix to the current matrix. - case kPDEForm: - { - PDEContent local = PDEFormGetContent ((PDEForm)elem); - ASDoubleMatrix localMatrix; - PDEFormGetMatrixEx ((PDEForm)elem, &localMatrix); - ASDoubleMatrixConcat (&localMatrix, &localMatrix, &matrix); - FindImagesInContent (pageNumber, local, localMatrix, imageList, inSoftMask); - - // PDEFormGetContent "acquires" the content, so it must be - // released. Other elements type that get content do not acquire them. - PDERelease ((PDEObject)local); - break; - } + switch (PDEObjectGetType((PDEObject)elem)) { + // In the case of a PDEImage, create an image entry. + case kPDEImage: { + ASDoubleMatrix imageMatrix; + PDEElementGetMatrixEx(elem, &imageMatrix); + ASDoubleMatrixConcat(&imageMatrix, &imageMatrix, &matrix); + CreateImageEntry(pageNumber, (PDEImage)elem, imageMatrix, imageList, false, inSoftMask); + break; + } - // In the case of a container, the program parses the container content. - // In this case, it does not concatenate the matrices. - case kPDEContainer: - { - PDEContent local = PDEContainerGetContent ((PDEContainer)elem); - FindImagesInContent (pageNumber, local, matrix, imageList, inSoftMask); - break; - } + // In the case of a PDEForm, the program parses the forms content, + // concatenating the forms matrix to the current matrix. + case kPDEForm: { + PDEContent local = PDEFormGetContent((PDEForm)elem); + ASDoubleMatrix localMatrix; + PDEFormGetMatrixEx((PDEForm)elem, &localMatrix); + ASDoubleMatrixConcat(&localMatrix, &localMatrix, &matrix); + FindImagesInContent(pageNumber, local, localMatrix, imageList, inSoftMask); + + // PDEFormGetContent "acquires" the content, so it must be + // released. Other elements type that get content do not acquire them. + PDERelease((PDEObject)local); + break; + } - // In the case of a group, the program parses the group content. - // In this case, it does not concatenate the matrices. - case kPDEGroup: - { - PDEContent local = PDEGroupGetContent ((PDEGroup)elem); - FindImagesInContent (pageNumber, local, matrix, imageList, inSoftMask); - break; - } + // In the case of a container, the program parses the container content. + // In this case, it does not concatenate the matrices. + case kPDEContainer: { + PDEContent local = PDEContainerGetContent((PDEContainer)elem); + FindImagesInContent(pageNumber, local, matrix, imageList, inSoftMask); + break; + } - // All other objects are ignored. - default: - break; + // In the case of a group, the program parses the group content. + // In this case, it does not concatenate the matrices. + case kPDEGroup: { + PDEContent local = PDEGroupGetContent((PDEGroup)elem); + FindImagesInContent(pageNumber, local, matrix, imageList, inSoftMask); + break; + } + // All other objects are ignored. + default: + break; } } } // This is a utility routine to rotate a matrix N degrees counterclockwise -void DoubleMatrixRotate (ASDoubleMatrix *M, ASDouble Angle) -{ - double Ad = Angle; - double Sina, Cosa; - double Ma, Mb, Mc, Md; +void DoubleMatrixRotate(ASDoubleMatrix *M, ASDouble Angle) { + double Ad = Angle; + double Sina, Cosa; + double Ma, Mb, Mc, Md; while (Ad < 0) Ad += 360; @@ -341,8 +312,8 @@ void DoubleMatrixRotate (ASDoubleMatrix *M, ASDouble Angle) Mb = M->b; Mc = M->c; Md = M->d; - Sina = sin (Ad); - Cosa = cos (Ad); + Sina = sin(Ad); + Cosa = cos(Ad); M->a = (Cosa * Ma) + (Sina * Mc); M->b = (Cosa * Mb) + (Sina * Md); diff --git a/CPlusPlus/Sample_Source/Images/OutputPreview/OutputPreview.cpp b/CPlusPlus/Sample_Source/Images/OutputPreview/OutputPreview.cpp index 679203f0..c50e8f9d 100644 --- a/CPlusPlus/Sample_Source/Images/OutputPreview/OutputPreview.cpp +++ b/CPlusPlus/Sample_Source/Images/OutputPreview/OutputPreview.cpp @@ -110,7 +110,7 @@ void WriteCMYKImage(PageInfo *pageInfo, PDDoc outputDoc); void WriteDeviceNImage(PageInfo *pageInfo, PDDoc outputDoc); void WriteSeparationImage(PageInfo *pageInfo, PDDoc outputDoc, int separationNumber); void AddImageToDoc(PageInfo *pageInfo, PDDoc outputDoc, PDEColorSpace color, char *buffer, - size_t bufferSize, ASInt16 channels, char *Name, char *Info = NULL); + size_t bufferSize, ASInt16 channels, const char *Name, const char *Info = NULL); ASBool CollectInkInfo(PDPageInk ink, void *clientData); PDEColorSpace CreateProcessColorSpace(PageInfo *pageInfo, PDPageInk ink); PDEColorSpace CreateSpotColorSpace(PageInfo *pageInfo, PDPageInk ink); @@ -502,7 +502,7 @@ void WriteSeparationImage(PageInfo *pageInfo, PDDoc outputDoc, int separationNum // Add a bitmap to the output document, as a single page, the size of the image, in that document. void AddImageToDoc(PageInfo *pageInfo, PDDoc outputDoc, PDEColorSpace space, char *buffer, - size_t bufferSize, ASInt16 channels, char *Name, char *Info) { + size_t bufferSize, ASInt16 channels, const char *Name, const char *Info) { // If the image row size is greater than the packed row size, // pack the image here. // Since it will always be smaller than the original image, we can pack it in place diff --git a/CPlusPlus/Sample_Source/InformationExtraction/CountColorsInDoc/CountColorsInDoc.cpp b/CPlusPlus/Sample_Source/InformationExtraction/CountColorsInDoc/CountColorsInDoc.cpp index 6db8e107..7ba86d8a 100644 --- a/CPlusPlus/Sample_Source/InformationExtraction/CountColorsInDoc/CountColorsInDoc.cpp +++ b/CPlusPlus/Sample_Source/InformationExtraction/CountColorsInDoc/CountColorsInDoc.cpp @@ -12,9 +12,9 @@ // the PDF document itself. // // This sample demonstrates how to find information in a PDF document, -// and how to access an object within a PDF. -// -// For more detail see the description of the CountColorsInDoc sample program on our Developer’s site, +// and how to access an object within a PDF. +// +// For more detail see the description of the CountColorsInDoc sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#countcolorsindoc #include @@ -25,130 +25,117 @@ #include "PEWCalls.h" #include "PagePDECntCalls.h" -#include "InitializeLibrary.h" -#include "APDFLDoc.h" +#include "InitializeLibrary.h" +#include "APDFLDoc.h" #include "CountColorsInDoc.h" #define INPUT_DIR "../../../../Resources/Sample_Input/" -#define INPUT_FILE "ColorNoColor.pdf" +#define INPUT_FILE "ColorNoColor.pdf" #define OUTPUT_FILE "CountColorsInDoc-out.txt" -int main (int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { // Initialize library - APDFLib libInit; - if (libInit.isValid() == false) - { + APDFLib libInit; + if (libInit.isValid() == false) { ASErrorCode errCode = libInit.getInitError(); - APDFLib::displayError ( errCode ); + APDFLib::displayError(errCode); return errCode; } - std::string csInputFile(argc > 1 ? argv[1] : INPUT_DIR INPUT_FILE ); - std::string csOutputFile(argc > 2 ? argv[2] : OUTPUT_FILE ); + std::string csInputFile(argc > 1 ? argv[1] : INPUT_DIR INPUT_FILE); + std::string csOutputFile(argc > 2 ? argv[2] : OUTPUT_FILE); - std::ofstream ofLog ( csOutputFile.c_str() ); + std::ofstream ofLog(csOutputFile.c_str()); ofLog << "Analyzing file " << csInputFile.c_str() << std::endl; std::cout << "Analyzing file " << csInputFile.c_str() << std::endl; std::cout << "Writing results to " << csOutputFile.c_str() << std::endl; -DURING + DURING - // Open the input document - APDFLDoc apdflDoc ( csInputFile.c_str(), true ); - PDDoc pdDoc = apdflDoc.getPDDoc(); + // Open the input document + APDFLDoc apdflDoc(csInputFile.c_str(), true); + PDDoc pdDoc = apdflDoc.getPDDoc(); - ColorsUsed colorsDoc; + ColorsUsed colorsDoc; - // For each page in the document, walk content, and summarize colors - for (int pageNumb = 0; pageNumb < PDDocGetNumPages (pdDoc); pageNumb++) - { - ColorsUsed colorsPage; + // For each page in the document, walk content, and summarize colors + for (int pageNumb = 0; pageNumb < PDDocGetNumPages(pdDoc); pageNumb++) { + ColorsUsed colorsPage; - PDPage pdPage = PDDocAcquirePage (pdDoc, pageNumb); - PDEContent pdeContent = PDPageAcquirePDEContent (pdPage, 0); + PDPage pdPage = PDDocAcquirePage(pdDoc, pageNumb); + PDEContent pdeContent = PDPageAcquirePDEContent(pdPage, 0); - // Walk the content - WalkPDETree (pdeContent, &colorsPage); - // Logically combine the page data into the document data - colorsDoc |= colorsPage; + // Walk the content + WalkPDETree(pdeContent, &colorsPage); + // Logically combine the page data into the document data + colorsDoc |= colorsPage; - // Release resources - PDPageReleasePDEContent (pdPage, 0); - PDPageRelease (pdPage); + // Release resources + PDPageReleasePDEContent(pdPage, 0); + PDPageRelease(pdPage); - ofLog << "Page " << pageNumb << ": " << colorsPage; - } - ofLog << "Document summary: " << colorsDoc; + ofLog << "Page " << pageNumb << ": " << colorsPage; + } + ofLog << "Document summary: " << colorsDoc; -HANDLER - APDFLib::displayError(ERRORCODE); - return ERRORCODE; -END_HANDLER + HANDLER + APDFLib::displayError(ERRORCODE); + return ERRORCODE; + END_HANDLER return 0; - } // Summarize one PDE Color spec into flags -void MarkColors (PDEColorSpec *color, ColorsUsed *colors) -{ - if (color->value.colorObj) - { +void MarkColors(PDEColorSpec *color, ColorsUsed *colors) { + if (color->value.colorObj) { // This is a patterned color space CosObj patternCOS; - PDEPatternGetCosObj ((PDEPattern)color->value.colorObj, &patternCOS); - ASUns32 type = CosIntegerValue (CosDictGetKeyString (patternCOS, "PatternType")); - if (type == 1) - { + PDEPatternGetCosObj((PDEPattern)color->value.colorObj, &patternCOS); + ASUns32 type = CosIntegerValue(CosDictGetKeyString(patternCOS, "PatternType")); + if (type == 1) { // Tiling pattern colors->hadPattern = true; - ASUns32 paintType = CosIntegerValue (CosDictGetKeyString (patternCOS, "PaintType")); - if (paintType == 1) - { + ASUns32 paintType = CosIntegerValue(CosDictGetKeyString(patternCOS, "PaintType")); + if (paintType == 1) { // A colored pattern needs to be parsed - CosObj resource = CosDictGetKeyString (patternCOS, "Resources"); - PDEContent patternContent = PDEContentCreateFromCosObj (&patternCOS, &resource); - WalkPDETree (patternContent, colors); - PDERelease ((PDEObject)patternContent); + CosObj resource = CosDictGetKeyString(patternCOS, "Resources"); + PDEContent patternContent = PDEContentCreateFromCosObj(&patternCOS, &resource); + WalkPDETree(patternContent, colors); + PDERelease((PDEObject)patternContent); return; } - return; // An uncolored pattern uses the colors already seen - } - else - { + return; // An uncolored pattern uses the colors already seen + } else { // Shading pattern PDEColorSpec shadeSpec; CosObj colorObj; - colorObj = CosDictGet (patternCOS, ASAtomFromString ("ColorSpace")); - memset ((char *)&shadeSpec, 0, sizeof (PDEColorSpec)); - shadeSpec.space = PDEColorSpaceCreateFromCosObj (&colorObj); - MarkColors (&shadeSpec, colors); - PDERelease ((PDEObject)shadeSpec.space); + colorObj = CosDictGet(patternCOS, ASAtomFromString("ColorSpace")); + memset((char *)&shadeSpec, 0, sizeof(PDEColorSpec)); + shadeSpec.space = PDEColorSpaceCreateFromCosObj(&colorObj); + MarkColors(&shadeSpec, colors); + PDERelease((PDEObject)shadeSpec.space); colors->hadShading = true; colors->hadNotGray = true; } - } - else - { + } else { // For any color, find the number of channels and name - ASUns16 channels = PDEColorSpaceGetNumComps (color->space); - ASAtom name = PDEColorSpaceGetName (color->space); + ASUns16 channels = PDEColorSpaceGetNumComps(color->space); + ASAtom name = PDEColorSpaceGetName(color->space); // If the color is indexed, then note it, and get the base color (and number of channels) - if (name == ASAtomFromString ("Indexed")) - { + if (name == ASAtomFromString("Indexed")) { colors->hadIndex = true; - name = PDEColorSpaceGetBase (color->space); - channels = PDEColorSpaceGetBaseNumComps (color->space); + name = PDEColorSpaceGetBase(color->space); + channels = PDEColorSpaceGetBaseNumComps(color->space); } static ColorModels sModels; - + // Find the model of this name, and use it to set flags for what has // been seen. Hold on to it for the flags denoting gray and additive. - const ColorModel& thisColor = sModels.FindModel ( name ); + const ColorModel &thisColor = sModels.FindModel(name); // Mark this color into the summary colors->hadGray |= thisColor.mark.hadGray; colors->hadRGB |= thisColor.mark.hadRGB; @@ -157,32 +144,30 @@ void MarkColors (PDEColorSpec *color, ColorsUsed *colors) colors->hadICC |= thisColor.mark.hadICC; colors->hadDeviceN |= thisColor.mark.hadDeviceN; colors->hadSep |= thisColor.mark.hadSep; - colors->hadCalibrated |=thisColor.mark.hadCalibrated; + colors->hadCalibrated |= thisColor.mark.hadCalibrated; colors->hadUncalibrated |= thisColor.mark.hadUncalibrated; // If this is a gray ink, it will never be colored if (thisColor.neverColored) return; - // Figuring out if a color specified is a color or a shade of gray can be difficult - // when working with ICC, DeviceN, and Separation colors. The program creates a - // single array to hold all color values. - // The program is not designed to write each color channel to an array one color - // at a time, looping through the process until the array is filled. + // Figuring out if a color specified is a color or a shade of gray can be difficult + // when working with ICC, DeviceN, and Separation colors. The program creates a + // single array to hold all color values. + // The program is not designed to write each color channel to an array one color + // at a time, looping through the process until the array is filled. ASFixed colorValue[20]; - if (color->value.colorObj2 && (name == ASAtomFromString("DeviceN"))) - { - // This color is a DeviceN color space. + if (color->value.colorObj2 && (name == ASAtomFromString("DeviceN"))) { + // This color is a DeviceN color space. // Not all deviceN color spaces will use this object, but any of them can. // When it is used, the color per channel values are stored here, instead of // in the array in the color value field. colors->hadDeviceN = true; for (ASUns16 index = 0; index < channels; index++) - colorValue[index] = PDEDeviceNColorsGetColorValue ((PDEDeviceNColors)color->value.colorObj2, index); - } - else - { + colorValue[index] = + PDEDeviceNColorsGetColorValue((PDEDeviceNColors)color->value.colorObj2, index); + } else { for (ASUns16 index = 0; index < channels; index++) colorValue[index] = color->value.color[index]; } @@ -191,12 +176,11 @@ void MarkColors (PDEColorSpec *color, ColorsUsed *colors) if (thisColor.mark.hadCMYK) channels -= 1; - // Program considers any ink drawn as color ink. - // The sample does not look for and ignore DeviceN channels or separation colors - // that contain or draw black or white. + // Program considers any ink drawn as color ink. + // The sample does not look for and ignore DeviceN channels or separation colors + // that contain or draw black or white. // - for (ASUns16 index = 0; index < channels; index++) - { + for (ASUns16 index = 0; index < channels; index++) { if ((thisColor.additive) && (colorValue[index] != 0)) colors->hadNotGray = true; if ((!thisColor.additive) && (colorValue[index] != fixedOne)) @@ -205,111 +189,95 @@ void MarkColors (PDEColorSpec *color, ColorsUsed *colors) } } -// Walk through the elements in one content item -void WalkPDETree (PDEContent content, ColorsUsed *colors) -{ +// Walk through the elements in one content item +void WalkPDETree(PDEContent content, ColorsUsed *colors) { // Get the number of elements in this content element - ASUns16 count = PDEContentGetNumElems (content); + ASUns16 count = PDEContentGetNumElems(content); - for (ASUns16 index = 0; index < count; index++) - { - PDEElement elem = PDEContentGetElem (content, index); - PDEType type = (PDEType)PDEObjectGetType ((PDEObject)elem); - switch (type) - { - case kPDEText: - { - // For a text element, we need to iterate on runs - PDEGraphicState gState; - PDETextState tState; - for (ASUns16 run = 0; run < PDETextGetNumRuns ((PDEText)elem); run++) - { - // Each run may draw text stroked, filled, or both - PDETextGetGState((PDEText)elem, kPDETextRun, run, &gState, sizeof (PDEGraphicState)); - PDETextGetTextState ((PDEText)elem, kPDETextRun, run, &tState, sizeof (PDETextState)); - switch (tState.renderMode) - { - case 0: - case 4: - MarkColors (&gState.fillColorSpec, colors); - break; - case 1: - case 5: - MarkColors (&gState.strokeColorSpec, colors); - break; - case 2: - case 6: - MarkColors (&gState.fillColorSpec, colors); - MarkColors (&gState.strokeColorSpec, colors); - break; - case 3: - case 7: - break; - } - } - } - break; - case kPDEPath: - { - // The path carries its color in the object itself. - // The path may be filled stroked, or both. - PDEGraphicState gState; - PDEElementGetGState (elem, &gState, sizeof (PDEGraphicState)); - ASUns32 op = PDEPathGetPaintOp ((PDEPath)elem); - if (op & kPDEStroke) - MarkColors (&gState.strokeColorSpec, colors); - if (op & (kPDEFill | kPDEEoFill)) - MarkColors (&gState.fillColorSpec, colors); - } - break; - case kPDEImage: - { - PDEColorSpec imageSpec; - PDEImageAttrs attrs; - PDEImageGetAttrs ((PDEImage)elem, &attrs, sizeof (PDEImageAttrs)); - imageSpec.space = PDEImageGetColorSpace ((PDEImage)elem); - if (attrs.flags & kPDEImageIsMask) - PDEImageGetColorValue ((PDEImage)elem, &imageSpec.value); - else - { - // If there is a colored image, presume it is never gray. - // Setting one channel to maximum, and one to minimum, will cover both the - // additive and subtractive cases. - memset (&imageSpec.value, 0, sizeof (PDEColorValue)); - imageSpec.value.color[0] = fixedOne; - imageSpec.value.color[1] = 0; + for (ASUns16 index = 0; index < count; index++) { + PDEElement elem = PDEContentGetElem(content, index); + PDEType type = (PDEType)PDEObjectGetType((PDEObject)elem); + switch (type) { + case kPDEText: { + // For a text element, we need to iterate on runs + PDEGraphicState gState; + PDETextState tState; + for (ASUns16 run = 0; run < PDETextGetNumRuns((PDEText)elem); run++) { + // Each run may draw text stroked, filled, or both + PDETextGetGState((PDEText)elem, kPDETextRun, run, &gState, sizeof(PDEGraphicState)); + PDETextGetTextState((PDEText)elem, kPDETextRun, run, &tState, sizeof(PDETextState)); + switch (tState.renderMode) { + case 0: + case 4: + MarkColors(&gState.fillColorSpec, colors); + break; + case 1: + case 5: + MarkColors(&gState.strokeColorSpec, colors); + break; + case 2: + case 6: + MarkColors(&gState.fillColorSpec, colors); + MarkColors(&gState.strokeColorSpec, colors); + break; + case 3: + case 7: + break; } - MarkColors (&imageSpec, colors); } - break; - case kPDEShading: - { - PDEColorSpec shadeSpec; - CosObj shadeObj, colorObj; - PDEShadingGetCosObj ((PDEShading)elem, &shadeObj); - colorObj = CosDictGet (shadeObj, ASAtomFromString ("ColorSpace")); - memset (&shadeSpec.value, 0, sizeof (PDEColorValue)); - shadeSpec.value.color[0] = fixedOne; - shadeSpec.value.color[1] = 0; - shadeSpec.space = PDEColorSpaceCreateFromCosObj (&colorObj); - MarkColors (&shadeSpec, colors); - PDERelease ((PDEObject)shadeSpec.space); - } - break; - case kPDEForm: - { - // Recurse through the form content - PDEContent content = PDEFormGetContent ((PDEForm)elem); - WalkPDETree (content, colors); - PDERelease ((PDEObject)content); - } - break; - case kPDEContainer: - { - // Recurse through the container content - PDEContent content = PDEContainerGetContent ((PDEContainer)elem); - WalkPDETree (content, colors); + } break; + case kPDEPath: { + // The path carries its color in the object itself. + // The path may be filled stroked, or both. + PDEGraphicState gState; + PDEElementGetGState(elem, &gState, sizeof(PDEGraphicState)); + ASUns32 op = PDEPathGetPaintOp((PDEPath)elem); + if (op & kPDEStroke) + MarkColors(&gState.strokeColorSpec, colors); + if (op & (kPDEFill | kPDEEoFill)) + MarkColors(&gState.fillColorSpec, colors); + } break; + case kPDEImage: { + PDEColorSpec imageSpec; + PDEImageAttrs attrs; + PDEImageGetAttrs((PDEImage)elem, &attrs, sizeof(PDEImageAttrs)); + imageSpec.space = PDEImageGetColorSpace((PDEImage)elem); + if (attrs.flags & kPDEImageIsMask) + PDEImageGetColorValue((PDEImage)elem, &imageSpec.value); + else { + // If there is a colored image, presume it is never gray. + // Setting one channel to maximum, and one to minimum, will cover both the + // additive and subtractive cases. + memset(&imageSpec.value, 0, sizeof(PDEColorValue)); + imageSpec.value.color[0] = fixedOne; + imageSpec.value.color[1] = 0; } + MarkColors(&imageSpec, colors); + } break; + case kPDEShading: { + PDEColorSpec shadeSpec; + CosObj shadeObj, colorObj; + PDEShadingGetCosObj((PDEShading)elem, &shadeObj); + colorObj = CosDictGet(shadeObj, ASAtomFromString("ColorSpace")); + memset(&shadeSpec.value, 0, sizeof(PDEColorValue)); + shadeSpec.value.color[0] = fixedOne; + shadeSpec.value.color[1] = 0; + shadeSpec.space = PDEColorSpaceCreateFromCosObj(&colorObj); + MarkColors(&shadeSpec, colors); + PDERelease((PDEObject)shadeSpec.space); + } break; + case kPDEForm: { + // Recurse through the form content + PDEContent content = PDEFormGetContent((PDEForm)elem); + WalkPDETree(content, colors); + PDERelease((PDEObject)content); + } break; + case kPDEContainer: { + // Recurse through the container content + PDEContent content = PDEContainerGetContent((PDEContainer)elem); + WalkPDETree(content, colors); + } break; + default: break; } } diff --git a/CPlusPlus/Sample_Source/InformationExtraction/CountColorsInDoc/CountColorsInDoc.h b/CPlusPlus/Sample_Source/InformationExtraction/CountColorsInDoc/CountColorsInDoc.h index ec82f71c..849a033b 100644 --- a/CPlusPlus/Sample_Source/InformationExtraction/CountColorsInDoc/CountColorsInDoc.h +++ b/CPlusPlus/Sample_Source/InformationExtraction/CountColorsInDoc/CountColorsInDoc.h @@ -96,7 +96,7 @@ typedef struct colormodel { name = ASAtomFromString(nameStr.c_str()); } - colormodel() : name(NULL), neverColored(false), additive(false) {} + colormodel() : name(0u), neverColored(false), additive(false) {} } ColorModel; struct MyComp { diff --git a/CPlusPlus/Sample_Source/Printing/PDFPrintGUI/PDFPrintGUI.cpp b/CPlusPlus/Sample_Source/Printing/PDFPrintGUI/PDFPrintGUI.cpp index afe9edde..aab80fb8 100644 --- a/CPlusPlus/Sample_Source/Printing/PDFPrintGUI/PDFPrintGUI.cpp +++ b/CPlusPlus/Sample_Source/Printing/PDFPrintGUI/PDFPrintGUI.cpp @@ -2,9 +2,9 @@ // // http://dev.datalogics.com/adobe-pdf-library/license-for-downloaded-pdf-samples/ // -// This sample allows a user to send a PDF document to a printer, using a Windows print interface. +// This sample allows a user to send a PDF document to a printer, using a Windows print interface. // -// For more detail see the description of the PDFPrintGUI sample program on our Developer’s site, +// For more detail see the description of the PDFPrintGUI sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#pdfprintgui /* Printing Support */ @@ -21,13 +21,12 @@ #define defaultDocument "../../../../Resources/Sample_Input/printpdf.pdf" -int main (int argc, char **argv) -{ - APDFLib lib; // Initialize the Adobe PDF Library - ASErrorCode errCode = 0; // This will catch error codes thrown during library usage +int main(int argc, char **argv) { + APDFLib lib; // Initialize the Adobe PDF Library + ASErrorCode errCode = 0; // This will catch error codes thrown during library usage - if (lib.isValid () == false) // If it failed to initialize, return the error code - return lib.getInitError (); + if (lib.isValid() == false) // If it failed to initialize, return the error code + return lib.getInitError(); DURING @@ -38,14 +37,14 @@ int main (int argc, char **argv) // If a file name is not specified on the command line, use the default name if (argc < 2) - strcpy (inPath, defaultDocument); + strcpy(inPath, defaultDocument); else - strcpy (inPath, argv[1]); + strcpy(inPath, argv[1]); std::wcout << L"Opening the input document - " << inPath << std::endl; - APDFLDoc inAPDoc (inPath, true); // Open the input document, repairing it if necessary. - PDDoc inDoc = inAPDoc.getPDDoc (); + APDFLDoc inAPDoc(inPath, true); // Open the input document, repairing it if necessary. + PDDoc inDoc = inAPDoc.getPDDoc(); //===================================================================================================================== // Step 2) Initialize print parameters @@ -55,16 +54,16 @@ int main (int argc, char **argv) // Set defaults (see SetupPrintParams files in Common folder) PDPrintParamsRec psParams; - SetupPDPrintParams (&psParams); + SetupPDPrintParams(&psParams); PDFLPrintUserParamsRec userParams; - SetupPDFLPrintUserParams (&userParams); + SetupPDFLPrintUserParams(&userParams); // Link print params to userParams userParams.printParams = &psParams; // Override defaults with specifics for this sample - userParams.emitToFile = false; // Print to printer + userParams.emitToFile = false; // Print to printer userParams.emitToPrinter = true; //===================================================================================================================== @@ -78,30 +77,28 @@ int main (int argc, char **argv) [NSApplication sharedApplication]; NSPrintPanel *printPanel = [NSPrintPanel printPanel]; - accepted = [printPanel runModalWithPrintInfo: thePrintInfo]; - + accepted = [printPanel runModalWithPrintInfo:thePrintInfo]; userParams.printSession = (PMPrintSession)[thePrintInfo PMPrintSession]; userParams.printSettings = (PMPrintSettings)[thePrintInfo PMPrintSettings]; userParams.pageFormat = (PMPageFormat)[thePrintInfo PMPageFormat]; UInt32 first, last, numCopies; - PMGetFirstPage (userParams.printSettings, &first); + PMGetFirstPage(userParams.printSettings, &first); userParams.startPage = first; - PMGetLastPage (userParams.printSettings, &last); + PMGetLastPage(userParams.printSettings, &last); userParams.endPage = last; - PMGetCopies (userParams.printSettings, &numCopies); + PMGetCopies(userParams.printSettings, &numCopies); userParams.nCopies = numCopies; - if (!accepted) - { - std::wcout << L"Print Canceled by user" <dmSize + devMode->dmDriverExtra); - memcpy (userParams.pDevModeW, devMode, devMode->dmSize + devMode->dmDriverExtra); - GlobalUnlock (printDialog.hDevMode); + LPDEVMODEW devMode = (LPDEVMODEW)(GlobalLock(printDialog.hDevMode)); + userParams.pDevModeW = (DEVMODEW *)malloc(devMode->dmSize + devMode->dmDriverExtra); + memcpy(userParams.pDevModeW, devMode, devMode->dmSize + devMode->dmDriverExtra); + GlobalUnlock(printDialog.hDevMode); // Need to retrieve the printer name from the hDevNames structure. It is also available // in the hDevMode structure but can be truncated due to the dmDeviceName field only // being capable of holding CCHDEVICENAME (32) characters. - LPDEVNAMES devNames = (LPDEVNAMES)(GlobalLock (printDialog.hDevNames)); - std::wstring dmDeviceName ((WCHAR*)(devNames)+devNames->wDeviceOffset); - std::wstring dmFileName ((WCHAR*)(devNames)+devNames->wOutputOffset); - GlobalUnlock (printDialog.hDevNames); + LPDEVNAMES devNames = (LPDEVNAMES)(GlobalLock(printDialog.hDevNames)); + std::wstring dmDeviceName((WCHAR *)(devNames) + devNames->wDeviceOffset); + std::wstring dmFileName((WCHAR *)(devNames) + devNames->wOutputOffset); + GlobalUnlock(printDialog.hDevNames); - size_t lenDeviceName = dmDeviceName.length (); + size_t lenDeviceName = dmDeviceName.length(); userParams.deviceNameW = new ASUns16[lenDeviceName + 1]; - memcpy (userParams.deviceNameW, dmDeviceName.data (), lenDeviceName * sizeof (ASUns16)); + memcpy(userParams.deviceNameW, dmDeviceName.data(), lenDeviceName * sizeof(ASUns16)); userParams.deviceNameW[lenDeviceName] = 0; // Print specific pages if requested in the print dialog box. // Otherwise, the All was left selected and all pages will be printed. - if (printDialog.Flags & PD_PAGENUMS) - { - psParams.ranges[0].startPage = printDialog.nFromPage - 1; // Specify starting page - psParams.ranges[0].endPage = printDialog.nToPage - 1; // Specify ending page + if (printDialog.Flags & PD_PAGENUMS) { + psParams.ranges[0].startPage = printDialog.nFromPage - 1; // Specify starting page + psParams.ranges[0].endPage = printDialog.nToPage - 1; // Specify ending page } // Check to see if "Print to a file" has been selected. @@ -158,26 +153,21 @@ int main (int argc, char **argv) // APDFL parameters such as emitToFile or emitToPrinter. Windows takes care of // prompting for the output file and saves to the file instead of sending it // to the printer. - if (printDialog.Flags & PD_PRINTTOFILE) - { - size_t lenFileName = dmFileName.length (); + if (printDialog.Flags & PD_PRINTTOFILE) { + size_t lenFileName = dmFileName.length(); userParams.outFileNameW = new ASUns16[lenFileName + 1]; - memcpy (userParams.outFileNameW, dmFileName.data (), lenFileName * sizeof (ASUns16)); + memcpy(userParams.outFileNameW, dmFileName.data(), lenFileName * sizeof(ASUns16)); userParams.outFileNameW[lenFileName] = 0; } - userParams.printParams = &psParams; // Connect the two structures + userParams.printParams = &psParams; // Connect the two structures - if (printDialog.Flags & PD_PRINTTOFILE) - { + if (printDialog.Flags & PD_PRINTTOFILE) { std::wcout << L"Sending to the file." << std::endl; - } - else - { + } else { std::wcout << L"Sending to the printer." << std::endl; } - } - else{ - std::wcout << L"Print Canceled by user" <size = sizeof(StdSecurityDataRec); securityData->newUserPW = true; @@ -50,6 +49,8 @@ int main(int argc, char *argv[]) { securityData->perms = pdPrivPermFillandSign | pdPrivPermAccessible; securityData->keyLength = STDSEC_KEYLENGTH_AES256; securityData->encryptMethod = STDSEC_METHOD_AES_V3; + securityData->revision = STDSEC_CryptRevision6; + securityData->version = STDSEC_CryptVersionV5; // Apply security settings PDDocSetNewSecurityData(pdDoc, (void *)securityData); diff --git a/CPlusPlus/Sample_Source/Security/AddPassword/AddPassword.cpp b/CPlusPlus/Sample_Source/Security/AddPassword/AddPassword.cpp index 7deb10ee..1b43eba0 100644 --- a/CPlusPlus/Sample_Source/Security/AddPassword/AddPassword.cpp +++ b/CPlusPlus/Sample_Source/Security/AddPassword/AddPassword.cpp @@ -8,7 +8,7 @@ // // Command-line: (All optional) // -// For more detail see the description of the AddPassword sample program on our Developer’s site, +// For more detail see the description of the AddPassword sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#addpassword #include @@ -20,74 +20,72 @@ #define DEF_OUTPUT "AddPassword-out.pdf" #define DEF_PASSWORD "Datalogics" -int main(int argc, char** argv) -{ +int main(int argc, char **argv) { APDFLib lib; ASErrorCode errCode = 0; - if (lib.isValid() == false) - { + if (lib.isValid() == false) { errCode = lib.getInitError(); std::cout << "Initialization failed with code " << errCode << std::endl; return errCode; } - std::string csInputFileName ( argc > 1 ? argv[1] : INPUT_LOC DEF_INPUT ); - std::string csPassword ( argc > 2 ? argv[2] : DEF_PASSWORD ); - std::string csOutputFileName ( argc > 3 ? argv[3] : DEF_OUTPUT ); - std::cout << "Will apply password \"" << csPassword.c_str() << "\" to " << csInputFileName.c_str() - << " and save as " << csOutputFileName.c_str() << std::endl; + std::string csInputFileName(argc > 1 ? argv[1] : INPUT_LOC DEF_INPUT); + std::string csPassword(argc > 2 ? argv[2] : DEF_PASSWORD); + std::string csOutputFileName(argc > 3 ? argv[3] : DEF_OUTPUT); + std::cout << "Will apply password \"" << csPassword.c_str() << "\" to " + << csInputFileName.c_str() << " and save as " << csOutputFileName.c_str() << std::endl; -DURING + DURING -//Step 1) Open the input document and create a password for it. + // Step 1) Open the input document and create a password for it. - APDFLDoc APDoc ( csInputFileName.c_str(), true); - PDDoc document = APDoc.getPDDoc(); + APDFLDoc APDoc(csInputFileName.c_str(), true); + PDDoc document = APDoc.getPDDoc(); - //This structure will hold the new security data. - PDDocSetNewCryptHandler(document, ASAtomFromString("Standard")); - StdSecurityData securityData = (StdSecurityData)PDDocNewSecurityData(document); - securityData->size = sizeof(StdSecurityDataRec); + // This structure will hold the new security data. + PDDocSetNewCryptHandler(document, ASAtomFromString("Standard")); + StdSecurityData securityData = (StdSecurityData)PDDocNewSecurityData(document); + securityData->size = sizeof(StdSecurityDataRec); - //Set the password needed to open the output file. - securityData->hasUserPW = true; - securityData->newUserPW = true; - strcpy(securityData->userPW, csPassword.c_str()); + // Set the password needed to open the output file. + securityData->hasUserPW = true; + securityData->newUserPW = true; + strcpy(securityData->userPW, csPassword.c_str()); - //Don't add a password to change restrictions once the file is open. - // (See SetUniquePermissions for this behavior.) - securityData->hasOwnerPW = false; + // Don't add a password to change restrictions once the file is open. + // (See SetUniquePermissions for this behavior.) + securityData->hasOwnerPW = false; - //Set the encryption method: - //2 = CF_METHOD_RC4_V2 - RC4 algorithm. - //5 = CF_METHOD_AES_V1 - AES algorithm with a zero initialization vector. - //6 = CF_METHOD_AES_V2 - AES algorithm with a 16 byte random initialization vector. - //7 = CF_METHOD_AES_V3 - AES algorithm with a 4 byte random initialization vector. - securityData->encryptMethod = 2; - securityData->keyLength = 16; - //Either of the following two booleans can be set to true, but not both. It's up to you. - securityData->encryptMetadata = true; - securityData->encryptAttachmentsOnly = false; + // Set the encryption method: + // 2 = CF_METHOD_RC4_V2 - RC4 algorithm. + // 5 = CF_METHOD_AES_V1 - AES algorithm with a zero initialization vector. + // 6 = CF_METHOD_AES_V2 - AES algorithm with a 16 byte random initialization vector. + // 7 = CF_METHOD_AES_V3 - AES algorithm with a 4 byte random initialization vector. + securityData->encryptMethod = 2; + securityData->keyLength = 16; + // Either of the following two booleans can be set to true, but not both. It's up to you. + securityData->encryptMetadata = true; + securityData->encryptAttachmentsOnly = false; - //The user will be able to perform all operations when the file is opened with the password. - securityData->perms = pdPermOwner; + // The user will be able to perform all operations when the file is opened with the password. + securityData->perms = pdPermOwner; -//Step 2) Set the new security data into the document. + // Step 2) Set the new security data into the document. - PDDocSetNewSecurityData(document, (void*)securityData); - ASfree((void*)securityData); + PDDocSetNewSecurityData(document, (void *)securityData); + ASfree((void *)securityData); -//Step 3) Save and close the document. + // Step 3) Save and close the document. - // Changing security permissions requires a full save. APDFLDoc saves with - // PDSaveFull by default, but we are making this explicit! - APDoc.saveDoc ( csOutputFileName.c_str(), PDSaveFull); + // Changing security permissions requires a full save. APDFLDoc saves with + // PDSaveFull by default, but we are making this explicit! + APDoc.saveDoc(csOutputFileName.c_str(), PDSaveFull); -HANDLER - errCode = ERRORCODE; - lib.displayError(errCode); -END_HANDLER + HANDLER + errCode = ERRORCODE; + lib.displayError(errCode); + END_HANDLER return errCode; }; diff --git a/CPlusPlus/Sample_Source/Security/AddRedaction/AddRedaction.cpp b/CPlusPlus/Sample_Source/Security/AddRedaction/AddRedaction.cpp index 6937eefd..c1ef7bcf 100644 --- a/CPlusPlus/Sample_Source/Security/AddRedaction/AddRedaction.cpp +++ b/CPlusPlus/Sample_Source/Security/AddRedaction/AddRedaction.cpp @@ -110,7 +110,7 @@ int main(int argc, char **argv) { redactParams->size = sizeof(PDRedactParamsRec); redactParams->pageNum = 0; // The page that the redaction will be applied to. redactParams->redactQuads = &quadVector.front(); // The vector or array holding the quads. - redactParams->numQuads = quadVector.size(); // The number of entries in the vector or array. + redactParams->numQuads = static_cast(quadVector.size()); // The number of entries in the vector or array. redactParams->colorVal = &cvRec; redactParams->colorVal->space = PDDeviceRGB; // Set device color space to RGB redactParams->colorVal->value[0] = FloatToASFixed(0.0); // The redaction box will be set to black. @@ -126,7 +126,7 @@ int main(int argc, char **argv) { redactParams->textColor = &textCVRec; redactParams->textColor->space = PDDeviceGray; // Draw the overlay text in white redactParams->textColor->value[0] = fixedOne; - redactParams->textFontName = "CourierStd"; // Draw the overlay text using CourierStd font + redactParams->textFontName = const_cast("CourierStd"); // Draw the overlay text using CourierStd font redactParams->textSize = FloatToASFixed(10.0); // Draw the text size as 10 point (nominally, may // be reduced is ScaleToFit is true). redactParams->repeat = true; // Draw the text in each quad, repeating to fill the quad diff --git a/CPlusPlus/Sample_Source/Security/AddTriangularRedaction/AddTriangularRedaction.cpp b/CPlusPlus/Sample_Source/Security/AddTriangularRedaction/AddTriangularRedaction.cpp index 09ec51f0..0570124f 100644 --- a/CPlusPlus/Sample_Source/Security/AddTriangularRedaction/AddTriangularRedaction.cpp +++ b/CPlusPlus/Sample_Source/Security/AddTriangularRedaction/AddTriangularRedaction.cpp @@ -5,7 +5,7 @@ // http://dev.datalogics.com/adobe-pdf-library/license-for-downloaded-pdf-samples/ // // The AddTriangularRedaction sample redacts each page of a document with -// two full-page triangles, leaving only a narrow diagonal strip across each page. +// two full-page triangles, leaving only a narrow diagonal strip across each page. // Text found within the triangular shapes is removed from the document, and gray // redaction triangles are added. // @@ -14,7 +14,6 @@ // For more detail see the description of the AddTriangularRedaction sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples/#addtriangularredaction - #include #include #include @@ -26,13 +25,11 @@ #define DEF_INPUT "AddTriangularRedaction.pdf" #define DEF_OUTPUT "AddTriangularRedaction-out.pdf" -int main(int argc, char** argv) -{ +int main(int argc, char **argv) { ASErrorCode errCode = 0; APDFLib libInit; - if (libInit.isValid() == false) - { + if (libInit.isValid() == false) { errCode = libInit.getInitError(); std::cout << "Initialization failed with code " << errCode << std::endl; return errCode; @@ -40,31 +37,29 @@ int main(int argc, char** argv) std::string csInputFileName(argc > 1 ? argv[1] : INPUT_LOC DEF_INPUT); std::string csOutputFileName(argc > 2 ? argv[2] : DEF_OUTPUT); - std::cout << "Redacting trianglular areas from " << csInputFileName.c_str() - << ", saving to " << csOutputFileName.c_str() << "\n" << std::endl; + std::cout << "Redacting trianglular areas from " << csInputFileName.c_str() << ", saving to " + << csOutputFileName.c_str() << "\n" + << std::endl; DURING APDFLDoc document(csInputFileName.c_str(), true); - // Step 1) Step through each page of the document, and get page width and height // Iterate through each page in the PDDoc - for (ASInt32 pageNum = 0; pageNum < (PDDocGetNumPages(document.getPDDoc())); ++pageNum) - { - PDPage pdPage = document.getPage(pageNum); // Get current page + for (ASInt32 pageNum = 0; pageNum < (PDDocGetNumPages(document.getPDDoc())); ++pageNum) { + PDPage pdPage = document.getPage(pageNum); // Get current page ASFixedRect bounds; - PDPageGetCropBox(pdPage, &bounds); // Get crop box of page + PDPageGetCropBox(pdPage, &bounds); // Get crop box of page - ASFixed pageWidth = bounds.right - bounds.left; // Get page width - ASFixed pageHeight = bounds.top - bounds.bottom; // Get page height - ASFixed stripWidth = fixedSeventyTwo + fixedThree; // Set distance between triangles + ASFixed pageWidth = bounds.right - bounds.left; // Get page width + ASFixed pageHeight = bounds.top - bounds.bottom; // Get page height + ASFixed stripWidth = fixedSeventyTwo + fixedThree; // Set distance between triangles std::wcout << L"Page " << pageNum << std::endl; - - // Step 2) Calculate four quad coordinates to represent each of the two full-page + // Step 2) Calculate four quad coordinates to represent each of the two full-page // triangles, leaving a diagonal strip between them across the middle of the current page std::vector quadVector; @@ -75,68 +70,67 @@ int main(int argc, char** argv) ASFixedPoint topLeft; topLeft.h = bounds.left; topLeft.v = bounds.bottom + pageHeight; - quad.tl = topLeft; // Set first quad's top left coordinate + quad.tl = topLeft; // Set first quad's top left coordinate ASFixedPoint topRight; - topRight.h = bounds.left + pageWidth - stripWidth; // Include offset for space between triangles + topRight.h = bounds.left + pageWidth - stripWidth; // Include offset for space between triangles topRight.v = bounds.bottom + pageHeight; - quad.tr = topRight; // Set first quad's top right coordinate + quad.tr = topRight; // Set first quad's top right coordinate ASFixedPoint bottomRight; bottomRight.h = bounds.left; bottomRight.v = bounds.bottom + stripWidth; - quad.br = bottomRight; // Set first quad's bottom right coordinate + quad.br = bottomRight; // Set first quad's bottom right coordinate ASFixedPoint bottomLeft; - bottomLeft.h = bounds.left; // Use same coordinate for bottomRight, bottomLeft + bottomLeft.h = bounds.left; // Use same coordinate for bottomRight, bottomLeft bottomLeft.v = bounds.bottom + stripWidth; - quad.bl = bottomLeft; // Set first quad's bottom left coordinate - - quadVector.push_back(quad); // Store first quad in vector + quad.bl = bottomLeft; // Set first quad's bottom left coordinate + quadVector.push_back(quad); // Store first quad in vector // Second quad represents triangle covering bottom right of page topLeft.h = bounds.left + pageWidth; topLeft.v = bounds.bottom + pageHeight - stripWidth; - quad.tl = topLeft; // Set second quad's top left coordinate + quad.tl = topLeft; // Set second quad's top left coordinate - topRight.h = bounds.left + pageWidth; // Use same coordinate for topLeft, topRight + topRight.h = bounds.left + pageWidth; // Use same coordinate for topLeft, topRight topRight.v = bounds.bottom + pageHeight - stripWidth; - quad.tr = topRight; // Set second quad's top right coordinate + quad.tr = topRight; // Set second quad's top right coordinate bottomRight.h = bounds.left + pageWidth; bottomRight.v = bounds.bottom; - quad.br = bottomRight; // Set second quad's bottom right coordinate + quad.br = bottomRight; // Set second quad's bottom right coordinate bottomLeft.h = bounds.left + stripWidth; bottomLeft.v = bounds.bottom; - quad.bl = bottomLeft; // Set second quad's bottom left coordinate + quad.bl = bottomLeft; // Set second quad's bottom left coordinate - quadVector.push_back(quad); // Store second quad in vector + quadVector.push_back(quad); // Store second quad in vector - - // Step 3) Create and apply the redactions. The redaction configurations are set, the - // redaction is created and finally applied. + // Step 3) Create and apply the redactions. The redaction configurations are set, the + // redaction is created and finally applied. PDRedactParams redactParams; PDRedactParamsRec rpRec; - memset ((char *)&rpRec, 0, sizeof (PDRedactParamsRec)); + memset((char *)&rpRec, 0, sizeof(PDRedactParamsRec)); redactParams = &rpRec; PDColorValueRec cvRec; redactParams->size = sizeof(PDRedactParamsRec); - redactParams->pageNum = pageNum; // Page that the redaction will be applied to - redactParams->redactQuads = &quadVector.front(); // Vector or array holding the quads - redactParams->numQuads = quadVector.size(); // Number of entries in the vector or array + redactParams->pageNum = pageNum; // Page that the redaction will be applied to + redactParams->redactQuads = &quadVector.front(); // Vector or array holding the quads + redactParams->numQuads = quadVector.size(); // Number of entries in the vector or array redactParams->colorVal = &cvRec; - redactParams->colorVal->space = PDDeviceRGB; // Set device color space to RGB - redactParams->colorVal->value[0] = fixedHalf; // The redaction box will be set to 50% gray + redactParams->colorVal->space = PDDeviceRGB; // Set device color space to RGB + redactParams->colorVal->value[0] = fixedHalf; // The redaction box will be set to 50% gray redactParams->colorVal->value[1] = fixedHalf; redactParams->colorVal->value[2] = fixedHalf; - redactParams->horizAlign = kPDHorizLeft; // Horizontal alignment of the text when generating the redaction mark - redactParams->overlayText = NULL; // Overlay text may be used to replace the underlying content + redactParams->horizAlign = + kPDHorizLeft; // Horizontal alignment of the text when generating the redaction mark + redactParams->overlayText = NULL; // Overlay text may be used to replace the underlying content // Create the redaction annotation. At this point the text HAS NOT been redacted. PDAnnot redactAnnot = PDDocCreateRedaction(document.getPDDoc(), redactParams); @@ -146,17 +140,15 @@ int main(int argc, char** argv) PDDocApplyRedactions(document.getPDDoc(), NULL); std::wcout << L"Words have been permanently removed.\n" << std::endl; - PDPageRelease(pdPage); } - - document.saveDoc(csOutputFileName.c_str(), true); // Save the redacted document + document.saveDoc(csOutputFileName.c_str(), true); // Save the redacted document HANDLER errCode = ERRORCODE; - libInit.displayError(errCode); // If there was an error, display the error that occured + libInit.displayError(errCode); // If there was an error, display the error that occured END_HANDLER - return errCode; // APDFLib's destructor terminates the library + return errCode; // APDFLib's destructor terminates the library } diff --git a/CPlusPlus/Sample_Source/Security/EncryptDocument/EncryptDocument.cpp b/CPlusPlus/Sample_Source/Security/EncryptDocument/EncryptDocument.cpp index 2e277bb8..acdba528 100644 --- a/CPlusPlus/Sample_Source/Security/EncryptDocument/EncryptDocument.cpp +++ b/CPlusPlus/Sample_Source/Security/EncryptDocument/EncryptDocument.cpp @@ -8,7 +8,7 @@ // // Command-line: (Optional) // -// For more detail see the description of the EncryptDocument sample program on our Developer’s site, +// For more detail see the description of the EncryptDocument sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#encryptdocument #include @@ -21,94 +21,86 @@ #define DEF_OUTPUT "EncryptDocument-out.pdf" #define DEF_PW "myPass" -static bool IsDocEncrypted ( PDDoc d ); +static bool IsDocEncrypted(PDDoc d); -int main( int argc, char* argv[] ) -{ +int main(int argc, char *argv[]) { APDFLib libInit; ASErrorCode errCode = 0; - if (libInit.isValid() == false) - { + if (libInit.isValid() == false) { errCode = libInit.getInitError(); std::cout << "Initialization failed with code " << errCode << std::endl; return libInit.getInitError(); } - - std::string csInputFileName ( argc > 1 ? argv[1] : DIR_LOC DEF_INPUT ); - std::string csOutputFileName ( argc > 2 ? argv[2] : DEF_OUTPUT ); - std::string csPassword ( argc > 3 ? argv[3] : DEF_PW ); - std::cout << "Will apply password \"" << csPassword.c_str() << "\" to " - << csInputFileName.c_str() << " and resave as " << csOutputFileName.c_str() << std::endl; - -DURING - -// Step 0) Open input document, repair if damaged, and verify un-encrypted - - APDFLDoc document ( csInputFileName.c_str(), true); - - // Verify it is not encrypted at this time - // Actually, this is not needed, as based on the technique just used to open the document (not - // calling PDDocOpen with a PDAuthProc provided) the above constructor would have raised were - // the document already password encrypted. - // It is included here for contrast against its result at the end of the program. - if ( IsDocEncrypted ( document.pdDoc ) ) - { - std::cout << "Error! Input document seems to already be encrypted!" << std::endl; - return 2; - } - -// Step 1) Create new security data, set with a user password for encryption using the RC4 algorithm. - - // Note: Encrytpion can be set from among 4 different types. - // 2 = CF_METHOD_RC4_V2 - RC4 algorithm. - // 5 = CF_METHOD_AES_V1 - AES algorithm with a zero initialization vector. - // 6 = CF_METHOD_AES_V2 - AES algorithm with a 16 byte random initialization vector. - // 7 = CF_METHOD_AES_V3 - AES algorithm with a 4 byte random initialization vector. - - //Set new security handler. - PDDocSetNewCryptHandler(document.pdDoc, ASAtomFromString("Standard")); - - // Set up the security data record - StdSecurityData securityData = (StdSecurityData)PDDocNewSecurityData(document.pdDoc); - securityData->size = sizeof(StdSecurityDataRec); - securityData->hasUserPW = true; - securityData->newUserPW = true; - strcpy(securityData->userPW, csPassword.c_str()); - securityData->hasOwnerPW = false; - securityData->newOwnerPW = false; - strcpy(securityData->ownerPW, ""); - securityData->perms = pdPermUser; - securityData->keyLength = 16; - securityData->encryptMethod = 2; - -// Step 2) Set the encrptyion method to the document, save and exit - - //Set the security data to the document. - PDDocSetNewSecurityData(document.pdDoc, securityData); - - //Changing the document security requires a full save. - PDDocSetFlags(document.pdDoc, PDDocRequiresFullSave); - - ASfree(securityData); - - // Verify that it is encrypted - document.saveDoc ( csOutputFileName.c_str(), PDSaveFull | PDSaveLinearized); - if ( !IsDocEncrypted ( document.pdDoc ) ) - { - std::cout << "Error! Input document would seem to NOT be encrypted!" << std::endl; - return 2; - } - -HANDLER - errCode = ERRORCODE; - libInit.displayError(errCode); -END_HANDLER - - return errCode; -} -/* static */ bool IsDocEncrypted ( PDDoc d ) -{ - return !(ASAtomNull == PDDocGetNewCryptHandler ( d ) ); + std::string csInputFileName(argc > 1 ? argv[1] : DIR_LOC DEF_INPUT); + std::string csOutputFileName(argc > 2 ? argv[2] : DEF_OUTPUT); + std::string csPassword(argc > 3 ? argv[3] : DEF_PW); + std::cout << "Will apply password \"" << csPassword.c_str() << "\" to " << csInputFileName.c_str() + << " and resave as " << csOutputFileName.c_str() << std::endl; + + DURING + + // Step 0) Open input document, repair if damaged, and verify un-encrypted + + APDFLDoc document(csInputFileName.c_str(), true); + + // Verify it is not encrypted at this time + // Actually, this is not needed, as based on the technique just used to open the document (not + // calling PDDocOpen with a PDAuthProc provided) the above constructor would have raised were + // the document already password encrypted. + // It is included here for contrast against its result at the end of the program. + if (IsDocEncrypted(document.pdDoc)) { + std::cout << "Error! Input document seems to already be encrypted!" << std::endl; + return 2; + } + + // Step 1) Create new security data, set with a user password for encryption using the RC4 algorithm. + + // Note: Encrytpion can be set from among 4 different types. + // 2 = CF_METHOD_RC4_V2 - RC4 algorithm. + // 5 = CF_METHOD_AES_V1 - AES algorithm with a zero initialization vector. + // 6 = CF_METHOD_AES_V2 - AES algorithm with a 16 byte random initialization vector. + // 7 = CF_METHOD_AES_V3 - AES algorithm with a 4 byte random initialization vector. + + // Set new security handler. + PDDocSetNewCryptHandler(document.pdDoc, ASAtomFromString("Standard")); + + // Set up the security data record + StdSecurityData securityData = (StdSecurityData)PDDocNewSecurityData(document.pdDoc); + securityData->size = sizeof(StdSecurityDataRec); + securityData->hasUserPW = true; + securityData->newUserPW = true; + strcpy(securityData->userPW, csPassword.c_str()); + securityData->hasOwnerPW = false; + securityData->newOwnerPW = false; + strcpy(securityData->ownerPW, ""); + securityData->perms = pdPermUser; + securityData->keyLength = 16; + securityData->encryptMethod = 2; + + // Step 2) Set the encrptyion method to the document, save and exit + + // Set the security data to the document. + PDDocSetNewSecurityData(document.pdDoc, securityData); + + // Changing the document security requires a full save. + PDDocSetFlags(document.pdDoc, PDDocRequiresFullSave); + + ASfree(securityData); + + // Verify that it is encrypted + document.saveDoc(csOutputFileName.c_str(), PDSaveFull | PDSaveLinearized); + if (!IsDocEncrypted(document.pdDoc)) { + std::cout << "Error! Input document would seem to NOT be encrypted!" << std::endl; + return 2; + } + + HANDLER + errCode = ERRORCODE; + libInit.displayError(errCode); + END_HANDLER + + return errCode; } +/* static */ bool IsDocEncrypted(PDDoc d) { return !(ASAtomNull == PDDocGetNewCryptHandler(d)); } diff --git a/CPlusPlus/Sample_Source/Security/LockDocument/LockDocument.cpp b/CPlusPlus/Sample_Source/Security/LockDocument/LockDocument.cpp index 633c6c39..be93377b 100644 --- a/CPlusPlus/Sample_Source/Security/LockDocument/LockDocument.cpp +++ b/CPlusPlus/Sample_Source/Security/LockDocument/LockDocument.cpp @@ -8,7 +8,7 @@ // // Command-line: (Both optional) // -// For more detail see the description of the LockDocument sample program on our Developer’s site, +// For more detail see the description of the LockDocument sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#lockdocument #include @@ -19,75 +19,73 @@ #define DEF_INPUT "LockDocument.pdf" #define DEF_OUTPUT "LockDocument-out.pdf" -int main(int argc, char** argv) -{ +int main(int argc, char **argv) { APDFLib libInit; ASErrorCode errCode = 0; - if (libInit.isValid() == false) - { + if (libInit.isValid() == false) { errCode = libInit.getInitError(); std::cout << "Initialization failed with code " << errCode << std::endl; return libInit.getInitError(); } - - std::string csInputFileName ( argc > 1 ? argv[1] : DIR_LOC DEF_INPUT ); - std::string csOutputFileName ( argc > 2 ? argv[2] : DEF_OUTPUT ); + + std::string csInputFileName(argc > 1 ? argv[1] : DIR_LOC DEF_INPUT); + std::string csOutputFileName(argc > 2 ? argv[2] : DEF_OUTPUT); std::cout << "Will apply new security data to " << csInputFileName.c_str() << " and save as " << csOutputFileName.c_str() << std::endl; - //Password to change permissions we will add. Note: cannot be a wide character string. - const char* password = "Datalogics"; + // Password to change permissions we will add. Note: cannot be a wide character string. + const char *password = "Datalogics"; + + DURING -DURING + // Step 1) Open the document, and create new security data for it which will disallow all editing permissions. -// Step 1) Open the document, and create new security data for it which will disallow all editing permissions. + APDFLDoc APDoc(csInputFileName.c_str(), true); + PDDoc document = APDoc.getPDDoc(); - APDFLDoc APDoc ( csInputFileName.c_str(), true ); - PDDoc document = APDoc.getPDDoc(); + // This structure will hold the new security data. + PDDocSetNewCryptHandler(document, ASAtomFromString("Standard")); - //This structure will hold the new security data. - PDDocSetNewCryptHandler(document, ASAtomFromString("Standard")); + // Prepare new security data... + StdSecurityData securityData = (StdSecurityData)PDDocNewSecurityData(document); + securityData->size = sizeof(StdSecurityDataRec); - //Prepare new security data... - StdSecurityData securityData = (StdSecurityData)PDDocNewSecurityData(document); - securityData->size = sizeof(StdSecurityDataRec); + // Do not require a password to open the document. + securityData->hasUserPW = false; - //Do not require a password to open the document. - securityData->hasUserPW = false; + // Specify "owner password", which will be required to change the new permissions of the document + securityData->hasOwnerPW = true; + securityData->newOwnerPW = true; + strcpy(securityData->ownerPW, password); - //Specify "owner password", which will be required to change the new permissions of the document - securityData->hasOwnerPW = true; - securityData->newOwnerPW = true; - strcpy(securityData->ownerPW, password); + // Set the encryption method: + // 2 = CF_METHOD_RC4_V2 - RC4 algorithm. + // 5 = CF_METHOD_AES_V1 - AES algorithm with a zero initialization vector. + // 6 = CF_METHOD_AES_V2 - AES algorithm with a 16 byte random initialization vector. + // 7 = CF_METHOD_AES_V3 - AES algorithm with a 4 byte random initialization vector. + securityData->encryptMethod = 2; + // Encryption key length, in bytes. + securityData->keyLength = 16; + securityData->encryptMetadata = true; + securityData->encryptAttachmentsOnly = false; - //Set the encryption method: - //2 = CF_METHOD_RC4_V2 - RC4 algorithm. - //5 = CF_METHOD_AES_V1 - AES algorithm with a zero initialization vector. - //6 = CF_METHOD_AES_V2 - AES algorithm with a 16 byte random initialization vector. - //7 = CF_METHOD_AES_V3 - AES algorithm with a 4 byte random initialization vector. - securityData->encryptMethod = 2; - //Encryption key length, in bytes. - securityData->keyLength = 16; - securityData->encryptMetadata = true; - securityData->encryptAttachmentsOnly = false; + // No permissions at all will be enabled. + securityData->perms = 0x00000000; - //No permissions at all will be enabled. - securityData->perms = 0x00000000; + // Step 2) Set the new security data into the document. -// Step 2) Set the new security data into the document. + PDDocSetNewSecurityData(document, (void *)securityData); + ASfree((void *)securityData); - PDDocSetNewSecurityData(document, (void*)securityData); - ASfree((void*)securityData); + // Step 3) Save and close the document. -// Step 3) Save and close the document. + // Changing the security of a document requires a full save. APDFLDoc + APDoc.saveDoc(csOutputFileName.c_str(), PDSaveFull); - //Changing the security of a document requires a full save. APDFLDoc - APDoc.saveDoc(csOutputFileName.c_str(), PDSaveFull); - -HANDLER - errCode = ERRORCODE; - libInit.displayError(errCode); -END_HANDLER + HANDLER + errCode = ERRORCODE; + libInit.displayError(errCode); + END_HANDLER return errCode; }; diff --git a/CPlusPlus/Sample_Source/Security/OpenEncrypted/OpenEncrypted.cpp b/CPlusPlus/Sample_Source/Security/OpenEncrypted/OpenEncrypted.cpp index 5636b230..3712ac06 100644 --- a/CPlusPlus/Sample_Source/Security/OpenEncrypted/OpenEncrypted.cpp +++ b/CPlusPlus/Sample_Source/Security/OpenEncrypted/OpenEncrypted.cpp @@ -9,7 +9,7 @@ // // Command-line: (Both optional) // -// For more detail see the description of the OpenEncrypted sample program on our Developer’s site, +// For more detail see the description of the OpenEncrypted sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#openencrypted #include @@ -28,123 +28,116 @@ #define PASSWORD "mypassword" -//Callback function called by PDDocOpenEx to obtain permission to open the document by supplying the password. -static ACCB1 ASBool ACCB2 openAuthorizationProcedure(PDDoc encrypted, void* password); +// Callback function called by PDDocOpenEx to obtain permission to open the document by supplying the password. +static ACCB1 ASBool ACCB2 openAuthorizationProcedure(PDDoc encrypted, void *password); -int main(int argc, char** argv) -{ +int main(int argc, char **argv) { APDFLib libInit; ASErrorCode errCode = 0; - if (libInit.isValid() == false) - { + if (libInit.isValid() == false) { errCode = libInit.getInitError(); std::cout << "Initialization failed with code " << errCode << std::endl; return libInit.getInitError(); } - - std::string csInputFileName ( argc > 1 ? argv[1] : DIR_LOC DEF_INPUT ); - std::string csOutputFileName ( argc > 2 ? argv[2] : DEF_OUTPUT ); + + std::string csInputFileName(argc > 1 ? argv[1] : DIR_LOC DEF_INPUT); + std::string csOutputFileName(argc > 2 ? argv[2] : DEF_OUTPUT); std::cout << "Will remove all security from " << csInputFileName.c_str() << " and save as " << csOutputFileName.c_str() << std::endl; -DURING + DURING -// Step 1) Open the document with the password. + // Step 1) Open the document with the password. - ASPathName inputPathName = APDFLDoc::makePath ( csInputFileName.c_str() ); + ASPathName inputPathName = APDFLDoc::makePath(csInputFileName.c_str()); - //PDDocOpenEx openAuthorizationProcedure to supply the password. - PDDoc document = PDDocOpenEx(inputPathName, ASGetDefaultFileSys(), &openAuthorizationProcedure, 0, true); + // PDDocOpenEx openAuthorizationProcedure to supply the password. + PDDoc document = + PDDocOpenEx(inputPathName, ASGetDefaultFileSys(), &openAuthorizationProcedure, 0, true); - // This can be released at this point - ASFileSysReleasePath(ASGetDefaultFileSys(), inputPathName); + // This can be released at this point + ASFileSysReleasePath(ASGetDefaultFileSys(), inputPathName); -// Step 2) Remove the encryption. + // Step 2) Remove the encryption. - //Setting it to ASAtomNull completely removes security from the document. - PDDocSetNewCryptHandler(document, ASAtomNull); + // Setting it to ASAtomNull completely removes security from the document. + PDDocSetNewCryptHandler(document, ASAtomNull); -// Step 3) Save and close the document. + // Step 3) Save and close the document. - ASPathName pathOutput = APDFLDoc::makePath ( csOutputFileName.c_str() ); - PDDocSave(document, PDDocNeedsSave | PDDocIsOpen, pathOutput, ASGetDefaultFileSys(), NULL, NULL); + ASPathName pathOutput = APDFLDoc::makePath(csOutputFileName.c_str()); + PDDocSave(document, PDDocNeedsSave | PDDocIsOpen, pathOutput, ASGetDefaultFileSys(), NULL, NULL); - //Release resources. - PDDocClose(document); - ASFileSysReleasePath(ASGetDefaultFileSys(), pathOutput); + // Release resources. + PDDocClose(document); + ASFileSysReleasePath(ASGetDefaultFileSys(), pathOutput); -// Step 4) Open it without a password to ensure the encryption is gone. + // Step 4) Open it without a password to ensure the encryption is gone. - ASErrorCode openError = 0; + ASErrorCode openError = 0; -DURING - - // Since this class' default is to open without a password (or authorization proc) this will - // throw instantly if there is a password on the file! - APDFLDoc doc ( csOutputFileName.c_str(), true ); + DURING -HANDLER - openError = ERRORCODE; -END_HANDLER + // Since this class' default is to open without a password (or authorization proc) this will + // throw instantly if there is a password on the file! + APDFLDoc doc(csOutputFileName.c_str(), true); - if (openError) - { - if (ErrGetSystem(openError) == ErrSysPDDoc && ErrGetCode(openError) == pdErrNeedPassword) - { - std::cout << "Error: The document still requires a password ]." << std::endl; - } - else - { - std::cout << "An unexpected error occured." << std::endl; + HANDLER + openError = ERRORCODE; + END_HANDLER + + if (openError) { + if (ErrGetSystem(openError) == ErrSysPDDoc && ErrGetCode(openError) == pdErrNeedPassword) { + std::cout << "Error: The document still requires a password ]." << std::endl; + } else { + std::cout << "An unexpected error occured." << std::endl; + } + return openError; } - return openError; - } -HANDLER - errCode = ERRORCODE; - libInit.displayError(errCode); -END_HANDLER + HANDLER + errCode = ERRORCODE; + libInit.displayError(errCode); + END_HANDLER return errCode; }; // Callback for PDDocOpenEx to obtain permission to open the document by supplying the password. -static ACCB1 ASBool ACCB2 openAuthorizationProcedure(PDDoc encrypted, void *clientData){ +static ACCB1 ASBool ACCB2 openAuthorizationProcedure(PDDoc encrypted, void *clientData) { PDPermReqStatus permReqStatus; -DURING + DURING - //Request open permission by supplying the password. - permReqStatus = PDDocPermRequest(encrypted, //The document we want to open. - PDPermReqObjDoc, //Object of the request: a document. - PDPermReqOprOpen, //Target operation of the request: to open it. - (void*)PASSWORD); //And, of course, the password. + // Request open permission by supplying the password. + permReqStatus = PDDocPermRequest(encrypted, // The document we want to open. + PDPermReqObjDoc, // Object of the request: a document. + PDPermReqOprOpen, // Target operation of the request: to open it. + (void *)PASSWORD); // And, of course, the password. -HANDLER - ASRaise(ERRORCODE); -END_HANDLER + HANDLER + ASRaise(ERRORCODE); + END_HANDLER std::cout << "openAuthorizationProcedure: "; - switch (permReqStatus) - { - case PDPermReqGranted: - std::cout << "Password verified." << std::endl; - break; - case PDPermReqDenied: - std::cout << "Invalid password." << std::endl; - break; - case PDPermReqUnknownObject: - std::cout << "Target object unknown for the permisson request." << std::endl; - break; - case PDPermReqUnknownOperation: - std::cout << "Target operation unknown for the permission request." << std::endl; - break; - default: - std::cout << "An unexpected error occured while trying to open the document." << std::endl; - break; + switch (permReqStatus) { + case PDPermReqGranted: + std::cout << "Password verified." << std::endl; + break; + case PDPermReqDenied: + std::cout << "Invalid password." << std::endl; + break; + case PDPermReqUnknownObject: + std::cout << "Target object unknown for the permisson request." << std::endl; + break; + case PDPermReqUnknownOperation: + std::cout << "Target operation unknown for the permission request." << std::endl; + break; + default: + std::cout << "An unexpected error occured while trying to open the document." << std::endl; + break; } return (permReqStatus == PDPermReqGranted); }; - diff --git a/CPlusPlus/Sample_Source/Security/SetUniquePermissions/SetUniquePermissions.cpp b/CPlusPlus/Sample_Source/Security/SetUniquePermissions/SetUniquePermissions.cpp index 43cda1bf..70c8c4d7 100644 --- a/CPlusPlus/Sample_Source/Security/SetUniquePermissions/SetUniquePermissions.cpp +++ b/CPlusPlus/Sample_Source/Security/SetUniquePermissions/SetUniquePermissions.cpp @@ -8,7 +8,7 @@ // // Command-line: (Both optional) // -// For more detail see the description of the SetUniquePermissions sample program on our Developer’s site, +// For more detail see the description of the SetUniquePermissions sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#setuniquepermissions #include "APDFLDoc.h" @@ -18,137 +18,136 @@ #define DEF_INPUT "SetUniquePermissions.pdf" #define DEF_OUTPUT "SetUniquePermissions-out.pdf" -//To reduce verbosity. -#define PERM_PAIR std::make_pair +// To reduce verbosity. +#define PERM_PAIR std::make_pair -int main(int argc, char** argv) -{ +int main(int argc, char **argv) { APDFLib libInit; ASErrorCode errCode = 0; - if (libInit.isValid() == false) - { + if (libInit.isValid() == false) { errCode = libInit.getInitError(); std::cout << "Initialization failed with code " << errCode << std::endl; return libInit.getInitError(); } - - std::string csInputFileName ( argc > 1 ? argv[1] : DIR_LOC DEF_INPUT ); - std::string csOutputFileName ( argc > 2 ? argv[2] : DEF_OUTPUT ); - std::cout << "Will apply custom security settings to " << csInputFileName.c_str() << " and save as " - << csOutputFileName.c_str() << std::endl; - const char* password = "Datalogics"; + std::string csInputFileName(argc > 1 ? argv[1] : DIR_LOC DEF_INPUT); + std::string csOutputFileName(argc > 2 ? argv[2] : DEF_OUTPUT); + std::cout << "Will apply custom security settings to " << csInputFileName.c_str() + << " and save as " << csOutputFileName.c_str() << std::endl; -// Step 1) Select which permissions you want to allow/deny. + const char *password = "Datalogics"; - std::vector > permList(15); //There are 15 permissions + // Step 1) Select which permissions you want to allow/deny. - //Most Permissions + std::vector > permList(15); // There are 15 permissions - //All permissions, except page extraction. + // Most Permissions + + // All permissions, except page extraction. permList.push_back(PERM_PAIR(false, pdPermAll)); - //All permissions, except page extraction. + // All permissions, except page extraction. permList.push_back(PERM_PAIR(false, pdPermUser)); - //User Editing Permissions - - //Sets these four permissions true: pdPermEdit, pdPermEditNotes, pdPermPrint, pdPermCopy. + // User Editing Permissions + + // Sets these four permissions true: pdPermEdit, pdPermEditNotes, pdPermPrint, pdPermCopy. permList.push_back(PERM_PAIR(false, pdPermSettable)); - //Enables changing the document, document assembly, form field filling, signing, and template page spawning. + // Enables changing the document, document assembly, form field filling, signing, and template page spawning. permList.push_back(PERM_PAIR(false, pdPermEdit)); - //Enables commenting, form field filling, and signing. + // Enables commenting, form field filling, and signing. permList.push_back(PERM_PAIR(false, pdPermEditNotes)); - //Enables page insertion/deletion/rotation, as well as bookmark creation. + // Enables page insertion/deletion/rotation, as well as bookmark creation. permList.push_back(PERM_PAIR(false, pdPrivPermDocAssembly)); - //Enables form field filling, signing, and spawning template pages. + // Enables form field filling, signing, and spawning template pages. permList.push_back(PERM_PAIR(false, pdPrivPermFillandSign)); - //Whether the form can be submitted outside of a browser. Be sure you enable form field filling and signing. + // Whether the form can be submitted outside of a browser. Be sure you enable form field filling and signing. permList.push_back(PERM_PAIR(false, pdPrivPermFormSubmit)); - //Copying + // Copying - //Enables content copying (i.e., to the clipboard) and content copying for accessibility. + // Enables content copying (i.e., to the clipboard) and content copying for accessibility. permList.push_back(PERM_PAIR(false, pdPermCopy)); - //Enables copying of content related to Acrobat's accessibility features for people with disabilities. + // Enables copying of content related to Acrobat's accessibility features for people with disabilities. permList.push_back(PERM_PAIR(false, pdPrivPermAccessible)); - //Printing + // Printing - //Enables printing. + // Enables printing. permList.push_back(PERM_PAIR(false, pdPermPrint)); - // If pdPermPrint is true and this is false, only low quality printing (Print As Image) is allowed. + // If pdPermPrint is true and this is false, only low quality printing (Print As Image) is allowed. // On UNIX platforms where Print As Image doesn't exist, printing will be disabled. permList.push_back(PERM_PAIR(false, pdPrivPermHighPrint)); - //Open/Save - - //The user can open and decrypt the document. This will have no effect if a user password is not set. + // Open/Save + + // The user can open and decrypt the document. This will have no effect if a user password is not set. permList.push_back(PERM_PAIR(false, pdPermOpen)); - //Enables Save As..., with the followng caveats: - // If both pdPermEdit and pdPermEditNotes are disallowed, "Save" will be disabled but - // "Save As" will be enabled. Note that the "Save As" menu item is not necessarily + // Enables Save As..., with the followng caveats: + // If both pdPermEdit and pdPermEditNotes are disallowed, "Save" will be disabled but + // "Save As" will be enabled. Note that the "Save As" menu item is not necessarily // disabled even if this is set to false! permList.push_back(PERM_PAIR(false, pdPermSaveAs)); - //Security + // Security - //The user can change the document's security settings. + // The user can change the document's security settings. // This will have no effect unless an owner password is set. permList.push_back(PERM_PAIR(false, pdPermSecure)); -DURING - - APDFLDoc APDoc ( csInputFileName.c_str(), true); - PDDoc document = APDoc.getPDDoc(); - -// Step 2) Create new security data with the specified permissions. - - // Prepare and create the structure that will hold the new security data. - PDDocSetNewCryptHandler(document, ASAtomFromString("Standard")); - StdSecurityData securityData = (StdSecurityData)PDDocNewSecurityData(document); - securityData->size = sizeof(StdSecurityDataRec); - - //See the sample Encryption for a demonstration of user passwords. - securityData->hasUserPW = false; - - //The permissions of the document will not be able to be changed - // back unless the user supplies this password. - securityData->hasOwnerPW = true; - securityData->newOwnerPW = true; - strcpy(securityData->ownerPW, password); - - //Set the encryption method: - //2 = CF_METHOD_RC4_V2 - RC4 algorithm. - //5 = CF_METHOD_AES_V1 - AES algorithm with a zero initialization vector. - //6 = CF_METHOD_AES_V2 - AES algorithm with a 16 byte random initialization vector. - //7 = CF_METHOD_AES_V3 - AES algorithm with a 4 byte random initialization vector. - securityData->encryptMethod = 2; - securityData->keyLength = 16; //encryption key length in bytes. - securityData->encryptMetadata = true; - securityData->encryptAttachmentsOnly = false; - - //Set the supplied user permissions flags. - securityData->perms = 0x00000000; //First, default to no permissions... - for (int i = 0; i < 15; i++) //Then bitwise OR in all the permissions we paired with true. - { - std::pair x = permList[i]; - if (x.first) securityData->perms |= x.second; - } + DURING + + APDFLDoc APDoc(csInputFileName.c_str(), true); + PDDoc document = APDoc.getPDDoc(); + + // Step 2) Create new security data with the specified permissions. + + // Prepare and create the structure that will hold the new security data. + PDDocSetNewCryptHandler(document, ASAtomFromString("Standard")); + StdSecurityData securityData = (StdSecurityData)PDDocNewSecurityData(document); + securityData->size = sizeof(StdSecurityDataRec); + + // See the sample Encryption for a demonstration of user passwords. + securityData->hasUserPW = false; + + // The permissions of the document will not be able to be changed + // back unless the user supplies this password. + securityData->hasOwnerPW = true; + securityData->newOwnerPW = true; + strcpy(securityData->ownerPW, password); + + // Set the encryption method: + // 2 = CF_METHOD_RC4_V2 - RC4 algorithm. + // 5 = CF_METHOD_AES_V1 - AES algorithm with a zero initialization vector. + // 6 = CF_METHOD_AES_V2 - AES algorithm with a 16 byte random initialization vector. + // 7 = CF_METHOD_AES_V3 - AES algorithm with a 4 byte random initialization vector. + securityData->encryptMethod = 2; + securityData->keyLength = 16; // encryption key length in bytes. + securityData->encryptMetadata = true; + securityData->encryptAttachmentsOnly = false; + + // Set the supplied user permissions flags. + securityData->perms = 0x00000000; // First, default to no permissions... + for (int i = 0; i < 15; i++) // Then bitwise OR in all the permissions we paired with true. + { + std::pair x = permList[i]; + if (x.first) + securityData->perms |= x.second; + } -// Step 3) Set the new security data into the document. + // Step 3) Set the new security data into the document. - PDDocSetNewSecurityData(document, (void*)securityData); - ASfree((void*)securityData); + PDDocSetNewSecurityData(document, (void *)securityData); + ASfree((void *)securityData); -// Step 4) Save and close the document. + // Step 4) Save and close the document. - // Specifying PDSaveFull, even though APDFLDoc would do that by default - APDoc.saveDoc ( csOutputFileName.c_str(), PDSaveFull); + // Specifying PDSaveFull, even though APDFLDoc would do that by default + APDoc.saveDoc(csOutputFileName.c_str(), PDSaveFull); -HANDLER - errCode = ERRORCODE; - libInit.displayError(errCode); -END_HANDLER + HANDLER + errCode = ERRORCODE; + libInit.displayError(errCode); + END_HANDLER return errCode; }; diff --git a/CPlusPlus/Sample_Source/Text/AddText/AddText.cpp b/CPlusPlus/Sample_Source/Text/AddText/AddText.cpp index bff468e6..556e4a57 100644 --- a/CPlusPlus/Sample_Source/Text/AddText/AddText.cpp +++ b/CPlusPlus/Sample_Source/Text/AddText/AddText.cpp @@ -95,7 +95,7 @@ int main(int argc, char **argv) { kPDETextRun, // kPDETextRun/kPDETextChar specify whether a string/character will be inserted. 0, // The index after which to add the character or text run. (Uns8 *)csText.c_str(), // The string that will be added should be type-cast as a pointer to Uns8. - csText.length(), // Length of the string. + static_cast(csText.length()), // Length of the string. pdeFont, // The PDEFont we created above &gState, 0, // PDEGraphicState and its size. ontains graphical attributes of the text object. &tState, 0, // Text state and its size. Contains textual attributes of the text object. diff --git a/CPlusPlus/Sample_Source/Text/ExtractText/ExtractText.cpp b/CPlusPlus/Sample_Source/Text/ExtractText/ExtractText.cpp index 635fe046..44444f41 100644 --- a/CPlusPlus/Sample_Source/Text/ExtractText/ExtractText.cpp +++ b/CPlusPlus/Sample_Source/Text/ExtractText/ExtractText.cpp @@ -9,7 +9,7 @@ // // Command-line: (Both optional) // -// For more detail see the description of the ExtractText sample program on our Developer’s site, +// For more detail see the description of the ExtractText sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#extracttext #include @@ -31,226 +31,214 @@ #define DEF_OUTPUT_1 "ExtractText-out.pdf" #define DEF_OUTPUT_2 "ExtractText-out.txt" -int main(int argc, char** argv) -{ +int main(int argc, char **argv) { APDFLib libInit; ASErrorCode errCode = 0; - if (libInit.isValid() == false) - { + if (libInit.isValid() == false) { errCode = libInit.getInitError(); std::cout << "Initialization failed with code " << errCode << std::endl; return libInit.getInitError(); } - - std::string csInputFileName1 ( argc > 1 ? argv[1] : DIR_LOC DEF_INPUT_1 ); - std::string csInputFileName2 ( argc > 2 ? argv[2] : DIR_LOC DEF_INPUT_2 ); - std::string csOutputFileName1 ( argc > 3 ? argv[3] : DEF_OUTPUT_1 ); - std::string csOutputFileName2 ( argc > 4 ? argv[4] : DEF_OUTPUT_2 ); - -DURING - - APDFLDoc inAPDoc ( csInputFileName1.c_str(), true); - -// Step 1) Initialize the PDWordFinder class and things we'll need to draw the text to the output. - - // Note: This is not the only way to search through text (See the sample AddBookmarks - // for another way), but it is a well-supported way. - - //Prepare the font we'll draw the text with. - PDEFontAttrs fontAttrs; - memset(&fontAttrs, 0, sizeof(fontAttrs)); - fontAttrs.name = ASAtomFromString("CourierStd"); - fontAttrs.type = ASAtomFromString("Type0"); - PDEFont font = PDEFontCreateFromSysFont(PDFindSysFont(&fontAttrs, sizeof(fontAttrs), 0), kPDEFontDoNotEmbed); - - //A default graphics state with which to draw the text. - PDEGraphicState graphics; - PDEDefaultGState(&graphics, sizeof(PDEGraphicState)); - - //This FixedMatrix will point to where each next word will be drawn. - ASFixedMatrix nextWordLocation; - memset(&nextWordLocation, 0, sizeof(nextWordLocation)); - ASInt16 fontSize = 9; - nextWordLocation.a = Int16ToFixed(fontSize); // Character width. - nextWordLocation.d = Int16ToFixed(fontSize); // Character height. - ASFixed leftMargin = ASFloatToFixed(0.5 * 72); - nextWordLocation.h = leftMargin; // Left margin of 1/2 inch (72 pixels per inch) - nextWordLocation.v = ASInt32ToFixed(10 * 72); // Start drawing text 10 inches from the bottom. - - //Use default settings for the PDWordFinder. See the sample TextSearch for an example of PDWordFinder settings. - PDWordFinderConfigRec wfConfig; - memset (&wfConfig, 0, sizeof(PDWordFinderConfigRec)); - wfConfig.recSize = sizeof(PDWordFinderConfigRec); - - //We'll use the PDWordfinder class to iterate through all the words in our input document. - // If boolean value is set to true, the word finder extracts text in unicode. - PDWordFinder wordFinder = PDDocCreateWordFinderEx(inAPDoc.getPDDoc(), WF_LATEST_VERSION, false, &wfConfig); - - PDWord wordList; - ASInt32 numWordsFound; - PDWordFinderAcquireWordList(wordFinder, 0, &wordList, NULL, NULL, &numWordsFound); - -//Step 2) Iterate through each word of the input document and draw each new line of text to the output document. - - std::cout << "Extracting " << numWordsFound << " words on the first page of " << csInputFileName1.c_str() - << " and placing into " << csOutputFileName1.c_str() << std::endl; - - APDFLDoc outAPDoc; - outAPDoc.insertPage(FloatToASFixed(8.5 * 72), Int16ToFixed(11 * 72), PDBeforeFirstPage); - PDPage outPage = outAPDoc.getPage(0); - PDEContent outPageContent = PDPageAcquirePDEContent(outPage, 0); - - for (int i = 0; i < numWordsFound; ++i) - { - PDEText nextLine = PDETextCreate(); - int nextLineIndex = 0; - ASUns16 nextWordAttrs = 0; - - do - { - PDWord nextWord = PDWordFinderGetNthWord(wordFinder, i); - - //We'll copy over the next word of the line using its associated ASText. - ASText nextWordASText = ASTextNew(); - PDWordGetASText(nextWord, 0, nextWordASText); - - // NOTE: Uncomment this paragraph to print the text to the screen as well - // This will print the text in UTF-16BE or in PDFDocEncoding; it may not output correctly on the console. - // It will be correct in the output document, however. - // - // ASInt32 wordLen = 0; - // char* consoleMessage = ASTextGetPDTextCopy(nextWordASText, &wordLen); - // std::cout << consoleMessage; - // ASfree(consoleMessage); - // std::cout << "(Unicode text will not have displayed correctly.)"; - // std::cout << "(But unicode text is printed in the output correctly.)" << std::endl; - // std::cout << "The text has been added to the output document." << std::endl; - - //Append the word to the line. - PDETextAddASText ( nextLine, - kPDETextRun, // It's a text run because it's (usually) multiple characters. - nextLineIndex, - nextWordASText, - font, - &graphics, sizeof(PDEGraphicState), - NULL, 0, - &nextWordLocation); - - //Now that the word's been added, get the new location of the end of the line to prepare to add text there. - ASFixedRect newLocation; - PDETextGetBBox(nextLine, kPDETextRun, PDETextGetNumRuns(nextLine) - 1, &newLocation); - //The h coordinate of our next word will be (at least) the very end of the last word. - nextWordLocation.h = newLocation.right; - - //If the last word we printed is followed by a space, add a little to - //the starting h coordinate of the next word to account for that. - nextWordAttrs = PDWordGetAttr(nextWord); - if (WXE_ADJACENT_TO_SPACE & nextWordAttrs) - { - nextWordLocation.h += ASFloatToFixed(0.5*fontSize); - } - ASTextDestroy(nextWordASText); - - ++nextLineIndex; - ++i; + std::string csInputFileName1(argc > 1 ? argv[1] : DIR_LOC DEF_INPUT_1); + std::string csInputFileName2(argc > 2 ? argv[2] : DIR_LOC DEF_INPUT_2); + std::string csOutputFileName1(argc > 3 ? argv[3] : DEF_OUTPUT_1); + std::string csOutputFileName2(argc > 4 ? argv[4] : DEF_OUTPUT_2); - } while ((!(WXE_LAST_WORD_ON_LINE & nextWordAttrs))); // Note that this procedure works only - // if the last word in the page is the - // last word in its line (which is true). + DURING - --i; // i got overstepped at the end of the do-while loop. + APDFLDoc inAPDoc(csInputFileName1.c_str(), true); - //We've captured the line, so add it to our output page's content. - PDEContentAddElem(outPageContent, kPDEAfterLast, reinterpret_cast(nextLine)); + // Step 1) Initialize the PDWordFinder class and things we'll need to draw the text to the output. - //Prepare to draw the next line. - nextWordLocation.h = leftMargin; - //Drop down the v coordinate just enough to draw new text that won't overlap - nextWordLocation.v -= Int16ToFixed(fontSize); - PDERelease(reinterpret_cast(nextLine)); - } + // Note: This is not the only way to search through text (See the sample AddBookmarks + // for another way), but it is a well-supported way. - //We've now captured every line of text. This sets all the content we've just added into the page. - PDPageSetPDEContentCanRaise(outPage, NULL); + // Prepare the font we'll draw the text with. + PDEFontAttrs fontAttrs; + memset(&fontAttrs, 0, sizeof(fontAttrs)); + fontAttrs.name = ASAtomFromString("CourierStd"); + fontAttrs.type = ASAtomFromString("Type0"); + PDEFont font = PDEFontCreateFromSysFont(PDFindSysFont(&fontAttrs, sizeof(fontAttrs), 0), kPDEFontDoNotEmbed); - PDERelease(reinterpret_cast(font)); - PDWordFinderReleaseWordList(wordFinder, 0); - PDWordFinderDestroy(wordFinder); - - PDPageReleasePDEContent(outPage, NULL); - PDPageRelease(outPage); - outAPDoc.saveDoc( csOutputFileName1.c_str()); + // A default graphics state with which to draw the text. + PDEGraphicState graphics; + PDEDefaultGState(&graphics, sizeof(PDEGraphicState)); -//Step 3) Extract unicode from a second PDF document into a text file + // This FixedMatrix will point to where each next word will be drawn. + ASFixedMatrix nextWordLocation; + memset(&nextWordLocation, 0, sizeof(nextWordLocation)); + ASInt16 fontSize = 9; + nextWordLocation.a = Int16ToFixed(fontSize); // Character width. + nextWordLocation.d = Int16ToFixed(fontSize); // Character height. + ASFixed leftMargin = ASFloatToFixed(0.5 * 72); + nextWordLocation.h = leftMargin; // Left margin of 1/2 inch (72 pixels per inch) + nextWordLocation.v = ASInt32ToFixed(10 * 72); // Start drawing text 10 inches from the bottom. - APDFLDoc document ( csInputFileName2.c_str(), true); + // Use default settings for the PDWordFinder. See the sample TextSearch for an example of PDWordFinder settings. + PDWordFinderConfigRec wfConfig; + memset(&wfConfig, 0, sizeof(PDWordFinderConfigRec)); + wfConfig.recSize = sizeof(PDWordFinderConfigRec); - std::ofstream outputFile ( csOutputFileName2.c_str() ); + // We'll use the PDWordfinder class to iterate through all the words in our input document. + // If boolean value is set to true, the word finder extracts text in unicode. + PDWordFinder wordFinder = + PDDocCreateWordFinderEx(inAPDoc.getPDDoc(), WF_LATEST_VERSION, false, &wfConfig); + + PDWord wordList; + ASInt32 numWordsFound; + PDWordFinderAcquireWordList(wordFinder, 0, &wordList, NULL, NULL, &numWordsFound); + + // Step 2) Iterate through each word of the input document and draw each new line of text to the output document. + + std::cout << "Extracting " << numWordsFound << " words on the first page of " + << csInputFileName1.c_str() << " and placing into " << csOutputFileName1.c_str() + << std::endl; + + APDFLDoc outAPDoc; + outAPDoc.insertPage(FloatToASFixed(8.5 * 72), Int16ToFixed(11 * 72), PDBeforeFirstPage); + PDPage outPage = outAPDoc.getPage(0); + PDEContent outPageContent = PDPageAcquirePDEContent(outPage, 0); + + for (int i = 0; i < numWordsFound; ++i) { + PDEText nextLine = PDETextCreate(); + int nextLineIndex = 0; + ASUns16 nextWordAttrs = 0; + + do { + PDWord nextWord = PDWordFinderGetNthWord(wordFinder, i); + + // We'll copy over the next word of the line using its associated ASText. + ASText nextWordASText = ASTextNew(); + PDWordGetASText(nextWord, 0, nextWordASText); + + // NOTE: Uncomment this paragraph to print the text to the screen as well + // This will print the text in UTF-16BE or in PDFDocEncoding; it may not output correctly on the console. + // It will be correct in the output document, however. + // + // ASInt32 wordLen = 0; + // char* consoleMessage = ASTextGetPDTextCopy(nextWordASText, &wordLen); + // std::cout << consoleMessage; + // ASfree(consoleMessage); + // std::cout << "(Unicode text will not have displayed correctly.)"; + // std::cout << "(But unicode text is printed in the output correctly.)" << std::endl; + // std::cout << "The text has been added to the output document." << std::endl; + + // Append the word to the line. + PDETextAddASText(nextLine, + kPDETextRun, // It's a text run because it's (usually) multiple characters. + nextLineIndex, nextWordASText, font, &graphics, + sizeof(PDEGraphicState), NULL, 0, &nextWordLocation); + + // Now that the word's been added, get the new location of the end of the line to prepare to add text there. + ASFixedRect newLocation; + PDETextGetBBox(nextLine, kPDETextRun, PDETextGetNumRuns(nextLine) - 1, &newLocation); + // The h coordinate of our next word will be (at least) the very end of the last word. + nextWordLocation.h = newLocation.right; + + // If the last word we printed is followed by a space, add a little to + // the starting h coordinate of the next word to account for that. + nextWordAttrs = PDWordGetAttr(nextWord); + if (WXE_ADJACENT_TO_SPACE & nextWordAttrs) { + nextWordLocation.h += ASFloatToFixed(0.5 * fontSize); + } + + ASTextDestroy(nextWordASText); + + ++nextLineIndex; + ++i; + + } while ((!(WXE_LAST_WORD_ON_LINE & nextWordAttrs))); // Note that this procedure works only + // if the last word in the page is the + // last word in its line (which is true). + + --i; // i got overstepped at the end of the do-while loop. + + // We've captured the line, so add it to our output page's content. + PDEContentAddElem(outPageContent, kPDEAfterLast, reinterpret_cast(nextLine)); + + // Prepare to draw the next line. + nextWordLocation.h = leftMargin; + // Drop down the v coordinate just enough to draw new text that won't overlap + nextWordLocation.v -= Int16ToFixed(fontSize); + PDERelease(reinterpret_cast(nextLine)); + } - if (outputFile.is_open()) - { - // Here, we set the boolean value is set to true, in order to extract text in unicode. - PDWordFinder pdWordFinder = PDDocCreateWordFinderEx(document.getPDDoc(), WF_LATEST_VERSION, true, &wfConfig); + // We've now captured every line of text. This sets all the content we've just added into the page. + PDPageSetPDEContentCanRaise(outPage, NULL); - ASInt32 numWords; - PDWord wordArray; - PDWordFinderAcquireWordList(pdWordFinder, 0, &wordArray, NULL, NULL, &numWords); + PDERelease(reinterpret_cast(font)); + PDWordFinderReleaseWordList(wordFinder, 0); + PDWordFinderDestroy(wordFinder); - std::cout << "Extracting " << numWords << " (Unicode) words on the first page of " - << csInputFileName2.c_str() << "; saving to " - << csOutputFileName2.c_str() << std::endl; + PDPageReleasePDEContent(outPage, NULL); + PDPageRelease(outPage); + outAPDoc.saveDoc(csOutputFileName1.c_str()); - PDPage pdPage = document.getPage(0); + // Step 3) Extract unicode from a second PDF document into a text file - for (ASInt32 index = 0; index < numWords; ++index) - { - ASUTF8Val* utf8String; - PDWord pdWord = PDWordFinderGetNthWord(pdWordFinder, index); + APDFLDoc document(csInputFileName2.c_str(), true); - ASText asText = ASTextNew(); - PDWordGetASText(pdWord, 0, asText); + std::ofstream outputFile(csOutputFileName2.c_str()); - //Get the endian neutral utf8 string. - utf8String = reinterpret_cast(ASTextGetUnicodeCopy(asText, kUTF8)); - - ASUns16 wordAttrs = PDWordGetAttr(pdWord); + if (outputFile.is_open()) { + // Here, we set the boolean value is set to true, in order to extract text in unicode. + PDWordFinder pdWordFinder = + PDDocCreateWordFinderEx(document.getPDDoc(), WF_LATEST_VERSION, true, &wfConfig); - outputFile << utf8String; + ASInt32 numWords; + PDWord wordArray; + PDWordFinderAcquireWordList(pdWordFinder, 0, &wordArray, NULL, NULL, &numWords); - if (WXE_ADJACENT_TO_SPACE & wordAttrs) - { - outputFile << " "; - } + std::cout << "Extracting " << numWords << " (Unicode) words on the first page of " + << csInputFileName2.c_str() << "; saving to " << csOutputFileName2.c_str() + << std::endl; - if ((WXE_LAST_WORD_ON_LINE & wordAttrs) == WXE_LAST_WORD_ON_LINE || - PDWordIsLastWordInRegion(pdWord)) - { - outputFile << std::endl; - } + PDPage pdPage = document.getPage(0); - ASTextDestroy(asText); - } + for (ASInt32 index = 0; index < numWords; ++index) { + ASUTF8Val *utf8String; + PDWord pdWord = PDWordFinderGetNthWord(pdWordFinder, index); - //Close any remaining resources. APDFLDoc's destructor will take care of closing the documents. - outputFile.close(); - PDPageReleasePDEContent(pdPage, 0); - PDPageRelease(pdPage); - PDWordFinderReleaseWordList(pdWordFinder, 0); - PDWordFinderDestroy(pdWordFinder); + ASText asText = ASTextNew(); + PDWordGetASText(pdWord, 0, asText); - PDERelease((PDEObject)graphics.fillColorSpec.space); - PDERelease((PDEObject)graphics.strokeColorSpec.space); - } - else - { - std::cout << "Error opening output file." << std::endl; - } + // Get the endian neutral utf8 string. + utf8String = reinterpret_cast(ASTextGetUnicodeCopy(asText, kUTF8)); + + ASUns16 wordAttrs = PDWordGetAttr(pdWord); + + outputFile << utf8String; + + if (WXE_ADJACENT_TO_SPACE & wordAttrs) { + outputFile << " "; + } + + if ((WXE_LAST_WORD_ON_LINE & wordAttrs) == WXE_LAST_WORD_ON_LINE || + PDWordIsLastWordInRegion(pdWord)) { + outputFile << std::endl; + } + + ASTextDestroy(asText); + } + + // Close any remaining resources. APDFLDoc's destructor will take care of closing the documents. + outputFile.close(); + PDPageReleasePDEContent(pdPage, 0); + PDPageRelease(pdPage); + PDWordFinderReleaseWordList(pdWordFinder, 0); + PDWordFinderDestroy(pdWordFinder); + + PDERelease((PDEObject)graphics.fillColorSpec.space); + PDERelease((PDEObject)graphics.strokeColorSpec.space); + } else { + std::cout << "Error opening output file." << std::endl; + } -HANDLER - errCode = ERRORCODE; - libInit.displayError(errCode); -END_HANDLER + HANDLER + errCode = ERRORCODE; + libInit.displayError(errCode); + END_HANDLER return errCode; }; diff --git a/CPlusPlus/Sample_Source/Text/HelloJapan/HelloJapan.cpp b/CPlusPlus/Sample_Source/Text/HelloJapan/HelloJapan.cpp index 71ec81f8..4e1b3192 100644 --- a/CPlusPlus/Sample_Source/Text/HelloJapan/HelloJapan.cpp +++ b/CPlusPlus/Sample_Source/Text/HelloJapan/HelloJapan.cpp @@ -1,6 +1,6 @@ // // Copyright (c) 2004-2017, Datalogics, Inc. All rights reserved. -// +// // For complete copyright information, see: // http://dev.datalogics.com/adobe-pdf-library/adobe-pdf-library-c-language-interface/license-for-downloaded-pdf-samples/ // @@ -12,7 +12,7 @@ // // The files for the fonts used for this sample program are shipped with the Adobe PDF Library, stored in the Resource // directory under APDFL. When the Adobe PDF Library initializes, it loads the files found in the Resource directory. -// +// // For more detail see the description of the HelloJapan sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#hellojapan @@ -24,28 +24,28 @@ #include "APDFLDoc.h" #include "InitializeLibrary.h" -#define DEFAULT_FONT_1 "KozGoPr6N-Medium" -#define DEFAULT_FONT_2 "KozMinPr6N-Regular" +#define DEFAULT_FONT_1 "KozGoPr6N-Medium" +#define DEFAULT_FONT_2 "KozMinPr6N-Regular" #define USE_UTF 1 #define OUTPUT_FILE "HelloJapan-out.pdf" -int main ( int argc, char* argv[] ) -{ - APDFLib libInit; // Initialize the Adobe PDF Library. Termination will be automatic when scope is lost. +int main(int argc, char *argv[]) { + APDFLib libInit; // Initialize the Adobe PDF Library. Termination will be automatic when scope is lost. - if (libInit.isValid() == false) // Check for errors upon initialization. + if (libInit.isValid() == false) // Check for errors upon initialization. { ASErrorCode errCode = libInit.getInitError(); - APDFLib::displayError ( errCode ); + APDFLib::displayError(errCode); return errCode; } - std::string csOutputFile ( argc > 1 ? argv[1] : OUTPUT_FILE ); - std::string csFont1 ( argc > 2 ? argv[2] : DEFAULT_FONT_1 ); - std::string csFont2 ( argc > 3 ? argv[3] : DEFAULT_FONT_2 ); + std::string csOutputFile(argc > 1 ? argv[1] : OUTPUT_FILE); + std::string csFont1(argc > 2 ? argv[2] : DEFAULT_FONT_1); + std::string csFont2(argc > 3 ? argv[3] : DEFAULT_FONT_2); - std::cout << "Using fonts " << csFont1.c_str() << " and " << csFont2.c_str() << ", writing to file " << csOutputFile.c_str() << std::endl; + std::cout << "Using fonts " << csFont1.c_str() << " and " << csFont2.c_str() + << ", writing to file " << csOutputFile.c_str() << std::endl; // When supplying Unicode text to the PDEText API, such as for all Character Map (CMAP) files with // "UCS" in their names, the text must be provided as UTF16 in big endian format (UTF16-BE). @@ -53,114 +53,112 @@ int main ( int argc, char* argv[] ) #if USE_UTF size_t stringLen = 18; - // "Hello [Nihon]." in UTF16-BE - ASUns8 *HelloWorldStr = (ASUns8*)"\x00\x48\x00\x65\x00\x6C\x00\x6C\x00\x6F\x00\x20\x65\xE5\x67\x2c\x00\x2E"; - // H e l l o [sp] [Ni] [Hon] . + // "Hello [Nihon]." in UTF16-BE + ASUns8 *HelloWorldStr = (ASUns8 *)"\x00\x48\x00\x65\x00\x6C\x00\x6C\x00\x6F\x00\x20\x65\xE5\x67" + "\x2c\x00\x2E"; + // H e l l o [sp] [Ni] [Hon] . #else size_t stringLen = 11; - // "Hello [Nihon]." in Shift-JIS - ASUns8 *HelloWorldStr = (ASUns8*)"Hello “ú–{."; + // "Hello [Nihon]." in Shift-JIS + ASUns8 *HelloWorldStr = (ASUns8 *)"Hello “ú–{."; #endif // The first page of the PDF document uses a CIDType0 font (Character ID-based font) // for setting. In this case, the KozGoPr6N-Medium font is used by default. -DURING - PDDoc pdDoc = PDDocCreate(); - ASFixedRect mediaBox; // dimensions of page - mediaBox.left = fixedZero; - mediaBox.top = Int16ToFixed(4*72); - mediaBox.right = Int16ToFixed(5*72); - mediaBox.bottom = fixedZero; - - PDPage pdPage = PDDocCreatePage(pdDoc, PDBeforeFirstPage, mediaBox); - PDEContent pdeContent = PDPageAcquirePDEContent(pdPage, NULL); - - PDEFontAttrs pdeFontAttrs; - memset(&pdeFontAttrs, 0, sizeof(pdeFontAttrs)); - pdeFontAttrs.name = ASAtomFromString ( csFont1.c_str() ); - - PDSysFont sysFont = PDFindSysFont(&pdeFontAttrs, sizeof(PDEFontAttrs), 0); - PDSysEncoding sysEncoding; + DURING + PDDoc pdDoc = PDDocCreate(); + ASFixedRect mediaBox; // dimensions of page + mediaBox.left = fixedZero; + mediaBox.top = Int16ToFixed(4 * 72); + mediaBox.right = Int16ToFixed(5 * 72); + mediaBox.bottom = fixedZero; + + PDPage pdPage = PDDocCreatePage(pdDoc, PDBeforeFirstPage, mediaBox); + PDEContent pdeContent = PDPageAcquirePDEContent(pdPage, NULL); + + PDEFontAttrs pdeFontAttrs; + memset(&pdeFontAttrs, 0, sizeof(pdeFontAttrs)); + pdeFontAttrs.name = ASAtomFromString(csFont1.c_str()); + + PDSysFont sysFont = PDFindSysFont(&pdeFontAttrs, sizeof(PDEFontAttrs), 0); + PDSysEncoding sysEncoding; #if USE_UTF - sysEncoding = PDSysEncodingCreateFromCMapName(ASAtomFromString("UniJIS-UTF16-H")); + sysEncoding = PDSysEncodingCreateFromCMapName(ASAtomFromString("UniJIS-UTF16-H")); #else - sysEncoding = PDSysEncodingCreateFromCMapName(ASAtomFromString("90msp-RKSJ-H")); + sysEncoding = PDSysEncodingCreateFromCMapName(ASAtomFromString("90msp-RKSJ-H")); #endif - PDEFont pdeFont = PDEFontCreateFromSysFontAndEncoding ( sysFont, sysEncoding, pdeFontAttrs.name, - kPDEFontCreateEmbedded | kPDEFontCreateSubset); - - PDEGraphicState gState; // graphic state to apply to operation - PDEDefaultGState ( &gState, sizeof(PDEGraphicState) ); - - // transformation matrix for text: - ASFixedMatrix textMatrix = { 24 * fixedOne, fixedZero, fixedZero, 24 * fixedOne, fixedSeventyTwo, 2 * fixedSeventyTwo }; - PDEText pdeText = PDETextCreate(); - PDETextAdd ( pdeText, kPDETextRun, 0, HelloWorldStr, stringLen, - pdeFont, &gState, sizeof(gState), NULL, 0, &textMatrix, NULL); - PDEContentAddElem(pdeContent, kPDEAfterLast, (PDEElement) pdeText); - PDPageSetPDEContent(pdPage, NULL); - - // For subsetted Type0 fonts, signal to the PDF Library that all the characters - // needed have been placed into PDEText areas. This allows APDFL to create the - // subset font stream. - PDEFontSubsetNow(pdeFont, PDDocGetCosDoc(pdDoc)); - PDERelease((PDEObject) pdeFont); - PDERelease((PDEObject) pdeText); - PDPageReleasePDEContent(pdPage, NULL); - PDPageRelease(pdPage); - PDERelease((PDEObject)sysEncoding); - - // The second page of the document uses a different font, - // KozMinPr6N-Regular. This is a CIDType2 font, or a glyph ID-based font. - pdPage = PDDocCreatePage(pdDoc, PDDocGetNumPages(pdDoc)-1, mediaBox); - pdeContent = PDPageAcquirePDEContent(pdPage, NULL); - memset(&pdeFontAttrs, 0, sizeof(pdeFontAttrs)); - pdeFontAttrs.name = ASAtomFromString( csFont2.c_str() ); - sysFont = PDFindSysFont(&pdeFontAttrs, sizeof(PDEFontAttrs), 0); + PDEFont pdeFont = PDEFontCreateFromSysFontAndEncoding( + sysFont, sysEncoding, pdeFontAttrs.name, kPDEFontCreateEmbedded | kPDEFontCreateSubset); + + PDEGraphicState gState; // graphic state to apply to operation + PDEDefaultGState(&gState, sizeof(PDEGraphicState)); + + // transformation matrix for text: + ASFixedMatrix textMatrix = {24 * fixedOne, fixedZero, fixedZero, + 24 * fixedOne, fixedSeventyTwo, 2 * fixedSeventyTwo}; + PDEText pdeText = PDETextCreate(); + PDETextAdd(pdeText, kPDETextRun, 0, HelloWorldStr, stringLen, pdeFont, &gState, + sizeof(gState), NULL, 0, &textMatrix, NULL); + PDEContentAddElem(pdeContent, kPDEAfterLast, (PDEElement)pdeText); + PDPageSetPDEContent(pdPage, NULL); + + // For subsetted Type0 fonts, signal to the PDF Library that all the characters + // needed have been placed into PDEText areas. This allows APDFL to create the + // subset font stream. + PDEFontSubsetNow(pdeFont, PDDocGetCosDoc(pdDoc)); + PDERelease((PDEObject)pdeFont); + PDERelease((PDEObject)pdeText); + PDPageReleasePDEContent(pdPage, NULL); + PDPageRelease(pdPage); + PDERelease((PDEObject)sysEncoding); + + // The second page of the document uses a different font, + // KozMinPr6N-Regular. This is a CIDType2 font, or a glyph ID-based font. + pdPage = PDDocCreatePage(pdDoc, PDDocGetNumPages(pdDoc) - 1, mediaBox); + pdeContent = PDPageAcquirePDEContent(pdPage, NULL); + memset(&pdeFontAttrs, 0, sizeof(pdeFontAttrs)); + pdeFontAttrs.name = ASAtomFromString(csFont2.c_str()); + sysFont = PDFindSysFont(&pdeFontAttrs, sizeof(PDEFontAttrs), 0); #if USE_UTF - sysEncoding = PDSysEncodingCreateFromCMapName(ASAtomFromString("UniJIS-UTF16-H")); + sysEncoding = PDSysEncodingCreateFromCMapName(ASAtomFromString("UniJIS-UTF16-H")); #else - sysEncoding = PDSysEncodingCreateFromCMapName(ASAtomFromString("90msp-RKSJ-H")); + sysEncoding = PDSysEncodingCreateFromCMapName(ASAtomFromString("90msp-RKSJ-H")); #endif - pdeFont = PDEFontCreateFromSysFontAndEncoding ( sysFont, sysEncoding, pdeFontAttrs.name, - kPDEFontCreateEmbedded | kPDEFontCreateSubset); - - textMatrix.b = textMatrix.c = 0; - textMatrix.a = Int32ToFixed(24); - textMatrix.d = Int32ToFixed(24); - textMatrix.h = Int32ToFixed(1*72); - textMatrix.v = Int32ToFixed(2*72); - pdeText = PDETextCreate(); - PDETextAdd ( pdeText, kPDETextRun, 0, HelloWorldStr, stringLen, - pdeFont, &gState, sizeof(gState), NULL, 0, &textMatrix, NULL); - PDEContentAddElem(pdeContent, kPDEAfterLast, (PDEElement) pdeText); - PDPageSetPDEContent(pdPage, NULL); - - // For subsetted Type0 fonts, signal to the PDF Library that all the characters - // needed have been placed into PDEText areas. This allows APDFL to create the - // subset font stream. - PDEFontSubsetNow(pdeFont, PDDocGetCosDoc(pdDoc)); - PDERelease((PDEObject) pdeFont); - PDERelease((PDEObject) pdeText); - PDPageReleasePDEContent(pdPage, NULL); - PDPageRelease(pdPage); - PDERelease((PDEObject)gState.strokeColorSpec.space ); - PDERelease((PDEObject)gState.fillColorSpec.space ); - PDERelease((PDEObject)sysEncoding); - - ASPathName outPath = APDFLDoc::makePath ( csOutputFile.c_str() ); - PDDocSave(pdDoc, PDSaveFull | PDSaveLinearized, outPath, ASGetDefaultFileSys(), NULL, NULL); - ASFileSysReleasePath( NULL, outPath); - PDDocClose(pdDoc); - -HANDLER - APDFLib::displayError ( ERRORCODE ); - return ERRORCODE; -END_HANDLER + pdeFont = PDEFontCreateFromSysFontAndEncoding(sysFont, sysEncoding, pdeFontAttrs.name, + kPDEFontCreateEmbedded | kPDEFontCreateSubset); + + textMatrix.b = textMatrix.c = 0; + textMatrix.a = Int32ToFixed(24); + textMatrix.d = Int32ToFixed(24); + textMatrix.h = Int32ToFixed(1 * 72); + textMatrix.v = Int32ToFixed(2 * 72); + pdeText = PDETextCreate(); + PDETextAdd(pdeText, kPDETextRun, 0, HelloWorldStr, stringLen, pdeFont, &gState, + sizeof(gState), NULL, 0, &textMatrix, NULL); + PDEContentAddElem(pdeContent, kPDEAfterLast, (PDEElement)pdeText); + PDPageSetPDEContent(pdPage, NULL); + + // For subsetted Type0 fonts, signal to the PDF Library that all the characters + // needed have been placed into PDEText areas. This allows APDFL to create the + // subset font stream. + PDEFontSubsetNow(pdeFont, PDDocGetCosDoc(pdDoc)); + PDERelease((PDEObject)pdeFont); + PDERelease((PDEObject)pdeText); + PDPageReleasePDEContent(pdPage, NULL); + PDPageRelease(pdPage); + PDERelease((PDEObject)gState.strokeColorSpec.space); + PDERelease((PDEObject)gState.fillColorSpec.space); + PDERelease((PDEObject)sysEncoding); + + ASPathName outPath = APDFLDoc::makePath(csOutputFile.c_str()); + PDDocSave(pdDoc, PDSaveFull | PDSaveLinearized, outPath, ASGetDefaultFileSys(), NULL, NULL); + ASFileSysReleasePath(NULL, outPath); + PDDocClose(pdDoc); + + HANDLER + APDFLib::displayError(ERRORCODE); + return ERRORCODE; + END_HANDLER return 0; - } - - - diff --git a/CPlusPlus/Sample_Source/Text/InsertHeadFoot/InsertHeadFoot.cpp b/CPlusPlus/Sample_Source/Text/InsertHeadFoot/InsertHeadFoot.cpp index f04bf444..d2ce187d 100644 --- a/CPlusPlus/Sample_Source/Text/InsertHeadFoot/InsertHeadFoot.cpp +++ b/CPlusPlus/Sample_Source/Text/InsertHeadFoot/InsertHeadFoot.cpp @@ -4,10 +4,10 @@ // For complete copyright information, see: // http://dev.datalogics.com/adobe-pdf-library/adobe-pdf-library-c-language-interface/license-for-downloaded-pdf-samples/ // -// This sample reads an input PDF document and inserts text for a header and for a footer on each page. The program adjusts +// This sample reads an input PDF document and inserts text for a header and for a footer on each page. The program adjusts // the contents of each page if necessary to make sure that the header and footer will fit. It also provides default text // for the header and footer, and then saves the PDF as an output file. InsertHeadFoot does not work with rotated pages. -// +// // The font used for the text in the header and footer is defined in DEF_FONT and DEF_CHARSET, and the point size for the // text for the header and footer is also set. You can name any font you like, but keep in mind that the program must be able // to find this font stored on the system where it is run. The program queries the local environment to see if the default font @@ -15,29 +15,28 @@ // // The program is also designed to encrypt the output file so that the header and footer cannot be removed or edited without a password. // -// For more detail see the description of the InsertHeadFoot sample program on our Developer’s site, +// For more detail see the description of the InsertHeadFoot sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#insertheadfoot #ifdef WIN32 // Avoid compiler warning. This is a sample program. -#pragma warning(disable:4267) +#pragma warning(disable : 4267) #endif - #include #include #include -#include "CosCalls.h" -#include "PEWCalls.h" -#include "PERCalls.h" -#include "PSFCalls.h" +#include "CosCalls.h" +#include "PEWCalls.h" +#include "PERCalls.h" +#include "PSFCalls.h" #include "InitializeLibrary.h" #include "APDFLDoc.h" #include "InsertHeadFoot.h" -#define INPUT_DIR "../../../../Resources/Sample_Input/" +#define INPUT_DIR "../../../../Resources/Sample_Input/" #define INPUT_FILE "CopyContent.pdf" #define OUTPUT_FILE "InsertHeadFoot-out.pdf" @@ -46,252 +45,229 @@ #define HeadPointSize 32 #define FootPointSize 12 -const char* Heading = "A Security Heading"; -const char* Footing = "Some security footing text, Smaller than the head."; +const char *Heading = "A Security Heading"; +const char *Footing = "Some security footing text, Smaller than the head."; -int main (int argc, char *argv[]) -{ - APDFLib libInit; // Initialize the library - if (libInit.isValid() == false) - { +int main(int argc, char *argv[]) { + APDFLib libInit; // Initialize the library + if (libInit.isValid() == false) { ASErrorCode errCode = libInit.getInitError(); - APDFLib::displayError ( errCode ); + APDFLib::displayError(errCode); return errCode; } // Verify that the default font named in the program is found on the local system and load it. - // The font name and character set name are drawn from HEADFOOT_FONT and HEADFOOT_CHARSET. - // If these are valid environment variables on the local system, the program will use that local font - // and character set. - // Otherwise, the program will use the font "CourierStd" and character set "Roman" defined above, - // under DEF_FONT and DEF_CHARSET. - char* ep = std::getenv("HEADFOOT_FONT"); - std::string csFontName ( ep ? ep : DEF_FONT ); + // The font name and character set name are drawn from HEADFOOT_FONT and HEADFOOT_CHARSET. + // If these are valid environment variables on the local system, the program will use that local + // font and character set. Otherwise, the program will use the font "CourierStd" and character + // set "Roman" defined above, under DEF_FONT and DEF_CHARSET. + char *ep = std::getenv("HEADFOOT_FONT"); + std::string csFontName(ep ? ep : DEF_FONT); ep = std::getenv("HEADFOOT_CHARSET"); - std::string csCharSet ( ep ? ep : DEF_CHARSET ); + std::string csCharSet(ep ? ep : DEF_CHARSET); PDEFontAttrs pdFontAttr; - memset (&pdFontAttr, 0, sizeof (pdFontAttr)); - pdFontAttr.name = ASAtomFromString (csFontName.c_str()); - pdFontAttr.charSet = ASAtomFromString (csCharSet.c_str()); - PDSysFont gSysFont = PDFindSysFont (&pdFontAttr, sizeof (pdFontAttr), kPDSysFontMatchNameAndCharSet); - if ( NULL == gSysFont ) - { - std::cout << "Couldn't find font " << csFontName.c_str() << " (charset " << - csCharSet.c_str() << ") on this system. Try requesting a different font" << std::endl; + memset(&pdFontAttr, 0, sizeof(pdFontAttr)); + pdFontAttr.name = ASAtomFromString(csFontName.c_str()); + pdFontAttr.charSet = ASAtomFromString(csCharSet.c_str()); + PDSysFont gSysFont = PDFindSysFont(&pdFontAttr, sizeof(pdFontAttr), kPDSysFontMatchNameAndCharSet); + if (NULL == gSysFont) { + std::cout << "Couldn't find font " << csFontName.c_str() << " (charset " << csCharSet.c_str() + << ") on this system. Try requesting a different font" << std::endl; return -4; - } - else - { + } else { std::cout << "Using font " << csFontName.c_str() << " char set " << csCharSet.c_str() << std::endl; } std::string csInputFile(argc > 1 ? argv[1] : INPUT_DIR INPUT_FILE); - std::string csOutputFile ( argc > 2 ? argv[2] : OUTPUT_FILE ); - - std::cout << "Operating on file " << csInputFile.c_str() << ", will write file " << csOutputFile.c_str() << std::endl; - - PDDoc InDoc; - PDEGraphicState gState; - PDETextState tState; - -DURING - // Open the source document - ASPathName InPath = APDFLDoc::makePath ( csInputFile.c_str() ); - InDoc = PDDocOpen(InPath, NULL, GetPassWord, true); - ASFileSysReleasePath(NULL, InPath); -HANDLER - APDFLib::displayError(ERRORCODE); - return ERRORCODE; -END_HANDLER - -DURING - // Set up a graphic state for setting the header and footer - PDEDefaultGState (&gState, sizeof (PDEGraphicState)); - memset (&tState, 0, sizeof (PDETextState)); - - CosObj CosWorkFont; - // Prepare fonts - { - PDEFont pdeFont = PDEFontCreateFromSysFont (gSysFont, 0); - PDEFontGetCosObj (pdeFont, &CosWorkFont); - CosDoc cosDoc = PDDocGetCosDoc ( InDoc ); - CosWorkFont = CosObjCopy (CosWorkFont, cosDoc, true); - PDERelease ((PDEObject)pdeFont); - } - - ASFixedRect HeadSpace, FootSpace; - memset (&HeadSpace, 0, sizeof (HeadSpace)); - memset (&FootSpace, 0, sizeof (FootSpace)); - - ASInt32 PageNumb; - CosObj CosHead = CosNewNull(), CosFoot = CosNewNull(); - for (PageNumb = 0; PageNumb < PDDocGetNumPages (InDoc); PageNumb++) - { - PDPage InPage; - ASFixedRect MediaBox, BBox; - ASFixed Width, Depth, Scale, HOffset, VOffset, Free, - FreeAbove, FreeBelow, HeadDepth, FootDepth; - ASFixedMatrix Matrix, PageMatrix, IPageMatrix; - CosObj Content, CosWork, CosPage, CosResource, CosFontDict; - - // Get the page, and find the page size - InPage = PDDocAcquirePage (InDoc, PageNumb); - PDPageGetMediaBox (InPage, &MediaBox); - - // Determine if the page has free space on the top and bottom - PDPageGetBBox (InPage, &BBox); - - // Get the content object - CosPage = PDPageGetCosObj (InPage); - Content = CosDictGet (CosPage, ASAtomFromString ("Contents")); - CosResource = CosDictGet (CosPage, ASAtomFromString ("Resources")); - CosWork = CosPage; - while (CosObjGetType (CosResource) == CosNull) - { - CosWork = CosDictGet (CosWork, ASAtomFromString ("Parent")); - CosResource = CosDictGet (CosPage, ASAtomFromString ("Resources")); - } - CosFontDict = CosDictGet (CosResource, ASAtomFromString ("Font")); - if (CosObjGetType (CosFontDict) == CosNull) + std::string csOutputFile(argc > 2 ? argv[2] : OUTPUT_FILE); + + std::cout << "Operating on file " << csInputFile.c_str() << ", will write file " + << csOutputFile.c_str() << std::endl; + + PDDoc InDoc; + PDEGraphicState gState; + PDETextState tState; + + DURING + // Open the source document + ASPathName InPath = APDFLDoc::makePath(csInputFile.c_str()); + InDoc = PDDocOpen(InPath, NULL, GetPassWord, true); + ASFileSysReleasePath(NULL, InPath); + HANDLER + APDFLib::displayError(ERRORCODE); + return ERRORCODE; + END_HANDLER + + DURING + // Set up a graphic state for setting the header and footer + PDEDefaultGState(&gState, sizeof(PDEGraphicState)); + memset(&tState, 0, sizeof(PDETextState)); + + CosObj CosWorkFont; + // Prepare fonts { - // There are no fonts on this page yet - CosFontDict = CosNewDict (PDDocGetCosDoc (InDoc), false, 1); - CosDictPut (CosResource, ASAtomFromString ("Font"), CosFontDict); + PDEFont pdeFont = PDEFontCreateFromSysFont(gSysFont, 0); + PDEFontGetCosObj(pdeFont, &CosWorkFont); + CosDoc cosDoc = PDDocGetCosDoc(InDoc); + CosWorkFont = CosObjCopy(CosWorkFont, cosDoc, true); + PDERelease((PDEObject)pdeFont); } - PDPageGetDefaultMatrix (InPage, &PageMatrix); - ASFixedMatrixTransformRect (&MediaBox, &PageMatrix, &MediaBox); - ASFixedMatrixTransformRect (&BBox, &PageMatrix, &BBox); - - ASFixedMatrixInvert (&IPageMatrix, &PageMatrix); - PDPageRelease (InPage); - - // Check to see if the page has room for a two inch header and footer. - Width = MediaBox.right - MediaBox.left; - Depth = MediaBox.top - MediaBox.bottom; - FreeAbove = MediaBox.top - BBox.top; - FreeBelow = BBox.bottom - MediaBox.bottom; - Free = FreeAbove + FreeBelow; - HeadDepth = FootDepth = fixedOne * 72; - if (Free < (HeadDepth + FootDepth)) - { - // Scale the header and footer to fit as needed - Scale = ASFixedDiv (Depth, // The available space on the page - Depth + ((HeadDepth + FootDepth) - Free)); // The amount of scaling needed for the header & footer - FreeAbove = ASFixedDiv (FreeAbove, Scale) + (Depth - ASFixedMul (Depth, Scale)); - FreeBelow = ASFixedDiv (FreeBelow, Scale); - } - else - Scale = fixedOne; + ASFixedRect HeadSpace, FootSpace; + memset(&HeadSpace, 0, sizeof(HeadSpace)); + memset(&FootSpace, 0, sizeof(FootSpace)); + + ASInt32 PageNumb; + CosObj CosHead = CosNewNull(), CosFoot = CosNewNull(); + for (PageNumb = 0; PageNumb < PDDocGetNumPages(InDoc); PageNumb++) { + PDPage InPage; + ASFixedRect MediaBox, BBox; + ASFixed Width, Depth, Scale, HOffset, VOffset, Free, FreeAbove, FreeBelow, HeadDepth, FootDepth; + ASFixedMatrix Matrix, PageMatrix, IPageMatrix; + CosObj Content, CosWork, CosPage, CosResource, CosFontDict; + + // Get the page, and find the page size + InPage = PDDocAcquirePage(InDoc, PageNumb); + PDPageGetMediaBox(InPage, &MediaBox); + + // Determine if the page has free space on the top and bottom + PDPageGetBBox(InPage, &BBox); + + // Get the content object + CosPage = PDPageGetCosObj(InPage); + Content = CosDictGet(CosPage, ASAtomFromString("Contents")); + CosResource = CosDictGet(CosPage, ASAtomFromString("Resources")); + CosWork = CosPage; + while (CosObjGetType(CosResource) == CosNull) { + CosWork = CosDictGet(CosWork, ASAtomFromString("Parent")); + CosResource = CosDictGet(CosPage, ASAtomFromString("Resources")); + } + CosFontDict = CosDictGet(CosResource, ASAtomFromString("Font")); + if (CosObjGetType(CosFontDict) == CosNull) { + // There are no fonts on this page yet + CosFontDict = CosNewDict(PDDocGetCosDoc(InDoc), false, 1); + CosDictPut(CosResource, ASAtomFromString("Font"), CosFontDict); + } - // Verify if the page needs to be moved down to clear the header - if (FreeAbove < HeadDepth) - { - // Move image down (- offset) to accommodate heading - VOffset = -(HeadDepth - FreeAbove); - FreeAbove -= VOffset; - FreeBelow += VOffset; - ASFixedMul (VOffset, Scale); - } - else - { - if (FreeBelow < FootDepth) - { - // Move image up (+ offset) to accommodate heading - VOffset = (FootDepth - FreeBelow); + PDPageGetDefaultMatrix(InPage, &PageMatrix); + ASFixedMatrixTransformRect(&MediaBox, &PageMatrix, &MediaBox); + ASFixedMatrixTransformRect(&BBox, &PageMatrix, &BBox); + + ASFixedMatrixInvert(&IPageMatrix, &PageMatrix); + PDPageRelease(InPage); + + // Check to see if the page has room for a two inch header and footer. + Width = MediaBox.right - MediaBox.left; + Depth = MediaBox.top - MediaBox.bottom; + FreeAbove = MediaBox.top - BBox.top; + FreeBelow = BBox.bottom - MediaBox.bottom; + Free = FreeAbove + FreeBelow; + HeadDepth = FootDepth = fixedOne * 72; + if (Free < (HeadDepth + FootDepth)) { + // Scale the header and footer to fit as needed + Scale = ASFixedDiv(Depth, // The available space on the page + Depth + ((HeadDepth + FootDepth) - Free)); // The amount of scaling needed for the header & footer + FreeAbove = ASFixedDiv(FreeAbove, Scale) + (Depth - ASFixedMul(Depth, Scale)); + FreeBelow = ASFixedDiv(FreeBelow, Scale); + } else + Scale = fixedOne; + + // Verify if the page needs to be moved down to clear the header + if (FreeAbove < HeadDepth) { + // Move image down (- offset) to accommodate heading + VOffset = -(HeadDepth - FreeAbove); FreeAbove -= VOffset; FreeBelow += VOffset; - ASFixedMul (VOffset, Scale); + ASFixedMul(VOffset, Scale); + } else { + if (FreeBelow < FootDepth) { + // Move image up (+ offset) to accommodate heading + VOffset = (FootDepth - FreeBelow); + FreeAbove -= VOffset; + FreeBelow += VOffset; + ASFixedMul(VOffset, Scale); + } else { + VOffset = 0; + } } + + // Scale symmetrically. Center the page horizontally. + if (Scale != fixedOne) + HOffset = (Width - ASFixedMul(Width, Scale)) / 2; else - { - VOffset = 0; + HOffset = 0; + + // Calculate the size of and content of header and footer + // Reuse previous header if page is the same size + if ((Width != (HeadSpace.right - HeadSpace.left)) || (MediaBox.top != HeadSpace.top)) { + HeadSpace.left = FootSpace.left = 0; + HeadSpace.right = FootSpace.right = Width; + HeadSpace.top = Depth; + HeadSpace.bottom = HeadSpace.top - HeadDepth; + FootSpace.bottom = 0; + FootSpace.top = FootDepth; + + CosHead = BuildSecurityHead(InDoc, &HeadSpace, &IPageMatrix, CosWorkFont); + CosFoot = BuildSecurityFoot(InDoc, &FootSpace, &IPageMatrix, CosWorkFont); } + ASAtom CosWorkName = ASAtomFromString("WorkFont"); + CosDictPut(CosFontDict, CosWorkName, CosWorkFont); + + // Form the complete transformation matrix + Matrix.h = HOffset; + Matrix.v = VOffset; + Matrix.a = Matrix.d = Scale; + Matrix.b = Matrix.c = 0; + + // Prepend the transformation to the content. Put a save before + // it, and a restore after it. + // This will transform the text from the document to the new location on the + // page. The text was transformed on the page after scaling was done to accommodate + // the header and footer being inserted. + if (CosObjGetType(Content) == CosStream) { + CosObj NewContent; + + Content = CopyStreamAddDisplacement(Content, &Matrix); + NewContent = CosNewArray(PDDocGetCosDoc(InDoc), true, 3); + CosArrayPut(NewContent, 0, CosHead); + CosArrayPut(NewContent, 1, CosFoot); + CosArrayPut(NewContent, 2, Content); + Content = NewContent; + } else { + CosWork = CosArrayGet(Content, 0); + CosWork = CopyStreamAddDisplacementStart(CosWork, &Matrix); + CosArrayPut(Content, 0, CosWork); + CosWork = CosArrayGet(Content, CosArrayLength(Content) - 1); + CosWork = CopyStreamAddRestore(CosWork); + CosArrayPut(Content, CosArrayLength(Content) - 1, CosWork); + CosArrayInsert(Content, 0, CosHead); + CosArrayInsert(Content, 1, CosFoot); + } + CosDictPut(CosPage, ASAtomFromString("Contents"), Content); } - // Scale symmetrically. Center the page horizontally. - if (Scale != fixedOne) - HOffset = (Width - ASFixedMul (Width, Scale)) / 2; - else - HOffset = 0; - - // Calculate the size of and content of header and footer - // Reuse previous header if page is the same size - if ((Width != (HeadSpace.right - HeadSpace.left)) || - (MediaBox.top != HeadSpace.top)) - { - HeadSpace.left = FootSpace.left = 0; - HeadSpace.right = FootSpace.right = Width; - HeadSpace.top = Depth; - HeadSpace.bottom = HeadSpace.top - HeadDepth; - FootSpace.bottom = 0; - FootSpace.top = FootDepth; - - CosHead = BuildSecurityHead (InDoc, &HeadSpace, &IPageMatrix, CosWorkFont ); - CosFoot = BuildSecurityFoot (InDoc, &FootSpace, &IPageMatrix, CosWorkFont ); - } - ASAtom CosWorkName = ASAtomFromString ("WorkFont"); - CosDictPut (CosFontDict, CosWorkName, CosWorkFont); - - // Form the complete transformation matrix - Matrix.h = HOffset; - Matrix.v = VOffset; - Matrix.a = Matrix.d = Scale; - Matrix.b = Matrix.c = 0; - - // Prepend the transformation to the content. Put a save before - // it, and a restore after it. - // This will transform the text from the document to the new location on the - // page. The text was transformed on the page after scaling was done to accommodate - // the header and footer being inserted. - if (CosObjGetType (Content) == CosStream) - { - CosObj NewContent; - - Content = CopyStreamAddDisplacement (Content, &Matrix); - NewContent = CosNewArray (PDDocGetCosDoc (InDoc), true, 3); - CosArrayPut (NewContent, 0, CosHead); - CosArrayPut (NewContent, 1, CosFoot); - CosArrayPut (NewContent, 2, Content); - Content = NewContent; - } - else - { - CosWork = CosArrayGet (Content, 0); - CosWork = CopyStreamAddDisplacementStart (CosWork, &Matrix); - CosArrayPut (Content, 0, CosWork); - CosWork = CosArrayGet (Content, CosArrayLength (Content)-1); - CosWork = CopyStreamAddRestore (CosWork); - CosArrayPut (Content, CosArrayLength (Content)-1, CosWork); - CosArrayInsert (Content, 0, CosHead); - CosArrayInsert (Content, 1, CosFoot); - } - CosDictPut (CosPage, ASAtomFromString ("Contents"), Content); - } - - ASPathName OutPath = APDFLDoc::makePath ( csOutputFile.c_str() ); - PDDocSave (InDoc, (PDSaveFull | PDSaveCollectGarbage), OutPath, NULL, NULL, NULL); - ASFileSysReleasePath (NULL, OutPath); + ASPathName OutPath = APDFLDoc::makePath(csOutputFile.c_str()); + PDDocSave(InDoc, (PDSaveFull | PDSaveCollectGarbage), OutPath, NULL, NULL, NULL); + ASFileSysReleasePath(NULL, OutPath); -HANDLER - APDFLib::displayError(ERRORCODE); - return ERRORCODE; -END_HANDLER + HANDLER + APDFLib::displayError(ERRORCODE); + return ERRORCODE; + END_HANDLER // Don't forget to release the color spaces in the default graphic state - PDERelease ((PDEObject)gState.fillColorSpec.space); - PDERelease ((PDEObject)gState.strokeColorSpec.space); + PDERelease((PDEObject)gState.fillColorSpec.space); + PDERelease((PDEObject)gState.strokeColorSpec.space); return 0; } // Call-back which PDDocOpen will invoke when it tries to open an encrypted document -ASBool GetPassWord (PDDoc Doc) -{ - ASAtom Handler = PDDocGetNewCryptHandler (Doc); +ASBool GetPassWord(PDDoc Doc) { + ASAtom Handler = PDDocGetNewCryptHandler(Doc); if (Handler == ASAtomNull) - return (TRUE); + return (TRUE); // Input a password from the user char PassWord[100]; @@ -300,7 +276,7 @@ ASBool GetPassWord (PDDoc Doc) std::cin >> PassWord; int Permissions = pdPermOwner | pdPermOpen; - int NewPerms = PDDocAuthorize (Doc, Permissions, PassWord); + int NewPerms = PDDocAuthorize(Doc, Permissions, PassWord); if (NewPerms & (pdPermOpen | pdPermOwner)) return (TRUE); @@ -309,133 +285,130 @@ ASBool GetPassWord (PDDoc Doc) return false; } -CosObj CopyStreamAddDisplacement (CosObj Stream, ASFixedMatrix *Matrix) -{ +CosObj CopyStreamAddDisplacement(CosObj Stream, ASFixedMatrix *Matrix) { std::ostringstream ossMatrixMoveCmd; - std::string sRestoreCmd ( "\nQ\n" ); - ossMatrixMoveCmd << "q " << FixedMatrixToStrings ( Matrix ).c_str() << " cm \n"; + std::string sRestoreCmd("\nQ\n"); + ossMatrixMoveCmd << "q " << FixedMatrixToStrings(Matrix).c_str() << " cm \n"; - CStreamContents csc ( Stream ); - csc.AddCommands ( ossMatrixMoveCmd.str().c_str(), sRestoreCmd.c_str() ); + CStreamContents csc(Stream); + csc.AddCommands(ossMatrixMoveCmd.str().c_str(), sRestoreCmd.c_str()); - CosObj Attribute = CosObjCopy ( CosStreamDict (Stream), CosObjGetDoc (Stream), false); - CosDictRemove (Attribute, ASAtomFromString ("Length")); - CosObj Parms = CosDictGet (Attribute, ASAtomFromString ("DecodeParms")); + CosObj Attribute = CosObjCopy(CosStreamDict(Stream), CosObjGetDoc(Stream), false); + CosDictRemove(Attribute, ASAtomFromString("Length")); + CosObj Parms = CosDictGet(Attribute, ASAtomFromString("DecodeParms")); - ASStm NewStm = ASMemStmRdOpen ( csc.GetBuffer(), csc.GetSize() ); - CosObj NewContent = CosNewStream (CosObjGetDoc (Stream), true, NewStm, 0, true, Attribute, Parms, -1); - ASStmClose ( NewStm ); + ASStm NewStm = ASMemStmRdOpen(csc.GetBuffer(), csc.GetSize()); + CosObj NewContent = CosNewStream(CosObjGetDoc(Stream), true, NewStm, 0, true, Attribute, Parms, -1); + ASStmClose(NewStm); return NewContent; } -CosObj CopyStreamAddDisplacementStart (CosObj Stream, ASFixedMatrix *Matrix) -{ +CosObj CopyStreamAddDisplacementStart(CosObj Stream, ASFixedMatrix *Matrix) { std::ostringstream ossMatrixMoveCmd; - ossMatrixMoveCmd << "q " << FixedMatrixToStrings ( Matrix ).c_str() << " cm \n"; + ossMatrixMoveCmd << "q " << FixedMatrixToStrings(Matrix).c_str() << " cm \n"; - CStreamContents csc ( Stream ); - csc.AddCommands ( ossMatrixMoveCmd.str().c_str(), NULL ); + CStreamContents csc(Stream); + csc.AddCommands(ossMatrixMoveCmd.str().c_str(), NULL); - CosObj Attribute = CosObjCopy ( CosStreamDict (Stream), CosObjGetDoc (Stream), false); - CosDictRemove (Attribute, ASAtomFromString ("Length")); - CosObj Parms = CosDictGet (Attribute, ASAtomFromString ("DecodeParms")); + CosObj Attribute = CosObjCopy(CosStreamDict(Stream), CosObjGetDoc(Stream), false); + CosDictRemove(Attribute, ASAtomFromString("Length")); + CosObj Parms = CosDictGet(Attribute, ASAtomFromString("DecodeParms")); - ASStm NewStm = ASMemStmRdOpen ( csc.GetBuffer(), csc.GetSize() ); - CosObj NewContent = CosNewStream (CosObjGetDoc (Stream), true, NewStm, 0, true, Attribute, Parms, -1); - ASStmClose ( NewStm ); + ASStm NewStm = ASMemStmRdOpen(csc.GetBuffer(), csc.GetSize()); + CosObj NewContent = CosNewStream(CosObjGetDoc(Stream), true, NewStm, 0, true, Attribute, Parms, -1); + ASStmClose(NewStm); return NewContent; } -CosObj CopyStreamAddRestore (CosObj Stream) -{ - std::string sRestoreCmd ( "\nQ\n" ); +CosObj CopyStreamAddRestore(CosObj Stream) { + std::string sRestoreCmd("\nQ\n"); - CStreamContents csc ( Stream ); - csc.AddCommands ( NULL, sRestoreCmd.c_str() ); + CStreamContents csc(Stream); + csc.AddCommands(NULL, sRestoreCmd.c_str()); - CosObj Attribute = CosObjCopy ( CosStreamDict (Stream), CosObjGetDoc (Stream), false); - CosDictRemove (Attribute, ASAtomFromString ("Length")); - CosObj Parms = CosDictGet (Attribute, ASAtomFromString ("DecodeParms")); + CosObj Attribute = CosObjCopy(CosStreamDict(Stream), CosObjGetDoc(Stream), false); + CosDictRemove(Attribute, ASAtomFromString("Length")); + CosObj Parms = CosDictGet(Attribute, ASAtomFromString("DecodeParms")); - ASStm NewStm = ASMemStmRdOpen ( csc.GetBuffer(), csc.GetSize() ); - CosObj NewContent = CosNewStream (CosObjGetDoc (Stream), true, NewStm, 0, true, Attribute, Parms, -1); - ASStmClose ( NewStm ); + ASStm NewStm = ASMemStmRdOpen(csc.GetBuffer(), csc.GetSize()); + CosObj NewContent = CosNewStream(CosObjGetDoc(Stream), true, NewStm, 0, true, Attribute, Parms, -1); + ASStmClose(NewStm); return NewContent; } // Utility function to render the elements in an ASFixedMatrix as a string in a, b, c, d, h, v order // To learn more about these matrix values, visit the Datalogics KnowledgeBase, feedback.datalogics.com/knowledgebase, and search on "ASFixedMatrix." -std::string FixedMatrixToStrings ( ASFixedMatrix* pM ) -{ +std::string FixedMatrixToStrings(ASFixedMatrix *pM) { char A[10], B[10], C[10], D[10], H[10], V[10]; - ASFixedToCString ( pM->a, A, sizeof (A)-1, 4); - ASFixedToCString ( pM->b, B, sizeof (B)-1, 4); - ASFixedToCString ( pM->c, C, sizeof (C)-1, 4); - ASFixedToCString ( pM->d, D, sizeof (D)-1, 4); - ASFixedToCString ( pM->h, H, sizeof (H)-1, 4); - ASFixedToCString ( pM->v, V, sizeof (V)-1, 4); + ASFixedToCString(pM->a, A, sizeof(A) - 1, 4); + ASFixedToCString(pM->b, B, sizeof(B) - 1, 4); + ASFixedToCString(pM->c, C, sizeof(C) - 1, 4); + ASFixedToCString(pM->d, D, sizeof(D) - 1, 4); + ASFixedToCString(pM->h, H, sizeof(H) - 1, 4); + ASFixedToCString(pM->v, V, sizeof(V) - 1, 4); std::ostringstream oss; oss << A << ' ' << B << ' ' << C << ' ' << D << ' ' << H << ' ' << V; - return oss.str(); + return oss.str(); } -CosObj BuildSecurityHead (PDDoc InDoc, ASFixedRect *HeadSpace, ASFixedMatrix *InMatrix, CosObj& cosWorkFont ) -{ - CosDoc cosDoc = PDDocGetCosDoc (InDoc); +CosObj BuildSecurityHead(PDDoc InDoc, ASFixedRect *HeadSpace, ASFixedMatrix *InMatrix, CosObj &cosWorkFont) { + CosDoc cosDoc = PDDocGetCosDoc(InDoc); PDEFont pdeFont; - pdeFont = PDEFontCreateFromCosObj (&cosWorkFont); - ASFixed Horiz = ASInt32ToFixed (PDEFontSumWidths (pdeFont, (ASUns8 *)Heading, strlen (Heading))) / 1000 * HeadPointSize; + pdeFont = PDEFontCreateFromCosObj(&cosWorkFont); + ASFixed Horiz = ASInt32ToFixed(PDEFontSumWidths(pdeFont, (ASUns8 *)Heading, strlen(Heading))) / + 1000 * HeadPointSize; Horiz = (HeadSpace->right + HeadSpace->left - Horiz) / 2; ASFixed Vert = HeadSpace->top - ASInt32ToFixed(((HeadPointSize * 2) / 3)) - (fixedOne * 10); - PDERelease ((PDEObject)pdeFont); + PDERelease((PDEObject)pdeFont); - ASFixedMatrix Matrix; + ASFixedMatrix Matrix; Matrix.a = Matrix.d = fixedOne; Matrix.b = Matrix.c = 0; Matrix.h = Horiz; Matrix.v = Vert; - ASFixedMatrixConcat (&Matrix, InMatrix, &Matrix); + ASFixedMatrixConcat(&Matrix, InMatrix, &Matrix); std::ostringstream oss; - oss << "q BT 0 g /WorkFont " << HeadPointSize << " Tf " << FixedMatrixToStrings ( &Matrix ) << " Tm (" << Heading << ") Tj ET Q"; - std::string header ( oss.str() ); - ASStm WorkStream = ASMemStmRdOpen ( header.c_str(), header.length() ); - CosObj StmDict = CosNewDict (cosDoc, false, 1); - CosDictPut (StmDict, ASAtomFromString ("Filter"), CosNewName (cosDoc, false, ASAtomFromString ("FlateDecode"))); - CosObj NewStream = CosNewStream (cosDoc, true, WorkStream, 0, true, StmDict, CosNewNull(), -1); + oss << "q BT 0 g /WorkFont " << HeadPointSize << " Tf " << FixedMatrixToStrings(&Matrix) + << " Tm (" << Heading << ") Tj ET Q"; + std::string header(oss.str()); + ASStm WorkStream = ASMemStmRdOpen(header.c_str(), header.length()); + CosObj StmDict = CosNewDict(cosDoc, false, 1); + CosDictPut(StmDict, ASAtomFromString("Filter"), CosNewName(cosDoc, false, ASAtomFromString("FlateDecode"))); + CosObj NewStream = CosNewStream(cosDoc, true, WorkStream, 0, true, StmDict, CosNewNull(), -1); return NewStream; } -CosObj BuildSecurityFoot (PDDoc InDoc, ASFixedRect *FootSpace, ASFixedMatrix *InMatrix, CosObj& cosWorkFont ) -{ - CosDoc cosDoc = PDDocGetCosDoc (InDoc); +CosObj BuildSecurityFoot(PDDoc InDoc, ASFixedRect *FootSpace, ASFixedMatrix *InMatrix, CosObj &cosWorkFont) { + CosDoc cosDoc = PDDocGetCosDoc(InDoc); - PDEFont pdeFont = PDEFontCreateFromCosObj (&cosWorkFont); - ASFixed Horiz = ASInt32ToFixed (PDEFontSumWidths (pdeFont, (ASUns8 *)Footing, strlen (Footing))) / 1000 * FootPointSize; + PDEFont pdeFont = PDEFontCreateFromCosObj(&cosWorkFont); + ASFixed Horiz = ASInt32ToFixed(PDEFontSumWidths(pdeFont, (ASUns8 *)Footing, strlen(Footing))) / + 1000 * FootPointSize; Horiz = (FootSpace->right + FootSpace->left - Horiz) / 2; ASFixed Vert = FootSpace->bottom + ASInt32ToFixed(((FootPointSize * 2) / 3)) + (10 * fixedOne); - PDERelease ((PDEObject)pdeFont); - + PDERelease((PDEObject)pdeFont); + ASFixedMatrix Matrix; - memmove (&Matrix, InMatrix, sizeof (ASFixedMatrix)); + memmove(&Matrix, InMatrix, sizeof(ASFixedMatrix)); Matrix.a = Matrix.d = fixedOne; Matrix.b = Matrix.c = 0; Matrix.h = Horiz; Matrix.v = Vert; - ASFixedMatrixConcat (&Matrix, InMatrix, &Matrix); + ASFixedMatrixConcat(&Matrix, InMatrix, &Matrix); std::ostringstream oss; - oss << "q BT 0 g /WorkFont " << FootPointSize << " Tf " << FixedMatrixToStrings ( &Matrix ) << " Tm (" << Footing << ") Tj ET Q"; - std::string footer ( oss.str() ); - ASStm WorkStream = ASMemStmRdOpen ( footer.c_str(), footer.length() ); - CosObj StmDict = CosNewDict (cosDoc, false, 1); - CosObj NewStream = CosNewStream (cosDoc, true, WorkStream, 0, true, StmDict, CosNewNull(), -1); + oss << "q BT 0 g /WorkFont " << FootPointSize << " Tf " << FixedMatrixToStrings(&Matrix) + << " Tm (" << Footing << ") Tj ET Q"; + std::string footer(oss.str()); + ASStm WorkStream = ASMemStmRdOpen(footer.c_str(), footer.length()); + CosObj StmDict = CosNewDict(cosDoc, false, 1); + CosObj NewStream = CosNewStream(cosDoc, true, WorkStream, 0, true, StmDict, CosNewNull(), -1); return NewStream; } - diff --git a/CPlusPlus/Sample_Source/Text/TextSearch/TextSearch.cpp b/CPlusPlus/Sample_Source/Text/TextSearch/TextSearch.cpp index c137250b..39e15a78 100644 --- a/CPlusPlus/Sample_Source/Text/TextSearch/TextSearch.cpp +++ b/CPlusPlus/Sample_Source/Text/TextSearch/TextSearch.cpp @@ -10,7 +10,7 @@ // // Command-line: (All optional) // -// For more detail see the description of the TextSearch sample program on our Developer’s site, +// For more detail see the description of the TextSearch sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#textsearch #include @@ -26,166 +26,159 @@ #define DEF_SEARCH_WORD "pirate" static void ApplyQuadsToAnnot(PDAnnot, ASFixedQuad *, ASArraySize); -static bool DoesWordMatch ( PDWord, const char* ); -static void AnnotateWord ( PDWord, PDPage, PDColorValue ); +static bool DoesWordMatch(PDWord, const char *); +static void AnnotateWord(PDWord, PDPage, PDColorValue); -int main ( int argc, char* argv[] ) -{ +int main(int argc, char *argv[]) { APDFLib libInit; ASErrorCode errCode = 0; - if (libInit.isValid() == false) - { + if (libInit.isValid() == false) { errCode = libInit.getInitError(); std::cout << "Initialization failed with code " << errCode << std::endl; return libInit.getInitError(); } - - std::string csInputFileName ( argc > 1 ? argv[1] : DIR_LOC DEF_INPUT ); - std::string csOutputFileName ( argc > 2 ? argv[2] : DEF_OUTPUT ); - std::string csSearchWord ( argc > 3 ? argv[3] : DEF_SEARCH_WORD ); + + std::string csInputFileName(argc > 1 ? argv[1] : DIR_LOC DEF_INPUT); + std::string csOutputFileName(argc > 2 ? argv[2] : DEF_OUTPUT); + std::string csSearchWord(argc > 3 ? argv[3] : DEF_SEARCH_WORD); std::cout << "Will search " << csInputFileName.c_str() << " for all occurrences of " - << "the word \"" << csSearchWord.c_str() << "\"," << std::endl << "highlight them all, " + << "the word \"" << csSearchWord.c_str() << "\"," << std::endl + << "highlight them all, " << " and save to " << csOutputFileName.c_str() << std::endl; - -DURING - - APDFLDoc document ( csInputFileName.c_str(), true); - -// Step 1) Set up the word finder configuration record - - PDWordFinderConfigRec wfConfig; - - memset(&wfConfig, 0, sizeof(wfConfig)); //Always do this! - wfConfig.recSize = sizeof(PDWordFinderConfigRec); //...and this! - - wfConfig.disableTaggedPDF = true; //Treat this as a non-tagged PDF document. - wfConfig.noXYSort = true; //Don't generate an XY-ordered word list. - wfConfig.preserveSpaces = false; //Don't preserve spaces during word breaking. - wfConfig.noLigatureExp = false; //Enable expansion of ligatures using the default ligatures. - wfConfig.noEncodingGuess = true; //Disable guessing encoding of fonts with unknown/custom encoding. - wfConfig.unknownToStdEnc = false; //Don't assume all fonts are Standard Roman. - // Setting to true overrides noEncodingGuess. - wfConfig.ignoreCharGaps = true; //Disable converting large character gaps to spaces. - wfConfig.ignoreLineGaps = false; //Treat vertical movements as line breaks. - wfConfig.noAnnots = true; //Don't extract from annotations. - wfConfig.noHyphenDetection = false; //Don't differentiate between hard and soft hyphens. - wfConfig.trustNBSpace = false; //Don't differentiate between breaking and non-breaking spaces. - wfConfig.noExtCharOffset = false; //If client doesn't have a need for detailed character - // offset information set to true for improvement in efficiency. - wfConfig.noStyleInfo = false; //Set to true if client doesn't have a need for style - // information for improvement in efficiency. - wfConfig.decomposeTbl = NULL; //Table may be used to expand unicode ligatures - // not in the default list. - wfConfig.decomposeTblSize = 0; //Not using decomposeTbl, so the size is 0. - wfConfig.charTypeTbl = NULL; //Custom table to enhance word breaking quality. - wfConfig.charTypeTblSize = 0; //Unused, so the size will be 0. - wfConfig.preserveRedundantChars = false; //May be used to preserve overlapping redundant - // characters in some PDF documents. - wfConfig.disableCharReordering = false; //Used in cases where the PDF page has heavily - // overlapped character bounding boxes. - -// Step 2) Fill in color information for highlighting text. In this case our color will be set to orange. - - PDColorValueRec colorValRec; - PDColorValue pdColorValue ( &colorValRec ); - pdColorValue->space = PDDeviceRGB; // Colors are set using the RGB color space. - pdColorValue->value[0] = ASFloatToFixed ( 1.0 ); // red level - pdColorValue->value[1] = ASFloatToFixed ( 0.65 ); // green level - pdColorValue->value[2] = ASFloatToFixed ( 0.0 ); // blue level - -// Step 3) Search for the quarry, and highlight all occurrences - - PDWordFinder wordFinder = PDDocCreateWordFinderEx(document.getPDDoc(), WF_LATEST_VERSION, true, &wfConfig); - - // Iterate over all pages in thedocument - ASInt32 countPages = PDDocGetNumPages ( document.getPDDoc() ); - for (ASInt32 pageNum = 0; pageNum < countPages; ++pageNum) - { - // Get the words for this page - PDWord pdfWordArray; - ASInt32 numberOfWords = 0; - PDWordFinderAcquireWordList(wordFinder, pageNum, &pdfWordArray, NULL, NULL, &numberOfWords); - - // The PDPage object will be needed for adding the highlight annotation. - PDPage pdPage = document.getPage(pageNum); - - // Examine each word - for (ASInt32 index = 0; index < numberOfWords; ++index) - { - PDWord pdWord = PDWordFinderGetNthWord(wordFinder, index); - if ( DoesWordMatch ( pdWord, csSearchWord.c_str() ) ) - { - AnnotateWord ( pdWord, pdPage, pdColorValue ); + + DURING + + APDFLDoc document(csInputFileName.c_str(), true); + + // Step 1) Set up the word finder configuration record + + PDWordFinderConfigRec wfConfig; + + memset(&wfConfig, 0, sizeof(wfConfig)); // Always do this! + wfConfig.recSize = sizeof(PDWordFinderConfigRec); //...and this! + + wfConfig.disableTaggedPDF = true; // Treat this as a non-tagged PDF document. + wfConfig.noXYSort = true; // Don't generate an XY-ordered word list. + wfConfig.preserveSpaces = false; // Don't preserve spaces during word breaking. + wfConfig.noLigatureExp = false; // Enable expansion of ligatures using the default ligatures. + wfConfig.noEncodingGuess = true; // Disable guessing encoding of fonts with unknown/custom encoding. + wfConfig.unknownToStdEnc = false; // Don't assume all fonts are Standard Roman. + // Setting to true overrides noEncodingGuess. + wfConfig.ignoreCharGaps = true; // Disable converting large character gaps to spaces. + wfConfig.ignoreLineGaps = false; // Treat vertical movements as line breaks. + wfConfig.noAnnots = true; // Don't extract from annotations. + wfConfig.noHyphenDetection = false; // Don't differentiate between hard and soft hyphens. + wfConfig.trustNBSpace = false; // Don't differentiate between breaking and non-breaking spaces. + wfConfig.noExtCharOffset = false; // If client doesn't have a need for detailed character + // offset information set to true for improvement in efficiency. + wfConfig.noStyleInfo = false; // Set to true if client doesn't have a need for style + // information for improvement in efficiency. + wfConfig.decomposeTbl = NULL; // Table may be used to expand unicode ligatures + // not in the default list. + wfConfig.decomposeTblSize = 0; // Not using decomposeTbl, so the size is 0. + wfConfig.charTypeTbl = NULL; // Custom table to enhance word breaking quality. + wfConfig.charTypeTblSize = 0; // Unused, so the size will be 0. + wfConfig.preserveRedundantChars = false; // May be used to preserve overlapping redundant + // characters in some PDF documents. + wfConfig.disableCharReordering = false; // Used in cases where the PDF page has heavily + // overlapped character bounding boxes. + + // Step 2) Fill in color information for highlighting text. In this case our color will be set to orange. + + PDColorValueRec colorValRec; + PDColorValue pdColorValue(&colorValRec); + pdColorValue->space = PDDeviceRGB; // Colors are set using the RGB color space. + pdColorValue->value[0] = ASFloatToFixed(1.0); // red level + pdColorValue->value[1] = ASFloatToFixed(0.65); // green level + pdColorValue->value[2] = ASFloatToFixed(0.0); // blue level + + // Step 3) Search for the quarry, and highlight all occurrences + + PDWordFinder wordFinder = + PDDocCreateWordFinderEx(document.getPDDoc(), WF_LATEST_VERSION, true, &wfConfig); + + // Iterate over all pages in thedocument + ASInt32 countPages = PDDocGetNumPages(document.getPDDoc()); + for (ASInt32 pageNum = 0; pageNum < countPages; ++pageNum) { + // Get the words for this page + PDWord pdfWordArray; + ASInt32 numberOfWords = 0; + PDWordFinderAcquireWordList(wordFinder, pageNum, &pdfWordArray, NULL, NULL, &numberOfWords); + + // The PDPage object will be needed for adding the highlight annotation. + PDPage pdPage = document.getPage(pageNum); + + // Examine each word + for (ASInt32 index = 0; index < numberOfWords; ++index) { + PDWord pdWord = PDWordFinderGetNthWord(wordFinder, index); + if (DoesWordMatch(pdWord, csSearchWord.c_str())) { + AnnotateWord(pdWord, pdPage, pdColorValue); + } } - } - PDPageRelease(pdPage); - //Release the word list before acquiring the next one. - PDWordFinderReleaseWordList(wordFinder, pageNum); - } + PDPageRelease(pdPage); + // Release the word list before acquiring the next one. + PDWordFinderReleaseWordList(wordFinder, pageNum); + } - PDWordFinderDestroy(wordFinder); + PDWordFinderDestroy(wordFinder); - document.saveDoc ( csOutputFileName.c_str() ); + document.saveDoc(csOutputFileName.c_str()); -HANDLER - errCode = ERRORCODE; - libInit.displayError(errCode); -END_HANDLER + HANDLER + errCode = ERRORCODE; + libInit.displayError(errCode); + END_HANDLER - return errCode; + return errCode; } // Add quads to an annotation's CosObj. -// NOTE: There is Adobe documentation that specifies quads be added in the order - BL, BR, TR, TL. -// However, currently the order needs to be BL, BR, TL, TR to get correct output. -void ApplyQuadsToAnnot(PDAnnot annot, ASFixedQuad *quads, ASArraySize numQuads) -{ +// NOTE: There is Adobe documentation that specifies quads be added in the order - BL, BR, TR, TL. +// However, currently the order needs to be BL, BR, TL, TR to get correct output. +void ApplyQuadsToAnnot(PDAnnot annot, ASFixedQuad *quads, ASArraySize numQuads) { CosObj coAnnot = PDAnnotGetCosObj(annot); CosDoc coDoc = CosObjGetDoc(coAnnot); CosObj coQuads = CosNewArray(coDoc, false, numQuads * 8); - static ASAtom atQP = ASAtomFromString ( "QuadPoints" ); + static ASAtom atQP = ASAtomFromString("QuadPoints"); - for (ASUns32 i = 0, n = 0; i < numQuads; ++i) - { + for (ASUns32 i = 0, n = 0; i < numQuads; ++i) { CosArrayPut(coQuads, n++, CosNewFixed(coDoc, false, quads[i].bl.h)); CosArrayPut(coQuads, n++, CosNewFixed(coDoc, false, quads[i].bl.v)); CosArrayPut(coQuads, n++, CosNewFixed(coDoc, false, quads[i].br.h)); CosArrayPut(coQuads, n++, CosNewFixed(coDoc, false, quads[i].br.v)); - CosArrayPut(coQuads, n++, CosNewFixed(coDoc, false, quads[i].tl.h)); // See note above + CosArrayPut(coQuads, n++, CosNewFixed(coDoc, false, quads[i].tl.h)); // See note above CosArrayPut(coQuads, n++, CosNewFixed(coDoc, false, quads[i].tl.v)); - CosArrayPut(coQuads, n++, CosNewFixed(coDoc, false, quads[i].tr.h)); // See note above + CosArrayPut(coQuads, n++, CosNewFixed(coDoc, false, quads[i].tr.h)); // See note above CosArrayPut(coQuads, n++, CosNewFixed(coDoc, false, quads[i].tr.v)); } - CosDictPut ( coAnnot, atQP, coQuads ); + CosDictPut(coAnnot, atQP, coQuads); } // Determines if our word "matches" the quarry. You control the logic of this decision. // In this sample, we will match on a case INsensitive containment of the search word -/* static */ bool DoesWordMatch ( PDWord w, const char* q ) -{ +/* static */ bool DoesWordMatch(PDWord w, const char *q) { ASText asTextWord = ASTextNew(); PDWordGetASText(w, 0, asTextWord); - + ASInt32 wordLen = 0; char *pdWordChar = ASTextGetPDTextCopy(asTextWord, &wordLen); - std::string sWord ( pdWordChar ); - std::transform ( sWord.begin(), sWord.end(), sWord.begin(), ::tolower ); - bool rc = std::string::npos != sWord.find ( q ); + std::string sWord(pdWordChar); + std::transform(sWord.begin(), sWord.end(), sWord.begin(), ::tolower); + bool rc = std::string::npos != sWord.find(q); - ASTextDestroy ( asTextWord ); - ASfree ( pdWordChar ); + ASTextDestroy(asTextWord); + ASfree(pdWordChar); return rc; } -/* static */ void AnnotateWord ( PDWord w, PDPage p, PDColorValue c ) -{ - static ASAtom atH = ASAtomFromString ( "Highlight" ); +/* static */ void AnnotateWord(PDWord w, PDPage p, PDColorValue c) { + static ASAtom atH = ASAtomFromString("Highlight"); - // A value of -2 adds the annotation to the end of the page's annotation array + // A value of -2 adds the annotation to the end of the page's annotation array ASInt32 addAfterCode = -2; // Coordinates of the annotation @@ -195,8 +188,8 @@ void ApplyQuadsToAnnot(PDAnnot annot, ASFixedQuad *quads, ASArraySize numQuads) ASFixedRect annotationRect; annotationRect.left = tempQuad.bl.h; annotationRect.top = tempQuad.tr.v; - annotationRect.right = tempQuad.tr.h; - annotationRect.bottom = tempQuad.bl.v; + annotationRect.right = tempQuad.tr.h; + annotationRect.bottom = tempQuad.bl.v; // Create the annotation PDAnnot highlight = PDPageCreateAnnot(p, atH, &annotationRect); @@ -205,5 +198,5 @@ void ApplyQuadsToAnnot(PDAnnot annot, ASFixedQuad *quads, ASArraySize numQuads) ApplyQuadsToAnnot(highlight, &tempQuad, 1); PDAnnotSetColor(highlight, c); - PDPageAddAnnot ( p, addAfterCode, highlight); + PDPageAddAnnot(p, addAfterCode, highlight); } diff --git a/CPlusPlus/Sample_Source/Text/UnicodeText/UnicodeText.cpp b/CPlusPlus/Sample_Source/Text/UnicodeText/UnicodeText.cpp index 1b48180d..bdc4bf20 100644 --- a/CPlusPlus/Sample_Source/Text/UnicodeText/UnicodeText.cpp +++ b/CPlusPlus/Sample_Source/Text/UnicodeText/UnicodeText.cpp @@ -4,12 +4,12 @@ // For complete copyright information, refer to: // http://dev.datalogics.com/adobe-pdf-library/license-for-downloaded-pdf-samples/ // -// The UnicodeText sample demonstrates how the Library works with Unicode text. -// The sample converts hexadecimal characters into Unicode. +// The UnicodeText sample demonstrates how the Library works with Unicode text. +// The sample converts hexadecimal characters into Unicode. // // Command-line: (Optional) // -// For more detail see the description of the UnicodeText sample program on our Developer’s site, +// For more detail see the description of the UnicodeText sample program on our Developer’s site, // http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/c1samples#unicodetext #include "APDFLDoc.h" @@ -21,337 +21,306 @@ #include "PagePDECntCalls.h" #include "DLExtrasCalls.h" -//The number of fonts we're using. Must be accurate, of course. -#define NUM_FONTS_SAMPLE 3 +// The number of fonts we're using. Must be accurate, of course. +#define NUM_FONTS_SAMPLE 3 -//The number of Unicode text strings we'll draw. This must be accurate, of course. -#define NUM_TEXTS 5 +// The number of Unicode text strings we'll draw. This must be accurate, of course. +#define NUM_TEXTS 5 -#define DEF_OUTPUT "UnicodeText-out.pdf" +#define DEF_OUTPUT "UnicodeText-out.pdf" -int main(int argc, char** argv) -{ +int main(int argc, char **argv) { APDFLib libInit; ASErrorCode errCode = 0; - if (libInit.isValid() == false) - { + if (libInit.isValid() == false) { errCode = libInit.getInitError(); std::cout << "Initialization failed with code " << errCode << std::endl; return libInit.getInitError(); } - - std::string csOutputFileName ( argc > 1 ? argv[1] : DEF_OUTPUT ); - std::cout << "Will write 2 pages of assorted Unicode strings to " << csOutputFileName.c_str() - << std::endl; -// Step 1) Declare the Unicode strings. + std::string csOutputFileName(argc > 1 ? argv[1] : DEF_OUTPUT); + std::cout << "Will write 2 pages of assorted Unicode strings to " << csOutputFileName.c_str() << std::endl; - // The following are all the Unicode strings we intend to place. Note that every string - // lacks a BOM, lacks other identifiers, and is big endian. These are all required - // characteristics for creating an ASText object from a Unicode string (minus the - // endianness - one could also use the host machine's endianness, but that is not + // Step 1) Declare the Unicode strings. + + // The following are all the Unicode strings we intend to place. Note that every string + // lacks a BOM, lacks other identifiers, and is big endian. These are all required + // characteristics for creating an ASText object from a Unicode string (minus the + // endianness - one could also use the host machine's endianness, but that is not // guaranteed to be little-endian, so little endian is not demonstrated.) // // Our English text is in UTF-8. // This could have been a string literal, but for the sake of consistency: - ASUTF8Val englishStr_U8[] = { - 0x55, 0x6E, 0x69, 0x76, 0x65, 0x72, 0x73, 0x61, - 0x6C, 0x20, 0x44, 0x65, 0x63, 0x6C, 0x61, 0x72, - 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x6F, 0x66, - 0x20, 0x48, 0x75, 0x6D, 0x61, 0x6E, 0x20, 0x52, - 0x69, 0x67, 0x68, 0x74, 0x73, 0x00 - }; - - //Our French text is in UTF-16B. + ASUTF8Val englishStr_U8[] = {0x55, 0x6E, 0x69, 0x76, 0x65, 0x72, 0x73, 0x61, 0x6C, 0x20, + 0x44, 0x65, 0x63, 0x6C, 0x61, 0x72, 0x61, 0x74, 0x69, 0x6F, + 0x6E, 0x20, 0x6F, 0x66, 0x20, 0x48, 0x75, 0x6D, 0x61, 0x6E, + 0x20, 0x52, 0x69, 0x67, 0x68, 0x74, 0x73, 0x00}; + + // Our French text is in UTF-16B. ASUTF8Val frenchStr_U16B[] = { - 0x00, 0x44, 0x00, 0xE9, 0x00, 0x63, 0x00, 0x6C, - 0x00, 0x61, 0x00, 0x72, 0x00, 0x61, 0x00, 0x74, - 0x00, 0x69, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x20, - 0x00, 0x75, 0x00, 0x6E, 0x00, 0x69, 0x00, 0x76, - 0x00, 0x65, 0x00, 0x72, 0x00, 0x73, 0x00, 0x65, - 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x20, - 0x00, 0x64, 0x00, 0x65, 0x00, 0x73, 0x00, 0x20, - 0x00, 0x64, 0x00, 0x72, 0x00, 0x6F, 0x00, 0x69, - 0x00, 0x74, 0x00, 0x73, 0x00, 0x20, 0x00, 0x64, - 0x00, 0x65, 0x00, 0x20, 0x00, 0x6C, 0x00, 0x27, - 0x00, 0x68, 0x00, 0x6F, 0x00, 0x6D, 0x00, 0x6D, - 0x00, 0x65, 0x00, 0x00 - }; - - //Our Russian (cyrillic script) text is in UTF-16B. + 0x00, 0x44, 0x00, 0xE9, 0x00, 0x63, 0x00, 0x6C, 0x00, 0x61, 0x00, 0x72, 0x00, 0x61, + 0x00, 0x74, 0x00, 0x69, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x20, 0x00, 0x75, 0x00, 0x6E, + 0x00, 0x69, 0x00, 0x76, 0x00, 0x65, 0x00, 0x72, 0x00, 0x73, 0x00, 0x65, 0x00, 0x6C, + 0x00, 0x6C, 0x00, 0x65, 0x00, 0x20, 0x00, 0x64, 0x00, 0x65, 0x00, 0x73, 0x00, 0x20, + 0x00, 0x64, 0x00, 0x72, 0x00, 0x6F, 0x00, 0x69, 0x00, 0x74, 0x00, 0x73, 0x00, 0x20, + 0x00, 0x64, 0x00, 0x65, 0x00, 0x20, 0x00, 0x6C, 0x00, 0x27, 0x00, 0x68, 0x00, 0x6F, + 0x00, 0x6D, 0x00, 0x6D, 0x00, 0x65, 0x00, 0x00}; + + // Our Russian (cyrillic script) text is in UTF-16B. ASUTF8Val cyrillicStr_U16B[] = { - 0x04, 0x12, 0x04, 0x41, 0x04, 0x35, 0x04, 0x3E, - 0x04, 0x31, 0x04, 0x49, 0x04, 0x30, 0x04, 0x4F, - 0x00, 0x20, 0x04, 0x34, 0x04, 0x35, 0x04, 0x3A, - 0x04, 0x3B, 0x04, 0x30, 0x04, 0x40, 0x04, 0x30, - 0x04, 0x46, 0x04, 0x38, 0x04, 0x4F, 0x00, 0x20, - 0x04, 0x3F, 0x04, 0x40, 0x04, 0x30, 0x04, 0x32, - 0x00, 0x20, 0x04, 0x47, 0x04, 0x35, 0x04, 0x3B, - 0x04, 0x3E, 0x04, 0x32, 0x04, 0x35, 0x04, 0x3A, - 0x04, 0x30, 0x00, 0x00 - }; - - //Our Japanese text is in UTF-16B. - ASUTF8Val japaneseStr_U16B[] = { - 0x30, 0x0E, 0x4E, 0x16, 0x75, 0x4C, 0x4E, 0xBA, - 0x6A, 0x29, 0x5B, 0xA3, 0x8A, 0x00, 0x30, 0x0F, - 0x00, 0x00 - }; - //Our Korean text is in UTF-16B. - ASUTF8Val koreanStr_U16B[] = { - 0xC1, 0x38, 0x00, 0x20, 0xAC, 0xC4, 0x00, 0x20, - 0xC7, 0x78, 0x00, 0x20, 0xAD, 0x8C, 0x00, 0x20, - 0xC1, 0x20, 0x00, 0x20, 0xC5, 0xB8, 0x00, 0x00 - }; - -DURING - -// Step 2) Load the necessary fonts. - - // Font objects for both vertical AND horizontal use: - PDEFont courVFont, courHFont; // Courier - for English and French - PDEFont kozgVFont, kozgHFont; // Kozgo - for Japanese Cyrillic - PDEFont myunVFont, myunHFont; // Myungjo - for Korean - - //These arrays will be used to initialize our fonts. Each column here is for one font. - // They should all be in the PDFL distribution, and we use bosh horizontal and vertical. - const char *fontNames[] = {"CourierStd", "KozGoPr6N-Medium", "AdobeMyungjoStd-Medium"}; - PDEFont *fontsV[] = {&courVFont, &kozgVFont, &myunVFont }; - PDEFont *fontsH[] = {&courHFont, &kozgHFont, &myunHFont }; - - //These properties are common to all fonts, so are specified out here before the initialization loop. - - //The system encoding used to translate code points to font GIDs for horizontally-texts. - PDSysEncoding iHEnc = PDSysEncodingCreateFromCMapName(ASAtomFromString("Identity-H")); - //The same, for vertically-placed texts. - PDSysEncoding iVEnc = PDSysEncodingCreateFromCMapName(ASAtomFromString("Identity-V")); - //All our fonts are this type, otherwise this would have been another array. - const char *fontType = "Type0"; - - //The flags CreateEmbedded, WillSubset, and CreateToUnicode are promises - // on our part to do these things. See the "PDEFontSubsetNow" calls. - PDEFontCreateFlags fontFlags = (PDEFontCreateFlags) - (kPDEFontCreateEmbedded | kPDEFontWillSubset | kPDEFontCreateToUnicode | kPDEFontEncodeByGID); - - //This loop will load each font according to the properties just specified. - // A PDFL exception will be thrown here and caught in the handler if a font can't be found. - PDEFontAttrs nextFontAttrs; - PDSysFont nextSysFont; - for (int i = 0; i < NUM_FONTS_SAMPLE; ++i) - { - memset(&nextFontAttrs, 0, sizeof(nextFontAttrs)); - nextFontAttrs.name = ASAtomFromString(fontNames[i]); - nextFontAttrs.type = ASAtomFromString(fontType); - - nextSysFont = PDFindSysFont(&nextFontAttrs, sizeof(PDEFontAttrs), 0); - - *fontsV[i] = PDEFontCreateFromSysFontAndEncoding(nextSysFont, iVEnc, nextFontAttrs.name, fontFlags); - *fontsH[i] = PDEFontCreateFromSysFontAndEncoding(nextSysFont, iHEnc, nextFontAttrs.name, fontFlags); - } - -// Step 3) Prepare the text objects and check for font compatibility. - - ASText enAST = ASTextFromUnicode((ASUTF16Val*)englishStr_U8, kUTF8); - - //This takes advantage of the fact that all ASCII code points are identical to their - // UTF-8 counterparts. It's simpler if it's all ASText objects. - ASText enTTL = ASTextFromUnicode((ASUTF16Val*)"English", kUTF8); - ASText frAST = ASTextFromUnicode((ASUTF16Val*)frenchStr_U16B, kUTF16BigEndian); - ASText frTTL = ASTextFromUnicode((ASUTF16Val*)"French", kUTF8); - - ASText jnAST = ASTextFromUnicode((ASUTF16Val*)japaneseStr_U16B, kUTF16BigEndian); - ASText jnTTL = ASTextFromUnicode((ASUTF16Val*)"Japanese", kUTF8); - - ASText krAST = ASTextFromUnicode((ASUTF16Val*)koreanStr_U16B, kUTF16BigEndian); - ASText krTTL = ASTextFromUnicode((ASUTF16Val*)"Korean", kUTF8); - - ASText ruAST = ASTextFromUnicode((ASUTF16Val*)cyrillicStr_U16B, kUTF16BigEndian); - ASText ruTTL = ASTextFromUnicode((ASUTF16Val*)"Russian", kUTF8); - - struct textAndFont { - ASText* text; //The ASText object containing the text we'll draw to the PDF. - ASText* title; //The title for this font will be drawn with the horizontal text. - PDEFont* fontH; //the horizontally-oriented font to use. - PDEFont* fontV; //The vertically-oriented font to use. - }; - - //This array associates each ASText object with the vertical (V) and horizontal (H) - // fonts we want to use for it. This is the order they will be drawn in. - textAndFont textsAndFonts[] = { - { &enAST, &enTTL, &courHFont, &courVFont}, //The English ASText and associated fonts. - { &jnAST, &jnTTL, &kozgHFont, &kozgVFont}, //Japanese... - { &frAST, &frTTL, &courHFont, &courVFont}, //French... - { &krAST, &krTTL, &myunHFont, &myunVFont}, //Korean... - { &ruAST, &ruTTL, &kozgHFont, &kozgVFont}, //Russian... - }; - - //We need to check that each text is actually representable in the fonts we associated with it. - // It is entirely possible, and indeed usual, for fonts to not support every possible - // Unicode character, even for common languages. We will however assume that Courier, - // the font we're using for the titles, can support the titles, since they're just ASCII. - - // This will be set to the index in the string of the first unrepresentable character - ASUns32 firstBadGlyph = 0; - for (int i = 0; i < NUM_TEXTS; ++i) - { - for (int f = 0; f < 2; f++) - { - const char* errString = ""; - PDEFont* nextFont = NULL; - - switch (f) - { - case (0): - errString = "horizontal"; - nextFont = textsAndFonts[i].fontH; - break; - case (1) : - errString = "vertical"; - nextFont = textsAndFonts[i].fontV; - break; - } - - if (!PDEFontCheckASTextIsRepresentable(*nextFont, *textsAndFonts[i].text, &firstBadGlyph)) - { - PDEFontAttrs badFontAttrs; - PDEFontGetAttrs(*nextFont, &badFontAttrs, sizeof(PDEFontAttrs)); - - std::cout << "Error: The " << errString << "font associated with the" << i - << "th text " << ASAtomGetString(badFontAttrs.name) - << " has no glyph for the text's " << firstBadGlyph << "th character." - << std::endl; + 0x04, 0x12, 0x04, 0x41, 0x04, 0x35, 0x04, 0x3E, 0x04, 0x31, 0x04, 0x49, 0x04, 0x30, + 0x04, 0x4F, 0x00, 0x20, 0x04, 0x34, 0x04, 0x35, 0x04, 0x3A, 0x04, 0x3B, 0x04, 0x30, + 0x04, 0x40, 0x04, 0x30, 0x04, 0x46, 0x04, 0x38, 0x04, 0x4F, 0x00, 0x20, 0x04, 0x3F, + 0x04, 0x40, 0x04, 0x30, 0x04, 0x32, 0x00, 0x20, 0x04, 0x47, 0x04, 0x35, 0x04, 0x3B, + 0x04, 0x3E, 0x04, 0x32, 0x04, 0x35, 0x04, 0x3A, 0x04, 0x30, 0x00, 0x00}; + + // Our Japanese text is in UTF-16B. + ASUTF8Val japaneseStr_U16B[] = {0x30, 0x0E, 0x4E, 0x16, 0x75, 0x4C, 0x4E, 0xBA, 0x6A, + 0x29, 0x5B, 0xA3, 0x8A, 0x00, 0x30, 0x0F, 0x00, 0x00}; + // Our Korean text is in UTF-16B. + ASUTF8Val koreanStr_U16B[] = {0xC1, 0x38, 0x00, 0x20, 0xAC, 0xC4, 0x00, 0x20, + 0xC7, 0x78, 0x00, 0x20, 0xAD, 0x8C, 0x00, 0x20, + 0xC1, 0x20, 0x00, 0x20, 0xC5, 0xB8, 0x00, 0x00}; + + DURING + + // Step 2) Load the necessary fonts. + + // Font objects for both vertical AND horizontal use: + PDEFont courVFont, courHFont; // Courier - for English and French + PDEFont kozgVFont, kozgHFont; // Kozgo - for Japanese Cyrillic + PDEFont myunVFont, myunHFont; // Myungjo - for Korean + + // These arrays will be used to initialize our fonts. Each column here is for one font. + // They should all be in the PDFL distribution, and we use bosh horizontal and vertical. + const char *fontNames[] = {"CourierStd", "KozGoPr6N-Medium", "AdobeMyungjoStd-Medium"}; + PDEFont *fontsV[] = {&courVFont, &kozgVFont, &myunVFont}; + PDEFont *fontsH[] = {&courHFont, &kozgHFont, &myunHFont}; + + // These properties are common to all fonts, so are specified out here before the initialization loop. + + // The system encoding used to translate code points to font GIDs for horizontally-texts. + PDSysEncoding iHEnc = PDSysEncodingCreateFromCMapName(ASAtomFromString("Identity-H")); + // The same, for vertically-placed texts. + PDSysEncoding iVEnc = PDSysEncodingCreateFromCMapName(ASAtomFromString("Identity-V")); + // All our fonts are this type, otherwise this would have been another array. + const char *fontType = "Type0"; + + // The flags CreateEmbedded, WillSubset, and CreateToUnicode are promises + // on our part to do these things. See the "PDEFontSubsetNow" calls. + PDEFontCreateFlags fontFlags = (PDEFontCreateFlags)( + kPDEFontCreateEmbedded | kPDEFontWillSubset | kPDEFontCreateToUnicode | kPDEFontEncodeByGID); + + // This loop will load each font according to the properties just specified. + // A PDFL exception will be thrown here and caught in the handler if a font can't be found. + PDEFontAttrs nextFontAttrs; + PDSysFont nextSysFont; + for (int i = 0; i < NUM_FONTS_SAMPLE; ++i) { + memset(&nextFontAttrs, 0, sizeof(nextFontAttrs)); + nextFontAttrs.name = ASAtomFromString(fontNames[i]); + nextFontAttrs.type = ASAtomFromString(fontType); + + nextSysFont = PDFindSysFont(&nextFontAttrs, sizeof(PDEFontAttrs), 0); + + *fontsV[i] = PDEFontCreateFromSysFontAndEncoding(nextSysFont, iVEnc, nextFontAttrs.name, fontFlags); + *fontsH[i] = PDEFontCreateFromSysFontAndEncoding(nextSysFont, iHEnc, nextFontAttrs.name, fontFlags); + } - return -1; + // Step 3) Prepare the text objects and check for font compatibility. + + ASText enAST = ASTextFromUnicode((ASUTF16Val *)englishStr_U8, kUTF8); + + // This takes advantage of the fact that all ASCII code points are identical to their + // UTF-8 counterparts. It's simpler if it's all ASText objects. + ASText enTTL = ASTextFromUnicode((ASUTF16Val *)"English", kUTF8); + ASText frAST = ASTextFromUnicode((ASUTF16Val *)frenchStr_U16B, kUTF16BigEndian); + ASText frTTL = ASTextFromUnicode((ASUTF16Val *)"French", kUTF8); + + ASText jnAST = ASTextFromUnicode((ASUTF16Val *)japaneseStr_U16B, kUTF16BigEndian); + ASText jnTTL = ASTextFromUnicode((ASUTF16Val *)"Japanese", kUTF8); + + ASText krAST = ASTextFromUnicode((ASUTF16Val *)koreanStr_U16B, kUTF16BigEndian); + ASText krTTL = ASTextFromUnicode((ASUTF16Val *)"Korean", kUTF8); + + ASText ruAST = ASTextFromUnicode((ASUTF16Val *)cyrillicStr_U16B, kUTF16BigEndian); + ASText ruTTL = ASTextFromUnicode((ASUTF16Val *)"Russian", kUTF8); + + struct textAndFont { + ASText *text; // The ASText object containing the text we'll draw to the PDF. + ASText *title; // The title for this font will be drawn with the horizontal text. + PDEFont *fontH; // the horizontally-oriented font to use. + PDEFont *fontV; // The vertically-oriented font to use. + }; + + // This array associates each ASText object with the vertical (V) and horizontal (H) + // fonts we want to use for it. This is the order they will be drawn in. + textAndFont textsAndFonts[] = { + {&enAST, &enTTL, &courHFont, &courVFont}, // The English ASText and associated fonts. + {&jnAST, &jnTTL, &kozgHFont, &kozgVFont}, // Japanese... + {&frAST, &frTTL, &courHFont, &courVFont}, // French... + {&krAST, &krTTL, &myunHFont, &myunVFont}, // Korean... + {&ruAST, &ruTTL, &kozgHFont, &kozgVFont}, // Russian... + }; + + // We need to check that each text is actually representable in the fonts we associated with it. + // It is entirely possible, and indeed usual, for fonts to not support every possible + // Unicode character, even for common languages. We will however assume that Courier, + // the font we're using for the titles, can support the titles, since they're just ASCII. + + // This will be set to the index in the string of the first unrepresentable character + ASUns32 firstBadGlyph = 0; + for (int i = 0; i < NUM_TEXTS; ++i) { + for (int f = 0; f < 2; f++) { + const char *errString = ""; + PDEFont *nextFont = NULL; + + switch (f) { + case (0): + errString = "horizontal"; + nextFont = textsAndFonts[i].fontH; + break; + case (1): + errString = "vertical"; + nextFont = textsAndFonts[i].fontV; + break; + } + + if (!PDEFontCheckASTextIsRepresentable(*nextFont, *textsAndFonts[i].text, &firstBadGlyph)) { + PDEFontAttrs badFontAttrs; + PDEFontGetAttrs(*nextFont, &badFontAttrs, sizeof(PDEFontAttrs)); + + std::cout << "Error: The " << errString << "font associated with the" << i << "th text " + << ASAtomGetString(badFontAttrs.name) << " has no glyph for the text's " + << firstBadGlyph << "th character." << std::endl; + + return -1; + } } } - } -// Step 4) Prepare to draw the texts to a new document. - - //Create the output document - APDFLDoc outDoc; - - // Insert 8.5" by 7.5" pages for the horizontal and vertical text. - outDoc.insertPage(FloatToASFixed(8.5 * 72),FloatToASFixed(11 * 72),kPDEBeforeFirst); - outDoc.insertPage(FloatToASFixed(8.5 * 72),FloatToASFixed(11 * 72),kPDEBeforeFirst); - - // Prepare first page for horizontal texts - PDPage horzPage = outDoc.getPage(0); - PDEContent horzPageCont = PDPageAcquirePDEContent(horzPage, 0); - PDEText horzTexts = PDETextCreate(); - - // Prepare first page for vertical texts - PDPage vertPage = outDoc.getPage(1); - PDEContent vertPageCont = PDPageAcquirePDEContent(vertPage, 0); - PDEText vertTexts = PDETextCreate(); - - // Retrieve the page bounds (it is the same for both pages, of course) - ASFixedRect pageRect; - PDPageGetCropBox(horzPage, &pageRect); - - // Matrices for placing text for each page - ASFixedMatrix horzPlaceMatrix; - memset(&horzPlaceMatrix, 0, sizeof(horzPlaceMatrix)); - ASFixedMatrix vertPlaceMatrix; - memset(&vertPlaceMatrix, 0, sizeof(vertPlaceMatrix)); - - // Both matrices may be initialized the same way to start out - vertPlaceMatrix.a = horzPlaceMatrix.a = Int16ToFixed(14); //Font width, in points. - vertPlaceMatrix.d = horzPlaceMatrix.d = Int16ToFixed(14); //Font height, in points. - vertPlaceMatrix.h = horzPlaceMatrix.h = Int16ToFixed(1 * 72); // X coordinate on page: 1" from left side. - vertPlaceMatrix.v = horzPlaceMatrix.v = pageRect.top - Int16ToFixed(1 * 72); // Y coordinate on page: 1" from the top. - - //We'll draw the text with whatever the default graphics state is. - PDEGraphicState graphics; - PDEDefaultGState(&graphics, sizeof(PDEGraphicState)); - -// Step 5) Draw the texts, and subset the fonts we used. - - // Iterate through each ASText, placing both the horizontal and vertical forms, - // as well as the title for the horizontal text. - for (int i = 0; i < NUM_TEXTS; ++i) - { - //The title for the horizontal text. We'll use the Courier horizontal font for consistency. - PDETextAddASText(horzTexts, kPDETextRun, i, *textsAndFonts[i].title, courHFont, - &graphics, sizeof(graphics), NULL, 0, &horzPlaceMatrix); - - //Advance the y value by the height of the font, plus a little padding. - horzPlaceMatrix.v -= horzPlaceMatrix.d + Int16ToFixed(10); - - //The horizontal text. This procedure converts the Unicode into Glyph IDs for specified font. - PDETextAddASText(horzTexts, kPDETextRun, i+NUM_TEXTS, *textsAndFonts[i].text, - *textsAndFonts[i].fontH, &graphics, sizeof(graphics), NULL, 0, &horzPlaceMatrix); - //Advance the y value by the height of the font, plus a lot of padding. - horzPlaceMatrix.v -= horzPlaceMatrix.d + Int16ToFixed(30); - - //The vertical text. Same as above. - PDETextAddASText(vertTexts, kPDETextRun, i, *textsAndFonts[i].text, - *textsAndFonts[i].fontV, &graphics, sizeof(graphics), NULL, 0, &vertPlaceMatrix); - //Advance the x value by the width of the font, plus some padding. - vertPlaceMatrix.h += vertPlaceMatrix.a + Int16ToFixed(20); - } + // Step 4) Prepare to draw the texts to a new document. + + // Create the output document + APDFLDoc outDoc; + + // Insert 8.5" by 7.5" pages for the horizontal and vertical text. + outDoc.insertPage(FloatToASFixed(8.5 * 72), FloatToASFixed(11 * 72), kPDEBeforeFirst); + outDoc.insertPage(FloatToASFixed(8.5 * 72), FloatToASFixed(11 * 72), kPDEBeforeFirst); + + // Prepare first page for horizontal texts + PDPage horzPage = outDoc.getPage(0); + PDEContent horzPageCont = PDPageAcquirePDEContent(horzPage, 0); + PDEText horzTexts = PDETextCreate(); + + // Prepare first page for vertical texts + PDPage vertPage = outDoc.getPage(1); + PDEContent vertPageCont = PDPageAcquirePDEContent(vertPage, 0); + PDEText vertTexts = PDETextCreate(); + + // Retrieve the page bounds (it is the same for both pages, of course) + ASFixedRect pageRect; + PDPageGetCropBox(horzPage, &pageRect); + + // Matrices for placing text for each page + ASFixedMatrix horzPlaceMatrix; + memset(&horzPlaceMatrix, 0, sizeof(horzPlaceMatrix)); + ASFixedMatrix vertPlaceMatrix; + memset(&vertPlaceMatrix, 0, sizeof(vertPlaceMatrix)); + + // Both matrices may be initialized the same way to start out + vertPlaceMatrix.a = horzPlaceMatrix.a = Int16ToFixed(14); // Font width, in points. + vertPlaceMatrix.d = horzPlaceMatrix.d = Int16ToFixed(14); // Font height, in points. + vertPlaceMatrix.h = horzPlaceMatrix.h = Int16ToFixed(1 * 72); // X coordinate on page: 1" from left side. + vertPlaceMatrix.v = horzPlaceMatrix.v = + pageRect.top - Int16ToFixed(1 * 72); // Y coordinate on page: 1" from the top. + + // We'll draw the text with whatever the default graphics state is. + PDEGraphicState graphics; + PDEDefaultGState(&graphics, sizeof(PDEGraphicState)); + + // Step 5) Draw the texts, and subset the fonts we used. + + // Iterate through each ASText, placing both the horizontal and vertical forms, + // as well as the title for the horizontal text. + for (int i = 0; i < NUM_TEXTS; ++i) { + // The title for the horizontal text. We'll use the Courier horizontal font for consistency. + PDETextAddASText(horzTexts, kPDETextRun, i, *textsAndFonts[i].title, courHFont, + &graphics, sizeof(graphics), NULL, 0, &horzPlaceMatrix); + + // Advance the y value by the height of the font, plus a little padding. + horzPlaceMatrix.v -= horzPlaceMatrix.d + Int16ToFixed(10); + + // The horizontal text. This procedure converts the Unicode into Glyph IDs for specified font. + PDETextAddASText(horzTexts, kPDETextRun, i + NUM_TEXTS, *textsAndFonts[i].text, + *textsAndFonts[i].fontH, &graphics, sizeof(graphics), NULL, 0, &horzPlaceMatrix); + // Advance the y value by the height of the font, plus a lot of padding. + horzPlaceMatrix.v -= horzPlaceMatrix.d + Int16ToFixed(30); + + // The vertical text. Same as above. + PDETextAddASText(vertTexts, kPDETextRun, i, *textsAndFonts[i].text, *textsAndFonts[i].fontV, + &graphics, sizeof(graphics), NULL, 0, &vertPlaceMatrix); + // Advance the x value by the width of the font, plus some padding. + vertPlaceMatrix.h += vertPlaceMatrix.a + Int16ToFixed(20); + } - //Add the text elements to the content and place into the page - PDEContentAddElem(horzPageCont, kPDEBeforeFirst, (PDEElement) horzTexts); - PDPageSetPDEContentCanRaise(horzPage, 0); - - PDEContentAddElem(vertPageCont, kPDEBeforeFirst, (PDEElement) vertTexts); - PDPageSetPDEContentCanRaise(vertPage, 0); - - //Simply calling "SubsetNow" subsets the font, creates a ToUnicode table (which maps Glyph IDs - // to Unicode), and creates widths. You don't need to call all three methods separately anymore. - // Remember, if you do this, you must use the kPDEFontWillSubset font flag during font retrieval, - // and vice versa. - CosDoc cosDoc = PDDocGetCosDoc(outDoc.getPDDoc()); - for (int i = 0; i < NUM_TEXTS; ++i) - { - PDEFontSubsetNow(*textsAndFonts[i].fontV, cosDoc); - PDEFontSubsetNow(*textsAndFonts[i].fontH, cosDoc); - } + // Add the text elements to the content and place into the page + PDEContentAddElem(horzPageCont, kPDEBeforeFirst, (PDEElement)horzTexts); + PDPageSetPDEContentCanRaise(horzPage, 0); + + PDEContentAddElem(vertPageCont, kPDEBeforeFirst, (PDEElement)vertTexts); + PDPageSetPDEContentCanRaise(vertPage, 0); + + // Simply calling "SubsetNow" subsets the font, creates a ToUnicode table (which maps Glyph IDs + // to Unicode), and creates widths. You don't need to call all three methods separately anymore. + // Remember, if you do this, you must use the kPDEFontWillSubset font flag during font retrieval, + // and vice versa. + CosDoc cosDoc = PDDocGetCosDoc(outDoc.getPDDoc()); + for (int i = 0; i < NUM_TEXTS; ++i) { + PDEFontSubsetNow(*textsAndFonts[i].fontV, cosDoc); + PDEFontSubsetNow(*textsAndFonts[i].fontH, cosDoc); + } -// Step 6) Release resources, save, and close. + // Step 6) Release resources, save, and close. - //Release the text objects. + // Release the text objects. PDERelease((PDEObject)horzTexts); PDERelease((PDEObject)vertTexts); - //Release the PDEContents so we can release the pages. + // Release the PDEContents so we can release the pages. PDPageReleasePDEContent(horzPage, 0); PDPageReleasePDEContent(vertPage, 0); - //Release the pages so we can close the document. + // Release the pages so we can close the document. PDPageRelease(horzPage); PDPageRelease(vertPage); - //Destroy all the ASText objects we made. - //We can't also release the fonts with textsAndFonts, since some texts use the same fonts. - for (int i = 0; i < NUM_TEXTS; ++i) - { - ASTextDestroy(*textsAndFonts[i].text); + // Destroy all the ASText objects we made. + // We can't also release the fonts with textsAndFonts, since some texts use the same fonts. + for (int i = 0; i < NUM_TEXTS; ++i) { + ASTextDestroy(*textsAndFonts[i].text); ASTextDestroy(*textsAndFonts[i].title); } - //Release the PDSysEncodings + // Release the PDSysEncodings PDERelease((PDEObject)iHEnc); PDERelease((PDEObject)iVEnc); - //Release all the fonts. - for (int i = 0; i < NUM_FONTS_SAMPLE; ++i) - { + // Release all the fonts. + for (int i = 0; i < NUM_FONTS_SAMPLE; ++i) { PDERelease((PDEObject)*fontsH[i]); PDERelease((PDEObject)*fontsV[i]); } - //And graphics we used. + // And graphics we used. PDERelease((PDEObject)graphics.fillColorSpec.space); PDERelease((PDEObject)graphics.strokeColorSpec.space); - outDoc.saveDoc ( csOutputFileName.c_str() ); + outDoc.saveDoc(csOutputFileName.c_str()); -HANDLER - errCode = ERRORCODE; - libInit.displayError(errCode); -END_HANDLER + HANDLER + errCode = ERRORCODE; + libInit.displayError(errCode); + END_HANDLER - return errCode; + return errCode; } diff --git a/CPlusPlus/Sample_Source/_Common/APDFLDoc.cpp b/CPlusPlus/Sample_Source/_Common/APDFLDoc.cpp index 53a20ace..44245992 100644 --- a/CPlusPlus/Sample_Source/_Common/APDFLDoc.cpp +++ b/CPlusPlus/Sample_Source/_Common/APDFLDoc.cpp @@ -14,6 +14,7 @@ #include "APDFLDoc.h" #include #include +#include //============================================================================================================================== // Default Constructor - This creates a new PDDoc object. This object will be automatically freed in the APDFLDoc's destructor. @@ -261,8 +262,7 @@ ASErrorCode APDFLDoc::insertPage(const ASFixed &width, const ASFixed &height, AS DURING - PDPage pdPage; - + PDPage pdPage = NULL; // Set the page dimensions before creating the PDPage. ASFixedRect mediaBox; mediaBox.left = fixedZero; @@ -273,7 +273,6 @@ ASErrorCode APDFLDoc::insertPage(const ASFixed &width, const ASFixed &height, AS pdPage = PDDocCreatePage(pdDoc, afterPageNum, mediaBox); // Create and insert a page into the PDDoc. PDPageRelease(pdPage); // Release the PDPage object. - pdPage = NULL; HANDLER @@ -333,7 +332,7 @@ ASErrorCode APDFLDoc::printErrorHandlerMessage() { // ~APDFLDoc() - Releases resources if they haven't already been freed. //============================================================================================================================== -APDFLDoc::~APDFLDoc() { +APDFLDoc::~APDFLDoc() noexcept(false) { DURING if (pdDoc != NULL) // Close the PDDoc diff --git a/CPlusPlus/Sample_Source/_Common/APDFLDoc.h b/CPlusPlus/Sample_Source/_Common/APDFLDoc.h index 8ac4002f..90db2ed4 100644 --- a/CPlusPlus/Sample_Source/_Common/APDFLDoc.h +++ b/CPlusPlus/Sample_Source/_Common/APDFLDoc.h @@ -3,12 +3,12 @@ // http://dev.datalogics.com/adobe-pdf-library/license-for-downloaded-pdf-samples/ // //=============================================================================== -//Sample: APDFLDoc -This class is intended to assist with operations common to -//most samples. The class is capable of opening/creating and saving a document. -//It can also insert and retrieve pages. +// Sample: APDFLDoc -This class is intended to assist with operations common to +// most samples. The class is capable of opening/creating and saving a document. +// It can also insert and retrieve pages. // -//APDFLDoc.cpp: Contains implementations of methods. -//APDFLDoc.h: Contains class definition. +// APDFLDoc.cpp: Contains implementations of methods. +// APDFLDoc.h: Contains class definition. //=============================================================================== #ifndef APDFLDOC_H @@ -18,53 +18,62 @@ #include "ASCalls.h" #include "ASExtraCalls.h" -#include #include +#include -class APDFLDoc { +#if defined(WIN_ENV) +// turn off a misleading windows-specific warning +#pragma warning( disable : 4290 ) +#endif -private: +class APDFLDoc { - static const unsigned MAX_PATH_LENGTH = 1024; //Private data members assosciated with the document. + private: + static const unsigned MAX_PATH_LENGTH = 1024; // Private data members assosciated with the document. wchar_t nameOfDocument[MAX_PATH_LENGTH]; - volatile ASPathName asPathName; + ASPathName asPathName; ASErrorCode errorCode; - void initialize(); //Called in constructor to initialize some data members. - ASErrorCode printErrorHandlerMessage(); //Prints an error message and returns the appropriate error code. - ASErrorCode setASPathName(wchar_t* ); //Helper method used to create ASPathName objects for operations. - void CommonConstruct(wchar_t*,bool); //Helper to allow char* overload of constructor with minimal code copying + void initialize(); // Called in constructor to initialize some data members. + ASErrorCode printErrorHandlerMessage(); // Prints an error message and returns the appropriate error code. + ASErrorCode setASPathName(wchar_t *); // Helper method used to create ASPathName objects for operations. + void CommonConstruct(wchar_t *, bool); // Helper to allow char* overload of constructor with minimal code copying - APDFLDoc(const APDFLDoc&); //Do not allow copy constructor or assignment operator to be used. - APDFLDoc& operator=(const APDFLDoc&); //in order to prevent shallow copies of objects. + APDFLDoc(const APDFLDoc &); // Do not allow copy constructor or assignment operator to be used. + APDFLDoc &operator=(const APDFLDoc &); // in order to prevent shallow copies of objects. -public: + public: + PDDoc pdDoc = nullptr; // Made public so it can be accessed directly. - volatile PDDoc pdDoc; //Made public so it can be accessed directly. + APDFLDoc(wchar_t *, bool doRepairDamagedFile); // Constructor used to open a document. + APDFLDoc(const char *, bool doRepairDamagedFile); // Constructor used to open a document. + APDFLDoc(); // Constructor used to create a document. - APDFLDoc(wchar_t*, bool doRepairDamagedFile); //Constructor used to open a document. - APDFLDoc(const char*, bool doRepairDamagedFile); //Constructor used to open a document. - APDFLDoc(); //Constructor used to create a document. + ASSize_t numPages() { return (PDDocGetNumPages(pdDoc)); } - ASSize_t numPages () { return (PDDocGetNumPages (pdDoc)); } + ASErrorCode insertPage(const ASFixed &width, const ASFixed &height, ASInt32); // Inserts a page into the document. + ASErrorCode insertPage(const ASInt16 &width, const ASInt16 &height, ASInt32); // Inserts a page into the document. + PDPage getPage(ASInt32); // Returns the specified PDPage, the first page is 0. - ASErrorCode insertPage(const ASFixed & width, const ASFixed & height, ASInt32); //Inserts a page into the document. - ASErrorCode insertPage(const ASInt16 & width, const ASInt16 & height, ASInt32); //Inserts a page into the document. - PDPage getPage(ASInt32); //Returns the specified PDPage, the first page is 0. + PDDoc getPDDoc() { + return pdDoc; + }; // Returns the PDDoc that was created or opened. - volatile PDDoc& getPDDoc(){ return pdDoc; }; //Returns a reference to the PDDoc that was created or opened. + ASErrorCode saveDoc(wchar_t * = NULL, PDSaveFlags = PDSaveFull | PDSaveLinearized, + PDSaveFlags2 saveFlags2 = PDSaveAddFlate); // Used to save the document, may be provided a path and PDSaveFlags. + ASErrorCode saveDoc(const char *, + PDSaveFlags = PDSaveFull | PDSaveLinearized, PDSaveFlags2 saveFlags2 = PDSaveAddFlate); // Used to save the document to a specified non-wide string, may be provided PDSaveFlags. - ASErrorCode saveDoc(wchar_t* = NULL, PDSaveFlags = PDSaveFull, PDSaveFlags2 saveFlags2 = 0); //Used to save the document, may be provided a path and PDSaveFlags. - ASErrorCode saveDoc(const char*, PDSaveFlags = PDSaveFull, PDSaveFlags2 saveFlags2 = 0); //Used to save the document to a specified non-wide string, may be provided PDSaveFlags. - - ~APDFLDoc(); //Destructor frees up resources. + ~APDFLDoc() noexcept(false); // Destructor frees up resources. - static ASPathName makePath(const char* path ); //Provide functionality for device independent path construction - static ASPathName makePath(const wchar_t* path ); - static ASFile OpenFlatFile ( const char* path, int mode = ASFILE_READ ); // Generic file open + static ASPathName makePath(const char *path); // Provide functionality for device independent path construction + static ASPathName makePath(const wchar_t *path); + static ASFile OpenFlatFile(const char *path, int mode = ASFILE_READ); // Generic file open - static ASUnicodeFormat GetHostUnicodeFormat() { return ( sizeof(wchar_t) == 2 ? kUTF16HostEndian : kUTF32HostEndian ); } + static ASUnicodeFormat GetHostUnicodeFormat() { + return (sizeof(wchar_t) == 2 ? kUTF16HostEndian : kUTF32HostEndian); + } }; #endif diff --git a/CPlusPlus/Sample_Source/_Common/APDFLDoc/APDFLDoc.cpp b/CPlusPlus/Sample_Source/_Common/APDFLDoc/APDFLDoc.cpp deleted file mode 100644 index 499f5535..00000000 --- a/CPlusPlus/Sample_Source/_Common/APDFLDoc/APDFLDoc.cpp +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright (c) 2015, Datalogics, Inc. All rights reserved. -// -// http://dev.datalogics.com/adobe-pdf-library/license-for-downloaded-pdf-samples/ -// -//=============================================================================== -//Sample: APDFLDoc -This class is intended to assist with operations common to -//most samples. The class is capable of opening/creating and saving a document. -//It can also insert and retrieve pages. -// -//APDFLDoc.cpp: Contains the method implementations. -//APDFLDoc.h: Contains the class definition. -//=============================================================================== - -#include "APDFLDoc.h" - -//============================================================================================================================== -// Default Constructor - This creates a new PDDoc object. This object will be automatically freed in the APDFLDoc's destructor. -//============================================================================================================================== - -APDFLDoc::APDFLDoc() -{ - - initialize(); //Helper method sets some of the data members to NULL values. - - DURING - - pdDoc = PDDocCreate(); //Initialize the PDDoc data member. - - HANDLER - - printErrorHandlerMessage(); - - RERAISE(); //Pass exception to the next HANDLER on the stack. - - END_HANDLER -} - -//============================================================================================================================== -// Constructor - This constructor opens an existing PDF document. nameOfDocument is the relative path for the PDF document -// and the bool repairDamagedFile determines whether to repair (true) or not (false) a damaged file. -//============================================================================================================================== - -APDFLDoc::APDFLDoc(wchar_t * nameOfDocument, bool repairDamagedFile) -{ - - initialize(); - - wcscpy(this->nameOfDocument, nameOfDocument); //Set the nameOfDocument data member. - - DURING - - setASPathName(this->nameOfDocument); //Set the ASPathName data member. - - pdDoc = PDDocOpen(asPathName, NULL, NULL, repairDamagedFile); //Open the PDF document. - - ASFileSysReleasePath(NULL, asPathName); //Release the ASPathName that was just created. - asPathName = NULL; - - HANDLER - - printErrorHandlerMessage(); //Report any exceptions that occured. - - RERAISE(); //Pass the exception to the next handler on the stack. - - END_HANDLER -} - -//============================================================================================================================== -// initialize() - Helper method used to initialize data members to NULL values. -//============================================================================================================================== - -void APDFLDoc::initialize() -{ - pdDoc = NULL; - asPathName = NULL; - errorCode = 0; - nameOfDocument[0] = L'\0'; -} - -//============================================================================================================================== -// saveDoc() - This method saves the PDDoc. If pathToSaveDoc is supplied it will save to the location specified. If it is -// not supplied it will overwrite the documents original location. The document will do a complete save by default, but other -// flags may be specified. -//============================================================================================================================== - -ASErrorCode APDFLDoc::saveDoc(wchar_t * pathToSaveDoc, PDSaveFlags saveFlags) -{ - - DURING - - //Error checking: Ensure a name has been set before saving the document. - if (pathToSaveDoc == NULL && nameOfDocument[0] == L'\0') - { - std::wcerr << L"Failed to save document ensure PDDoc has a valid name before saving. " << std::endl; - errorCode = -1; - return errorCode; - } - - //Error checking: Ensure that the ASPathName has been set before saving the document. - if (pathToSaveDoc != NULL) - setASPathName(pathToSaveDoc); //Use the path specified in saveDoc if it's been set. - else - setASPathName(nameOfDocument); //Overwrite the original document if it hasn't been set. - - //Error Checking: Ensure document has a page before saving. - if (PDDocGetNumPages(pdDoc) > 0) - PDDocSave(pdDoc, saveFlags, asPathName, NULL, NULL, NULL); - else - { - std::wcerr << L"Failed to save document ensure PDDoc has pages. " << std::endl; - errorCode = -2; - } - - ASFileSysReleasePath(NULL, asPathName); //Release ASPathName object and set to NULL. - asPathName = NULL; - - HANDLER - - return printErrorHandlerMessage(); //Return the error code that was generated by the exception. - - END_HANDLER - - return errorCode; -} - -//============================================================================================================================== -// setASPAthName() - Helper method used to create an ASPathName. This is called by the saveDoc and open document constructor. -//============================================================================================================================== - -ASErrorCode APDFLDoc::setASPathName(wchar_t * pathToCreate) -{ - //Check to make sure there is room for path before copy - if (wcslen(pathToCreate) <= MAX_PATH_LENGTH) - wcscpy(this->nameOfDocument, pathToCreate); - else - { - std::wcerr << L"Failed to create path, please check length of path name." << std::endl; - return -1; - } - - ASText textToCreatePath = NULL; //Text object to create ASPathName - - DURING - - //Determine size of wchar_t on system and get the ASText - if (sizeof(wchar_t) == 2) - textToCreatePath = ASTextFromUnicode(reinterpret_cast (nameOfDocument), kUTF16HostEndian); - else - textToCreatePath = ASTextFromUnicode(reinterpret_cast(nameOfDocument), kUTF32HostEndian); - - //Create the path for output file - asPathName = ASFileSysCreatePathFromDIPathText(NULL, textToCreatePath, NULL); - - HANDLER - - return printErrorHandlerMessage(); //Return error code that was generated by exception - - END_HANDLER - - ASTextDestroy(textToCreatePath); //Release text object - - return errorCode; -} - -//============================================================================================================================== -// insertPage() - Inserts a page into the PDDoc when provided ASFixed values for width, height and the location where the -// page will be inserted. The PDPage created is deallocated at the end of this method. -//============================================================================================================================== - -ASErrorCode APDFLDoc::insertPage(const ASFixed & width, const ASFixed & height, ASInt32 afterPageNum) -{ - - DURING - - PDPage pdPage; - - //Set the page dimensions before creating the PDPage. - ASFixedRect mediaBox; - mediaBox.left = fixedZero; - mediaBox.right = width; - mediaBox.bottom = fixedZero; - mediaBox.top = height; - - pdPage = PDDocCreatePage(pdDoc, afterPageNum, mediaBox); //Create and insert a page into the PDDoc. - - PDPageRelease(pdPage); //Release the PDPage object. - pdPage = NULL; - - HANDLER - - return printErrorHandlerMessage(); //Return the error code that was generated by the exception. - - END_HANDLER - - return errorCode; -} - -//============================================================================================================================== -// insertPage() - This is the overloaded method that takes integer arguments instead of ASFixed values. -//============================================================================================================================== - -ASErrorCode APDFLDoc::insertPage(const ASInt16 & width, const ASInt16 & height, ASInt32 afterPageNum) -{ - return insertPage(Int16ToFixed(width), Int16ToFixed(height), afterPageNum); -} - -//============================================================================================================================== -// getPage() - Accessor method for pages in the PDDoc. The argument is the page index with 0 being the first page. -//============================================================================================================================== - -PDPage APDFLDoc::getPage(ASInt32 pageNumber) -{ - - PDPage pdPage = NULL; - - DURING - - pdPage = PDDocAcquirePage(pdDoc, pageNumber); //Get the page from the PDDoc object. - - HANDLER - - printErrorHandlerMessage(); //If an exception occured print the error. - - END_HANDLER - - return pdPage; -} - -//============================================================================================================================== -// printErrorHandlerMessage() - Helper method that reports errors and returns an error code. -//============================================================================================================================== -ASErrorCode APDFLDoc::printErrorHandlerMessage() -{ - - errorCode = ERRORCODE; //Get the error code that caused the exception. - - char buf[256]; - - ASGetErrorString(ERRORCODE, buf, sizeof(buf)); //Get the error message that coreesponds to the error code. - - std::cerr << "Error Code: " << errorCode << "Error Message: " << buf << std::endl; - - return errorCode; -} - -//============================================================================================================================== -// ~APDFLDoc() - Releases resources if they haven't already been freed. -//============================================================================================================================== - -APDFLDoc::~APDFLDoc() -{ - DURING - - if (pdDoc != NULL) //Close the PDDoc - PDDocClose(pdDoc); - - if (asPathName != NULL) //Close the pathname - ASFileSysReleasePath(NULL, asPathName); - - HANDLER - - printErrorHandlerMessage(); - - RERAISE(); //Pass exception to the next handler on the stack. - - END_HANDLER -} diff --git a/CPlusPlus/Sample_Source/_Common/APDFLDoc/APDFLDoc.h b/CPlusPlus/Sample_Source/_Common/APDFLDoc/APDFLDoc.h deleted file mode 100644 index 33fc4a5d..00000000 --- a/CPlusPlus/Sample_Source/_Common/APDFLDoc/APDFLDoc.h +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2015, Datalogics, Inc. All rights reserved. -// -// http://dev.datalogics.com/adobe-pdf-library/license-for-downloaded-pdf-samples/ -// -//=============================================================================== -//Sample: APDFLDoc -This class is intended to assist with operations common to -//most samples. The class is capable of opening/creating and saving a document. -//It can also insert and retrieve pages. -// -//APDFLDoc.cpp: Contains implementations of methods. -//APDFLDoc.h: Contains class definition. -//=============================================================================== - -#ifndef APDFLDOC_H -#define APDFLDOC_H - -#include "PDCalls.h" -#include "ASCalls.h" -#include "ASExtraCalls.h" - -#include -#include - -class APDFLDoc { - -private: - - static const unsigned MAX_PATH_LENGTH = 1024; //Private data members assosciated with the document. - wchar_t nameOfDocument[MAX_PATH_LENGTH]; - - volatile ASPathName asPathName; - ASErrorCode errorCode; - - void initialize(); //Called in constructor to initialize some data members. - ASErrorCode printErrorHandlerMessage(); //Prints an error message and returns the appropriate error code. - ASErrorCode setASPathName(wchar_t* ); //Helper method used to create ASPathName objects for operations. - -public: - - volatile PDDoc pdDoc; //Made public so it can be accessed directly. - - APDFLDoc(wchar_t*, bool doRepairDamagedFile); //Constructor used to open a document. - APDFLDoc(); //Constructor used to create a document. - - ASSize_t numPages () { return (PDDocGetNumPages (pdDoc)); } - - ASErrorCode insertPage(const ASFixed & width, const ASFixed & height, ASInt32); //Inserts a page into the document. - ASErrorCode insertPage(const ASInt16 & width, const ASInt16 & height, ASInt32); //Inserts a page into the document. - PDPage getPage(ASInt32); //Returns the specified PDPage, the first page is 0. - - volatile PDDoc& getPDDoc(){ return pdDoc; }; //Returns a reference to the PDDoc that was created or opened. - - ASErrorCode saveDoc(wchar_t* = NULL, PDSaveFlags = PDSaveFull); //Used to save the document, may be provided a path and PDSaveFlags. - - ~APDFLDoc(); //Destructor frees up resources. - - APDFLDoc(const APDFLDoc& ){}; //Do not allow copy constructor or assignment operator to be used. - APDFLDoc& operator=(const APDFLDoc&){}; //in order to prevent shallow copies of objects. -}; - -#endif diff --git a/CPlusPlus/Sample_Source/_Common/InitializeLibrary.h b/CPlusPlus/Sample_Source/_Common/InitializeLibrary.h index ccfee6d7..79f8b8c6 100644 --- a/CPlusPlus/Sample_Source/_Common/InitializeLibrary.h +++ b/CPlusPlus/Sample_Source/_Common/InitializeLibrary.h @@ -14,9 +14,10 @@ #ifndef INITLIB_H #define INITLIB_H -#define NUM_FONTS 2 //The number of font directories we'll include during initialization. -#define NUM_COLOR_PROFS 1 //The number of color profile directories we'll include during initialization. -#define NUM_PLUGIN_DIRS 1 //The number of plugin directories we'll include during initialization. +#define NUM_FONTS 2 // The number of font directories we'll include during initialization. +#define NUM_COLOR_PROFS \ + 1 // The number of color profile directories we'll include during initialization. +#define NUM_PLUGIN_DIRS 1 // The number of plugin directories we'll include during initialization. #include #include @@ -26,79 +27,75 @@ #ifdef AIX_GCC_COMPAT #include // DLADD RobB 31Jan2017 - RAII helper to explicitly initialize xlC libraries on AIX from a g++ main() -class GCCAIXHelper -{ - public: +class GCCAIXHelper { + public: GCCAIXHelper() - :hAXE(NULL), hXMP(NULL), hJP2K(NULL), hBIBUt(NULL), hBIB(NULL), - hACE(NULL), hARE(NULL), hAGM(NULL), hCT(NULL), hPDFL(NULL) - { - if (!(hAXE = dlopen("libDL150AXE8SharedExpat.so", RTLD_NOW | RTLD_GLOBAL))) - if (!(hXMP = dlopen("libDL150AdobeXMP.so", RTLD_NOW | RTLD_GLOBAL))) - if (!(hJP2K = dlopen("libDL150JP2K.so", RTLD_NOW | RTLD_GLOBAL))) - if (!(hBIBUt = dlopen("libDL150BIBUtils.so", RTLD_NOW | RTLD_GLOBAL))) - if (!(hBIB = dlopen("libDL150BIB.so", RTLD_NOW | RTLD_GLOBAL))) - if (!(hACE = dlopen("libDL150ACE.so", RTLD_NOW | RTLD_GLOBAL))) - if (!(hARE = dlopen("libDL150ARE.so", RTLD_NOW | RTLD_GLOBAL))) - if (!(hAGM = dlopen("libDL150AGM.so", RTLD_NOW | RTLD_GLOBAL))) - if (!(hCT = dlopen("libDL150CoolType.so", RTLD_NOW | RTLD_GLOBAL))) - hPDFL = dlopen("libDL150pdfl.so", RTLD_NOW | RTLD_GLOBAL); - } - ~GCCAIXHelper() - { - if (hPDFL) - dlclose(hPDFL); - if (hCT) - dlclose(hCT); - if (hAGM) - dlclose(hAGM); - if (hARE) - dlclose(hARE); - if (hACE) - dlclose(hACE); - if (hBIB) - dlclose(hBIB); - if (hBIBUt) - dlclose(hBIBUt); - if (hJP2K) - dlclose(hJP2K); - if (hXMP) - dlclose(hXMP); - if (hAXE) - dlclose(hAXE); - } - private: - void *hAXE, *hXMP, *hJP2K, *hBIBUt, *hBIB, *hACE, *hARE, *hAGM, *hCT, *hPDFL; + : hAXE(NULL), hXMP(NULL), hJP2K(NULL), hBIBUt(NULL), hBIB(NULL), hACE(NULL), hARE(NULL), + hAGM(NULL), hCT(NULL), hPDFL(NULL) { + if (!(hAXE = dlopen("libDL180AXE8SharedExpat.so", RTLD_NOW | RTLD_GLOBAL))) + if (!(hXMP = dlopen("libDL180AdobeXMP.so", RTLD_NOW | RTLD_GLOBAL))) + if (!(hJP2K = dlopen("libDL180JP2K.so", RTLD_NOW | RTLD_GLOBAL))) + if (!(hBIBUt = dlopen("libDL180BIBUtils.so", RTLD_NOW | RTLD_GLOBAL))) + if (!(hBIB = dlopen("libDL180BIB.so", RTLD_NOW | RTLD_GLOBAL))) + if (!(hACE = dlopen("libDL180ACE.so", RTLD_NOW | RTLD_GLOBAL))) + if (!(hARE = dlopen("libDL180ARE.so", RTLD_NOW | RTLD_GLOBAL))) + if (!(hAGM = dlopen("libDL180AGM.so", RTLD_NOW | RTLD_GLOBAL))) + if (!(hCT = dlopen("libDL180CoolType.so", RTLD_NOW | RTLD_GLOBAL))) + hPDFL = dlopen("libDL180pdfl.so", RTLD_NOW | RTLD_GLOBAL); + } + ~GCCAIXHelper() { + if (hPDFL) + dlclose(hPDFL); + if (hCT) + dlclose(hCT); + if (hAGM) + dlclose(hAGM); + if (hARE) + dlclose(hARE); + if (hACE) + dlclose(hACE); + if (hBIB) + dlclose(hBIB); + if (hBIBUt) + dlclose(hBIBUt); + if (hJP2K) + dlclose(hJP2K); + if (hXMP) + dlclose(hXMP); + if (hAXE) + dlclose(hAXE); + } + + private: + void *hAXE, *hXMP, *hJP2K, *hBIBUt, *hBIB, *hACE, *hARE, *hAGM, *hCT, *hPDFL; }; #endif // AIX_GCC_COMPAT -class APDFLib -{ -public: - APDFLib(wchar_t* dl150Dir = NULL); //Constructor initializes APDFL and sets the path to DL150PDFL.dll to dl150Dir. If NULL is passed, defaults to ../../../Binaries. dl150Dir should be a relative path. - ~APDFLib(); //Destructor terminates APDFL. +class APDFLib { + public: + APDFLib(wchar_t *dlDir = NULL); // Constructor initializes APDFL and sets the path to DL180PDFL.dll to dlDir. If NULL is passed, defaults to ../../../Binaries. dlDir should be a relative path. + ~APDFLib(); // Destructor terminates APDFL. - ASInt32 getInitError(); //Reports whether an error happened during initialization and returns that error. - ASBool isValid() { return initValid; }; //Returns true if the library initialized successfully. - static void displayError(ASErrorCode); //Utility method, may be used to print APDFL errors to the terminal. + ASInt32 getInitError(); // Reports whether an error happened during initialization and returns that error. + ASBool isValid() { return initValid; }; // Returns true if the library initialized successfully. + static void displayError(ASErrorCode); // Utility method, may be used to print APDFL errors to the terminal. -private: - APDFLib(const APDFLib&); // not implemented - PDFLDataRec pdflData; //A struct containing information that APDFL initializes with. - ASInt32 initError; //Used to record initialization errors. - ASBool initValid; //Set to true if the library initializes successfully. + private: + APDFLib(const APDFLib &); // not implemented + PDFLDataRec pdflData; // A struct containing information that APDFL initializes with. + ASInt32 initError; // Used to record initialization errors. + ASBool initValid; // Set to true if the library initializes successfully. - void fillDirectories(); //Sets directory information for our PDFLDataRec. + void fillDirectories(); // Sets directory information for our PDFLDataRec. #if WIN_PLATFORM - HINSTANCE loadDFL150PDFL(wchar_t* relativeDir); //Loads the DL150PDFL library dynamically. + HINSTANCE loadDFL180PDFL(wchar_t *relativeDir); // Loads the DL180PDFL library dynamically. #endif - ASUTF16Val* fontDirList[NUM_FONTS]; //List of font directories we'll include during initialization. //TODO: platform divergences - ASUTF16Val* colorProfDirList[NUM_COLOR_PROFS]; //List of color profile directories we'll include during initialization. //TODO: platform divergences - ASUTF16Val* pluginDirList[NUM_PLUGIN_DIRS]; //List of plugin directories we'll include during initialization. //TODO: platform divergences + ASUTF16Val *fontDirList[NUM_FONTS]; // List of font directories we'll include during initialization. //TODO: platform divergences + ASUTF16Val *colorProfDirList[NUM_COLOR_PROFS]; // List of color profile directories we'll include during initialization. //TODO: platform divergences + ASUTF16Val *pluginDirList[NUM_PLUGIN_DIRS]; // List of plugin directories we'll include during initialization. //TODO: platform divergences #if AIX_GCC_COMPAT GCCAIXHelper gccHelp; #endif - }; -#endif //INITLIB_H +#endif // INITLIB_H diff --git a/CPlusPlus/Sample_Source/_Common/SampleCustomExceptions.h b/CPlusPlus/Sample_Source/_Common/SampleCustomExceptions.h index 1eca2be6..03b501f2 100644 --- a/CPlusPlus/Sample_Source/_Common/SampleCustomExceptions.h +++ b/CPlusPlus/Sample_Source/_Common/SampleCustomExceptions.h @@ -19,95 +19,87 @@ struct UnimplementedException : public std::exception {}; struct OutOfMemoryException : public std::exception {}; -struct BadArgumentException : public std::exception -{ - public: - BadArgumentException() : std::exception() {} - BadArgumentException(const char *msg) : std::exception(msg) {} +struct BadArgumentException : public std::exception { + public: + BadArgumentException() : std::exception() {} + BadArgumentException(const char *msg) : std::exception(msg) {} }; -struct GeneralException : public std::exception -{ /* catch all for unknown conditions (and basis for more specific types) */ - public: - GeneralException() : std::exception() {} - GeneralException(const char *msg) : std::exception(msg) {} +struct GeneralException : public std::exception { /* catch all for unknown conditions (and basis for more specific types) */ + public: + GeneralException() : std::exception() {} + GeneralException(const char *msg) : std::exception(msg) {} }; -struct StringException : public GeneralException -{ /* basis for other string (usually unicode to non-unicode translations) related failures */ - public: - StringException() : GeneralException() {} - StringException(const char *msg) : GeneralException(msg) {} +struct StringException : public GeneralException { /* basis for other string (usually unicode to non-unicode translations) related failures */ + public: + StringException() : GeneralException() {} + StringException(const char *msg) : GeneralException(msg) {} }; -struct StringContainsUnsupportedUnicodeException : public StringException -{ /* at times, pdfl cannot support unicode */ - public: - StringContainsUnsupportedUnicodeException() : StringException() {} - StringContainsUnsupportedUnicodeException(const char *msg) : StringException(msg) {} +struct StringContainsUnsupportedUnicodeException + : public StringException { /* at times, pdfl cannot support unicode */ + public: + StringContainsUnsupportedUnicodeException() : StringException() {} + StringContainsUnsupportedUnicodeException(const char *msg) : StringException(msg) {} }; -struct FileException : public GeneralException -{ /* basis for other file system related failures */ - public: - FileException() : GeneralException() {} - FileException(const char *msg) : GeneralException(msg) {} +struct FileException : public GeneralException { /* basis for other file system related failures */ + public: + FileException() : GeneralException() {} + FileException(const char *msg) : GeneralException(msg) {} }; -struct FileNotFoundException : public FileException -{ /* file does not exist, bad path, etc. */ - public: - FileNotFoundException() : FileException() {} - FileNotFoundException(const char *msg) : FileException(msg) {} +struct FileNotFoundException : public FileException { /* file does not exist, bad path, etc. */ + public: + FileNotFoundException() : FileException() {} + FileNotFoundException(const char *msg) : FileException(msg) {} }; -struct FileAccessException : public FileException -{ /* general file system access related failure (file locked, creds don't allow read or write, etc) */ - public: - FileAccessException() : FileException() {} - FileAccessException(const char *msg) : FileException(msg) {} +struct FileAccessException + : public FileException { /* general file system access related failure (file locked, creds don't allow read or write, etc) */ + public: + FileAccessException() : FileException() {} + FileAccessException(const char *msg) : FileException(msg) {} }; -struct InvalidFileException : public FileException -{ /* the file is the wrong type or locked or something similar */ - public: - InvalidFileException() : FileException() {} - InvalidFileException(const char *msg) : FileException(msg) {} +struct InvalidFileException + : public FileException { /* the file is the wrong type or locked or something similar */ + public: + InvalidFileException() : FileException() {} + InvalidFileException(const char *msg) : FileException(msg) {} }; -struct PrintException : public GeneralException -{ /* general print related failure */ - public: - PrintException() : GeneralException() {} - PrintException(const char *msg) : GeneralException(msg) {} +struct PrintException : public GeneralException { /* general print related failure */ + public: + PrintException() : GeneralException() {} + PrintException(const char *msg) : GeneralException(msg) {} }; -struct PrintSetupException : public PrintException -{ /* something that is not legal happened (e.g., conflicting settings) */ - public: - PrintSetupException() : PrintException() {} - PrintSetupException(const char *msg) : PrintException(msg) {} +struct PrintSetupException + : public PrintException { /* something that is not legal happened (e.g., conflicting settings) */ + public: + PrintSetupException() : PrintException() {} + PrintSetupException(const char *msg) : PrintException(msg) {} }; -struct InvalidPrinterNameException : public PrintException -{ /* printer does not exist (i.e., not installed) by that name */ -public: +struct InvalidPrinterNameException + : public PrintException { /* printer does not exist (i.e., not installed) by that name */ + public: InvalidPrinterNameException() : PrintException() {} InvalidPrinterNameException(const char *msg) : PrintException(msg) {} }; -struct PlatformPrintException : public PrintException -{ /* platform print related failure */ - public: - PlatformPrintException() : PrintException() {} - PlatformPrintException(const char *msg) : PrintException(msg) {} +struct PlatformPrintException : public PrintException { /* platform print related failure */ + public: + PlatformPrintException() : PrintException() {} + PlatformPrintException(const char *msg) : PrintException(msg) {} }; -struct PlatformPrintAccessException : public PrintException -{ /* platform print related failure (due to policy / credential restrictions) */ - public: - PlatformPrintAccessException() : PrintException() {} - PlatformPrintAccessException(const char *msg) : PrintException(msg) {} +struct PlatformPrintAccessException + : public PrintException { /* platform print related failure (due to policy / credential restrictions) */ + public: + PlatformPrintAccessException() : PrintException() {} + PlatformPrintAccessException(const char *msg) : PrintException(msg) {} }; -struct ExportPostScriptException : public PrintException -{ /* export postscript related failure */ - public: - ExportPostScriptException() : PrintException() {} - ExportPostScriptException(const char *msg) : PrintException(msg) {} +struct ExportPostScriptException : public PrintException { /* export postscript related failure */ + public: + ExportPostScriptException() : PrintException() {} + ExportPostScriptException(const char *msg) : PrintException(msg) {} }; -#endif /* _SAMPLE_CUSTOM_EXCEPTIONS_H_ */ +#endif /* _SAMPLE_CUSTOM_EXCEPTIONS_H_ */ diff --git a/CPlusPlus/Sample_Source/_Common/SampleCustomExceptions/SampleCustomExceptions.h b/CPlusPlus/Sample_Source/_Common/SampleCustomExceptions/SampleCustomExceptions.h index 1eca2be6..03b501f2 100644 --- a/CPlusPlus/Sample_Source/_Common/SampleCustomExceptions/SampleCustomExceptions.h +++ b/CPlusPlus/Sample_Source/_Common/SampleCustomExceptions/SampleCustomExceptions.h @@ -19,95 +19,87 @@ struct UnimplementedException : public std::exception {}; struct OutOfMemoryException : public std::exception {}; -struct BadArgumentException : public std::exception -{ - public: - BadArgumentException() : std::exception() {} - BadArgumentException(const char *msg) : std::exception(msg) {} +struct BadArgumentException : public std::exception { + public: + BadArgumentException() : std::exception() {} + BadArgumentException(const char *msg) : std::exception(msg) {} }; -struct GeneralException : public std::exception -{ /* catch all for unknown conditions (and basis for more specific types) */ - public: - GeneralException() : std::exception() {} - GeneralException(const char *msg) : std::exception(msg) {} +struct GeneralException : public std::exception { /* catch all for unknown conditions (and basis for more specific types) */ + public: + GeneralException() : std::exception() {} + GeneralException(const char *msg) : std::exception(msg) {} }; -struct StringException : public GeneralException -{ /* basis for other string (usually unicode to non-unicode translations) related failures */ - public: - StringException() : GeneralException() {} - StringException(const char *msg) : GeneralException(msg) {} +struct StringException : public GeneralException { /* basis for other string (usually unicode to non-unicode translations) related failures */ + public: + StringException() : GeneralException() {} + StringException(const char *msg) : GeneralException(msg) {} }; -struct StringContainsUnsupportedUnicodeException : public StringException -{ /* at times, pdfl cannot support unicode */ - public: - StringContainsUnsupportedUnicodeException() : StringException() {} - StringContainsUnsupportedUnicodeException(const char *msg) : StringException(msg) {} +struct StringContainsUnsupportedUnicodeException + : public StringException { /* at times, pdfl cannot support unicode */ + public: + StringContainsUnsupportedUnicodeException() : StringException() {} + StringContainsUnsupportedUnicodeException(const char *msg) : StringException(msg) {} }; -struct FileException : public GeneralException -{ /* basis for other file system related failures */ - public: - FileException() : GeneralException() {} - FileException(const char *msg) : GeneralException(msg) {} +struct FileException : public GeneralException { /* basis for other file system related failures */ + public: + FileException() : GeneralException() {} + FileException(const char *msg) : GeneralException(msg) {} }; -struct FileNotFoundException : public FileException -{ /* file does not exist, bad path, etc. */ - public: - FileNotFoundException() : FileException() {} - FileNotFoundException(const char *msg) : FileException(msg) {} +struct FileNotFoundException : public FileException { /* file does not exist, bad path, etc. */ + public: + FileNotFoundException() : FileException() {} + FileNotFoundException(const char *msg) : FileException(msg) {} }; -struct FileAccessException : public FileException -{ /* general file system access related failure (file locked, creds don't allow read or write, etc) */ - public: - FileAccessException() : FileException() {} - FileAccessException(const char *msg) : FileException(msg) {} +struct FileAccessException + : public FileException { /* general file system access related failure (file locked, creds don't allow read or write, etc) */ + public: + FileAccessException() : FileException() {} + FileAccessException(const char *msg) : FileException(msg) {} }; -struct InvalidFileException : public FileException -{ /* the file is the wrong type or locked or something similar */ - public: - InvalidFileException() : FileException() {} - InvalidFileException(const char *msg) : FileException(msg) {} +struct InvalidFileException + : public FileException { /* the file is the wrong type or locked or something similar */ + public: + InvalidFileException() : FileException() {} + InvalidFileException(const char *msg) : FileException(msg) {} }; -struct PrintException : public GeneralException -{ /* general print related failure */ - public: - PrintException() : GeneralException() {} - PrintException(const char *msg) : GeneralException(msg) {} +struct PrintException : public GeneralException { /* general print related failure */ + public: + PrintException() : GeneralException() {} + PrintException(const char *msg) : GeneralException(msg) {} }; -struct PrintSetupException : public PrintException -{ /* something that is not legal happened (e.g., conflicting settings) */ - public: - PrintSetupException() : PrintException() {} - PrintSetupException(const char *msg) : PrintException(msg) {} +struct PrintSetupException + : public PrintException { /* something that is not legal happened (e.g., conflicting settings) */ + public: + PrintSetupException() : PrintException() {} + PrintSetupException(const char *msg) : PrintException(msg) {} }; -struct InvalidPrinterNameException : public PrintException -{ /* printer does not exist (i.e., not installed) by that name */ -public: +struct InvalidPrinterNameException + : public PrintException { /* printer does not exist (i.e., not installed) by that name */ + public: InvalidPrinterNameException() : PrintException() {} InvalidPrinterNameException(const char *msg) : PrintException(msg) {} }; -struct PlatformPrintException : public PrintException -{ /* platform print related failure */ - public: - PlatformPrintException() : PrintException() {} - PlatformPrintException(const char *msg) : PrintException(msg) {} +struct PlatformPrintException : public PrintException { /* platform print related failure */ + public: + PlatformPrintException() : PrintException() {} + PlatformPrintException(const char *msg) : PrintException(msg) {} }; -struct PlatformPrintAccessException : public PrintException -{ /* platform print related failure (due to policy / credential restrictions) */ - public: - PlatformPrintAccessException() : PrintException() {} - PlatformPrintAccessException(const char *msg) : PrintException(msg) {} +struct PlatformPrintAccessException + : public PrintException { /* platform print related failure (due to policy / credential restrictions) */ + public: + PlatformPrintAccessException() : PrintException() {} + PlatformPrintAccessException(const char *msg) : PrintException(msg) {} }; -struct ExportPostScriptException : public PrintException -{ /* export postscript related failure */ - public: - ExportPostScriptException() : PrintException() {} - ExportPostScriptException(const char *msg) : PrintException(msg) {} +struct ExportPostScriptException : public PrintException { /* export postscript related failure */ + public: + ExportPostScriptException() : PrintException() {} + ExportPostScriptException(const char *msg) : PrintException(msg) {} }; -#endif /* _SAMPLE_CUSTOM_EXCEPTIONS_H_ */ +#endif /* _SAMPLE_CUSTOM_EXCEPTIONS_H_ */ diff --git a/CPlusPlus/Sample_Source/_Common/SampleFileUtils.cpp b/CPlusPlus/Sample_Source/_Common/SampleFileUtils.cpp index 4f537023..744949e8 100644 --- a/CPlusPlus/Sample_Source/_Common/SampleFileUtils.cpp +++ b/CPlusPlus/Sample_Source/_Common/SampleFileUtils.cpp @@ -8,12 +8,12 @@ #include -#include "ScopeGuard.h" // for ON_BLOCK_EXIT +#include "ScopeGuard.h" // for ON_BLOCK_EXIT #include "PDFLCalls.h" #include "PDCalls.h" #include "ASCalls.h" -#include "ASExtraCalls.h" // for ASTextFromUnicode +#include "ASExtraCalls.h" // for ASTextFromUnicode #include "SampleCustomExceptions.h" #include "SampleFileUtils.h" @@ -25,8 +25,7 @@ // functionality in support of opening and saving file(s) and similar activities. // -PDDoc SelectPDFDocument() -{ +PDDoc SelectPDFDocument() { ASErrorCode err = 0; // @@ -35,40 +34,35 @@ PDDoc SelectPDFDocument() std::wstring pdfFilePath; SelectPDFPath(pdfFilePath); - if (pdfFilePath.empty()) - { // User canceled or similar + if (pdfFilePath.empty()) { // User canceled or similar return NULL; } PDDoc pDoc = NULL; DURING - { - // - // Attempt to convert pdfFilePath to the correct composition for use with PDFL... - // - - ASFileSys fileSys = ASGetDefaultFileSys(); - ASAtom pathSpecType = ASAtomFromString("DIPathWithASText"); - ASText pathSpec = ASTextFromUnicode(((ASUTF16Val*)pdfFilePath.c_str()), kUTF16HostEndian); - ASPathName path = ASFileSysCreatePathName(NULL, pathSpecType, pathSpec, NULL); - ON_BLOCK_EXIT(ASFileSysReleasePath, fileSys, path); - - // - // Attempt to open the (pdf) document... - // - - pDoc = PDDocOpen(path, fileSys, NULL, TRUE); - } + { + // + // Attempt to convert pdfFilePath to the correct composition for use with PDFL... + // + + ASFileSys fileSys = ASGetDefaultFileSys(); + ASAtom pathSpecType = ASAtomFromString("DIPathWithASText"); + ASText pathSpec = ASTextFromUnicode(((ASUTF16Val *)pdfFilePath.c_str()), kUTF16HostEndian); + ASPathName path = ASFileSysCreatePathName(NULL, pathSpecType, pathSpec, NULL); + ON_BLOCK_EXIT(ASFileSysReleasePath, fileSys, path); + + // + // Attempt to open the (pdf) document... + // + + pDoc = PDDocOpen(path, fileSys, NULL, TRUE); + } HANDLER - { - err = ERRORCODE; - } + { err = ERRORCODE; } END_HANDLER - if (err) - { // Something bad happened while trying to open the document (maybe the selected file *is not actually a valid* PDF?) - if (pDoc) - { // Open pdfs are *locked*. NEVER forget to close them! + if (err) { // Something bad happened while trying to open the document (maybe the selected file *is not actually a valid* PDF?) + if (pDoc) { // Open pdfs are *locked*. NEVER forget to close them! DURING PDDocClose(pDoc); HANDLER @@ -95,8 +89,7 @@ PDDoc SelectPDFDocument() // // See also: https://msdn.microsoft.com/en-us/library/windows/desktop/ms646927%28v=vs.85%29.aspx // -void SelectPDFPath(std::wstring &pdfFilePath /* OUT */) -{ +void SelectPDFPath(std::wstring &pdfFilePath /* OUT */) { OPENFILENAMEW ofn; memset(&ofn, 0, sizeof(OPENFILENAMEW)); ofn.lStructSize = sizeof(OPENFILENAMEW); @@ -114,11 +107,9 @@ void SelectPDFPath(std::wstring &pdfFilePath /* OUT */) SetLastError(0); BOOL result = GetOpenFileNameW(&ofn); - if (!result) - { + if (!result) { DWORD err = CommDlgExtendedError(); - if (err == 0) - { // Dialog canceled + if (err == 0) { // Dialog canceled return; } @@ -126,13 +117,12 @@ void SelectPDFPath(std::wstring &pdfFilePath /* OUT */) // Convert the error to an easy to review and nest, custom exception exception and throw *that* // - char msg[64] = { 0 }; + char msg[64] = {0}; sprintf_s(msg, sizeof(msg), "Error: %d\r\n", err); throw new GeneralException(msg); } - if (ofn.lpstrFile && ofn.lpstrFile[0] != 0 /* not empty */) - { // Now (and ONLY now) that we have a known good result, use it... + if (ofn.lpstrFile && ofn.lpstrFile[0] != 0 /* not empty */) { // Now (and ONLY now) that we have a known good result, use it... pdfFilePath = ofn.lpstrFile; } } @@ -144,8 +134,7 @@ void SelectPDFPath(std::wstring &pdfFilePath /* OUT */) // // See also: https://msdn.microsoft.com/en-us/library/windows/desktop/ms646928%28v=vs.85%29.aspx // -void GetSaveAsFilePath(std::wstring &pdfFilePath /* OUT */) -{ +void GetSaveAsFilePath(std::wstring &pdfFilePath /* OUT */) { OPENFILENAMEW ofn; memset(&ofn, 0, sizeof(OPENFILENAMEW)); ofn.lStructSize = sizeof(OPENFILENAMEW); @@ -157,17 +146,16 @@ void GetSaveAsFilePath(std::wstring &pdfFilePath /* OUT */) ofn.nFilterIndex = 1; ofn.Flags = OFN_EXPLORER | OFN_LONGNAMES | OFN_NONETWORKBUTTON | OFN_OVERWRITEPROMPT; - WCHAR pathBuf[0x1000] = { 0 }; + WCHAR pathBuf[0x1000] = {0}; ofn.lpstrFile = pathBuf; ofn.nMaxFile = sizeof(pathBuf) / sizeof(WCHAR); SetLastError(0); BOOL result = GetSaveFileNameW(&ofn); - if (!result) - { + if (!result) { DWORD err = CommDlgExtendedError(); - { // dialog canceled + { // dialog canceled return; } @@ -175,21 +163,19 @@ void GetSaveAsFilePath(std::wstring &pdfFilePath /* OUT */) // Convert the error to an easy to review and nest, custom exception exception and throw *that* // - char msg[64] = { 0 }; + char msg[64] = {0}; sprintf_s(msg, sizeof(msg), "Error: %d\r\n", err); throw new GeneralException(msg); } - if (ofn.lpstrFile && ofn.lpstrFile[0] != 0 /* not empty */) - { + if (ofn.lpstrFile && ofn.lpstrFile[0] != 0 /* not empty */) { size_t len = wcslen(ofn.lpstrFile); LPWSTR newFilePath = new WCHAR[len + 1]; memcpy(newFilePath, ofn.lpstrFile, len * sizeof(WCHAR)); newFilePath[len] = 0; - if (ofn.nFileExtension > 0 && ofn.nFileExtension < len) - { // Remove the extension (we'll add one later when we know what type of file to make) + if (ofn.nFileExtension > 0 && ofn.nFileExtension < len) { // Remove the extension (we'll add one later when we know what type of file to make) newFilePath[ofn.nFileExtension - 1 /* account for the '.' */] = 0; } @@ -204,8 +190,7 @@ void GetSaveAsFilePath(std::wstring &pdfFilePath /* OUT */) // // See also: https://msdn.microsoft.com/en-us/library/windows/desktop/ms646927%28v=vs.85%29.aspx // -void SelectICCProfile(std::wstring &iccFilePath /* OUT */) -{ +void SelectICCProfile(std::wstring &iccFilePath /* OUT */) { OPENFILENAMEW ofn; memset(&ofn, 0, sizeof(OPENFILENAMEW)); ofn.lStructSize = sizeof(OPENFILENAMEW); @@ -216,18 +201,16 @@ void SelectICCProfile(std::wstring &iccFilePath /* OUT */) ofn.nFilterIndex = 1; ofn.Flags = OFN_EXPLORER | OFN_LONGNAMES | OFN_NONETWORKBUTTON | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; - WCHAR pathBuf[0x1000] = { 0 }; + WCHAR pathBuf[0x1000] = {0}; ofn.lpstrFile = pathBuf; ofn.nMaxFile = sizeof(pathBuf) / sizeof(WCHAR); SetLastError(0); BOOL result = GetOpenFileNameW(&ofn); - if (!result) - { + if (!result) { DWORD err = CommDlgExtendedError(); - if (err == 0) - { // Dialog canceled + if (err == 0) { // Dialog canceled return; } @@ -235,13 +218,12 @@ void SelectICCProfile(std::wstring &iccFilePath /* OUT */) // Convert the error to an easy to review and nest, custom exception exception and throw *that* // - char msg[64] = { 0 }; + char msg[64] = {0}; sprintf_s(msg, sizeof(msg), "Error: %d\r\n", err); throw new GeneralException(msg); } - if (ofn.lpstrFile && ofn.lpstrFile[0] != 0 /* not empty */) - { // Now (and ONLY now) that we have a known good result, use it... + if (ofn.lpstrFile && ofn.lpstrFile[0] != 0 /* not empty */) { // Now (and ONLY now) that we have a known good result, use it... iccFilePath = ofn.lpstrFile; } } diff --git a/CPlusPlus/Sample_Source/_Common/SampleFileUtils.h b/CPlusPlus/Sample_Source/_Common/SampleFileUtils.h index 8581d506..5c70d089 100644 --- a/CPlusPlus/Sample_Source/_Common/SampleFileUtils.h +++ b/CPlusPlus/Sample_Source/_Common/SampleFileUtils.h @@ -24,4 +24,4 @@ void GetSaveAsFilePath(std::wstring &pdfFilePath /* OUT */); /* Pops UI for selection of an ICC profile and fills in a path to it. */ void SelectICCProfile(std::wstring &iccFilePath /* OUT */); -#endif /* _SAMPLE_FILE_UTILS_H_ */ +#endif /* _SAMPLE_FILE_UTILS_H_ */ diff --git a/CPlusPlus/Sample_Source/_Common/SampleFileUtils/SampleFileUtils.cpp b/CPlusPlus/Sample_Source/_Common/SampleFileUtils/SampleFileUtils.cpp deleted file mode 100644 index 4f537023..00000000 --- a/CPlusPlus/Sample_Source/_Common/SampleFileUtils/SampleFileUtils.cpp +++ /dev/null @@ -1,247 +0,0 @@ -// -// Copyright 2015, Datalogics, Inc. All rights reserved. -// -// http://dev.datalogics.com/adobe-pdf-library/license-for-downloaded-pdf-samples/ -// -// This is a Windows specific sample class... -// - -#include - -#include "ScopeGuard.h" // for ON_BLOCK_EXIT - -#include "PDFLCalls.h" -#include "PDCalls.h" -#include "ASCalls.h" -#include "ASExtraCalls.h" // for ASTextFromUnicode - -#include "SampleCustomExceptions.h" -#include "SampleFileUtils.h" - -// -// File Utility Functions -// -// A collection of simple, utility functions that present platform user interface -// functionality in support of opening and saving file(s) and similar activities. -// - -PDDoc SelectPDFDocument() -{ - ASErrorCode err = 0; - - // - // Populate pdfFilePath with a path collected from a user... - // - - std::wstring pdfFilePath; - SelectPDFPath(pdfFilePath); - if (pdfFilePath.empty()) - { // User canceled or similar - return NULL; - } - - PDDoc pDoc = NULL; - DURING - { - // - // Attempt to convert pdfFilePath to the correct composition for use with PDFL... - // - - ASFileSys fileSys = ASGetDefaultFileSys(); - ASAtom pathSpecType = ASAtomFromString("DIPathWithASText"); - ASText pathSpec = ASTextFromUnicode(((ASUTF16Val*)pdfFilePath.c_str()), kUTF16HostEndian); - ASPathName path = ASFileSysCreatePathName(NULL, pathSpecType, pathSpec, NULL); - ON_BLOCK_EXIT(ASFileSysReleasePath, fileSys, path); - - // - // Attempt to open the (pdf) document... - // - - pDoc = PDDocOpen(path, fileSys, NULL, TRUE); - } - HANDLER - { - err = ERRORCODE; - } - END_HANDLER - - if (err) - { // Something bad happened while trying to open the document (maybe the selected file *is not actually a valid* PDF?) - if (pDoc) - { // Open pdfs are *locked*. NEVER forget to close them! - DURING - PDDocClose(pDoc); - HANDLER - // Ignore any error - END_HANDLER - } - - // - // Convert the error to an easy to review and nest, custom exception exception and throw *that* - // - - char msg[64] = {0}; - sprintf_s(msg, sizeof(msg), "Error: %d\r\n", err); - throw new InvalidFileException(msg); - } - - return pDoc; -} - -// -// This utility function presents Windows User Interface (i.e., Open File) -// and prompts the user to select a PDF. Filtration restricts what the user -// can select. -// -// See also: https://msdn.microsoft.com/en-us/library/windows/desktop/ms646927%28v=vs.85%29.aspx -// -void SelectPDFPath(std::wstring &pdfFilePath /* OUT */) -{ - OPENFILENAMEW ofn; - memset(&ofn, 0, sizeof(OPENFILENAMEW)); - ofn.lStructSize = sizeof(OPENFILENAMEW); - - ofn.lpstrTitle = L"Select a PDF"; - ofn.lpstrDefExt = L"pdf"; - ofn.lpstrFilter = L"Portable Document File\0*.pdf;\0"; - ofn.nFilterIndex = 1; - ofn.Flags = OFN_EXPLORER | OFN_LONGNAMES | OFN_NONETWORKBUTTON | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; - - WCHAR pathBuf[0x1000] = {0}; - - ofn.lpstrFile = pathBuf; - ofn.nMaxFile = sizeof(pathBuf) / sizeof(WCHAR); - - SetLastError(0); - BOOL result = GetOpenFileNameW(&ofn); - if (!result) - { - DWORD err = CommDlgExtendedError(); - if (err == 0) - { // Dialog canceled - return; - } - - // - // Convert the error to an easy to review and nest, custom exception exception and throw *that* - // - - char msg[64] = { 0 }; - sprintf_s(msg, sizeof(msg), "Error: %d\r\n", err); - throw new GeneralException(msg); - } - - if (ofn.lpstrFile && ofn.lpstrFile[0] != 0 /* not empty */) - { // Now (and ONLY now) that we have a known good result, use it... - pdfFilePath = ofn.lpstrFile; - } -} - -// -// This utility function presents Windows User Interface (i.e., Save As) -// and prompts for a PDF path. Filtration restricts what the user -// can specify. -// -// See also: https://msdn.microsoft.com/en-us/library/windows/desktop/ms646928%28v=vs.85%29.aspx -// -void GetSaveAsFilePath(std::wstring &pdfFilePath /* OUT */) -{ - OPENFILENAMEW ofn; - memset(&ofn, 0, sizeof(OPENFILENAMEW)); - ofn.lStructSize = sizeof(OPENFILENAMEW); - - ofn.lpstrTitle = L"Save as PDF..."; - - ofn.lpstrDefExt = L"pdf"; - ofn.lpstrFilter = L"Portable Document File\0*.pdf;\0"; - ofn.nFilterIndex = 1; - ofn.Flags = OFN_EXPLORER | OFN_LONGNAMES | OFN_NONETWORKBUTTON | OFN_OVERWRITEPROMPT; - - WCHAR pathBuf[0x1000] = { 0 }; - - ofn.lpstrFile = pathBuf; - ofn.nMaxFile = sizeof(pathBuf) / sizeof(WCHAR); - - SetLastError(0); - BOOL result = GetSaveFileNameW(&ofn); - if (!result) - { - DWORD err = CommDlgExtendedError(); - { // dialog canceled - return; - } - - // - // Convert the error to an easy to review and nest, custom exception exception and throw *that* - // - - char msg[64] = { 0 }; - sprintf_s(msg, sizeof(msg), "Error: %d\r\n", err); - throw new GeneralException(msg); - } - - if (ofn.lpstrFile && ofn.lpstrFile[0] != 0 /* not empty */) - { - size_t len = wcslen(ofn.lpstrFile); - LPWSTR newFilePath = new WCHAR[len + 1]; - - memcpy(newFilePath, ofn.lpstrFile, len * sizeof(WCHAR)); - newFilePath[len] = 0; - - if (ofn.nFileExtension > 0 && ofn.nFileExtension < len) - { // Remove the extension (we'll add one later when we know what type of file to make) - newFilePath[ofn.nFileExtension - 1 /* account for the '.' */] = 0; - } - - pdfFilePath = newFilePath; - } -} - -// -// This utility function presents Windows User Interface (i.e., Open File) -// and prompts the user to select an ICC profile. Filtration restricts what the user -// can select. -// -// See also: https://msdn.microsoft.com/en-us/library/windows/desktop/ms646927%28v=vs.85%29.aspx -// -void SelectICCProfile(std::wstring &iccFilePath /* OUT */) -{ - OPENFILENAMEW ofn; - memset(&ofn, 0, sizeof(OPENFILENAMEW)); - ofn.lStructSize = sizeof(OPENFILENAMEW); - - ofn.lpstrTitle = L"Select a ICC Profile"; - ofn.lpstrDefExt = L"icc"; - ofn.lpstrFilter = L"ICC Color Profile\0*.icc;\0"; - ofn.nFilterIndex = 1; - ofn.Flags = OFN_EXPLORER | OFN_LONGNAMES | OFN_NONETWORKBUTTON | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; - - WCHAR pathBuf[0x1000] = { 0 }; - - ofn.lpstrFile = pathBuf; - ofn.nMaxFile = sizeof(pathBuf) / sizeof(WCHAR); - - SetLastError(0); - BOOL result = GetOpenFileNameW(&ofn); - if (!result) - { - DWORD err = CommDlgExtendedError(); - if (err == 0) - { // Dialog canceled - return; - } - - // - // Convert the error to an easy to review and nest, custom exception exception and throw *that* - // - - char msg[64] = { 0 }; - sprintf_s(msg, sizeof(msg), "Error: %d\r\n", err); - throw new GeneralException(msg); - } - - if (ofn.lpstrFile && ofn.lpstrFile[0] != 0 /* not empty */) - { // Now (and ONLY now) that we have a known good result, use it... - iccFilePath = ofn.lpstrFile; - } -} diff --git a/CPlusPlus/Sample_Source/_Common/SampleFileUtils/SampleFileUtils.h b/CPlusPlus/Sample_Source/_Common/SampleFileUtils/SampleFileUtils.h deleted file mode 100644 index 8581d506..00000000 --- a/CPlusPlus/Sample_Source/_Common/SampleFileUtils/SampleFileUtils.h +++ /dev/null @@ -1,27 +0,0 @@ -/* -// Copyright 2015, Datalogics, Inc. All rights reserved. -// -// http://dev.datalogics.com/adobe-pdf-library/license-for-downloaded-pdf-samples/ -// -// This is a Windows specific sample class... -*/ - -#ifndef _SAMPLE_FILE_UTILS_H_ -#define _SAMPLE_FILE_UTILS_H_ - -/* Helper functions that work with Windows to acquire information */ -/* that everyone needs to work with APDFL... */ - -/* Pops UI for selection of a PDF and then opens, returns a PDDoc. */ -PDDoc SelectPDFDocument(); - -/* Pops UI for selection of a PDF and fills in a path to it. */ -void SelectPDFPath(std::wstring &pdfFilePath /* OUT */); - -/* Pops UI for creation of a Save As path (for a PDF). */ -void GetSaveAsFilePath(std::wstring &pdfFilePath /* OUT */); - -/* Pops UI for selection of an ICC profile and fills in a path to it. */ -void SelectICCProfile(std::wstring &iccFilePath /* OUT */); - -#endif /* _SAMPLE_FILE_UTILS_H_ */ diff --git a/CPlusPlus/Sample_Source/_Common/ScopeGuard.h b/CPlusPlus/Sample_Source/_Common/ScopeGuard.h index 5112ddaf..a3b93809 100644 --- a/CPlusPlus/Sample_Source/_Common/ScopeGuard.h +++ b/CPlusPlus/Sample_Source/_Common/ScopeGuard.h @@ -6,297 +6,203 @@ * * @file ScopeGuard.h * @date 9/21/2009 17:20 - * + * * @brief Scope guard objects - * + * * Source code from: Generic: Change the Way You Write Exception-Safe Code Forever * by Andrei Alexandrescu and Petru Marginean - * + * * Appeared in CUJ (Dec 2000) and DDJ (April 15, 2003) - * + * * Article: http://www.ddj.com/dept/cpp/184403758 * Download: ftp://66.77.27.238/sourcecode/cuj/2000/cujdec2000.zip - * + * * ScopeGuard creates automatic variables that can cause functions to be called * when going out of scope (including function return and exception throw). * Implements RAII. - * + * */ #ifndef SCOPEGUARD_H_ #define SCOPEGUARD_H_ -template -class RefHolder -{ - T& ref_; -public: - RefHolder(T& ref) : ref_(ref) {} - operator T& () const - { - return ref_; - } -private: +template class RefHolder { + T &ref_; + + public: + RefHolder(T &ref) : ref_(ref) {} + operator T &() const { return ref_; } + + private: // Disable assignment - not implemented - RefHolder& operator=(const RefHolder&); + RefHolder &operator=(const RefHolder &); }; -template -inline RefHolder ByRef(T& t) -{ - return RefHolder(t); -} - -class ScopeGuardImplBase -{ - ScopeGuardImplBase& operator =(const ScopeGuardImplBase&); -protected: - ~ScopeGuardImplBase() - { - } - ScopeGuardImplBase(const ScopeGuardImplBase& other) throw() - : dismissed_(other.dismissed_) - { - other.Dismiss(); - } - template - static void SafeExecute(J& j) throw() - { - if (!j.dismissed_) - try - { - j.Execute(); - } - catch(...) - { - } - } - - mutable bool dismissed_; -public: - ScopeGuardImplBase() throw() : dismissed_(false) - { - } - void Dismiss() const throw() - { - dismissed_ = true; - } +template inline RefHolder ByRef(T &t) { return RefHolder(t); } + +class ScopeGuardImplBase { + ScopeGuardImplBase &operator=(const ScopeGuardImplBase &); + + protected: + ~ScopeGuardImplBase() {} + ScopeGuardImplBase(const ScopeGuardImplBase &other) throw() : dismissed_(other.dismissed_) { + other.Dismiss(); + } + template static void SafeExecute(J &j) throw() { + if (!j.dismissed_) + try { + j.Execute(); + } catch (...) { + } + } + + mutable bool dismissed_; + + public: + ScopeGuardImplBase() throw() : dismissed_(false) {} + void Dismiss() const throw() { dismissed_ = true; } }; -typedef const ScopeGuardImplBase& ScopeGuard; - -template -class ScopeGuardImpl0 : public ScopeGuardImplBase -{ -public: - static ScopeGuardImpl0 MakeGuard(F fun) - { - return ScopeGuardImpl0(fun); - } - ~ScopeGuardImpl0() throw() - { - SafeExecute(*this); - } - void Execute() - { - fun_(); - } -protected: - ScopeGuardImpl0(F fun) : fun_(fun) - { - } - F fun_; +typedef const ScopeGuardImplBase &ScopeGuard; + +template class ScopeGuardImpl0 : public ScopeGuardImplBase { + public: + static ScopeGuardImpl0 MakeGuard(F fun) { return ScopeGuardImpl0(fun); } + ~ScopeGuardImpl0() throw() { SafeExecute(*this); } + void Execute() { fun_(); } + + protected: + ScopeGuardImpl0(F fun) : fun_(fun) {} + F fun_; }; -template -inline ScopeGuardImpl0 MakeGuard(F fun) -{ - return ScopeGuardImpl0::MakeGuard(fun); +template inline ScopeGuardImpl0 MakeGuard(F fun) { + return ScopeGuardImpl0::MakeGuard(fun); } -template -class ScopeGuardImpl1 : public ScopeGuardImplBase -{ -public: - static ScopeGuardImpl1 MakeGuard(F fun, P1 p1) - { - return ScopeGuardImpl1(fun, p1); - } - ~ScopeGuardImpl1() throw() - { - SafeExecute(*this); - } - void Execute() - { - fun_(p1_); - } -protected: - ScopeGuardImpl1(F fun, P1 p1) : fun_(fun), p1_(p1) - { - } - F fun_; - const P1 p1_; +template class ScopeGuardImpl1 : public ScopeGuardImplBase { + public: + static ScopeGuardImpl1 MakeGuard(F fun, P1 p1) { + return ScopeGuardImpl1(fun, p1); + } + ~ScopeGuardImpl1() throw() { SafeExecute(*this); } + void Execute() { fun_(p1_); } + + protected: + ScopeGuardImpl1(F fun, P1 p1) : fun_(fun), p1_(p1) {} + F fun_; + const P1 p1_; }; -template -inline ScopeGuardImpl1 MakeGuard(F fun, P1 p1) -{ - return ScopeGuardImpl1::MakeGuard(fun, p1); +template inline ScopeGuardImpl1 MakeGuard(F fun, P1 p1) { + return ScopeGuardImpl1::MakeGuard(fun, p1); } -template -class ScopeGuardImpl2: public ScopeGuardImplBase -{ -public: - static ScopeGuardImpl2 MakeGuard(F fun, P1 p1, P2 p2) - { - return ScopeGuardImpl2(fun, p1, p2); - } - ~ScopeGuardImpl2() throw() - { - SafeExecute(*this); - } - void Execute() - { - fun_(p1_, p2_); - } -protected: - ScopeGuardImpl2(F fun, P1 p1, P2 p2) : fun_(fun), p1_(p1), p2_(p2) - { - } - F fun_; - const P1 p1_; - const P2 p2_; +template class ScopeGuardImpl2 : public ScopeGuardImplBase { + public: + static ScopeGuardImpl2 MakeGuard(F fun, P1 p1, P2 p2) { + return ScopeGuardImpl2(fun, p1, p2); + } + ~ScopeGuardImpl2() throw() { SafeExecute(*this); } + void Execute() { fun_(p1_, p2_); } + + protected: + ScopeGuardImpl2(F fun, P1 p1, P2 p2) : fun_(fun), p1_(p1), p2_(p2) {} + F fun_; + const P1 p1_; + const P2 p2_; }; template -inline ScopeGuardImpl2 MakeGuard(F fun, P1 p1, P2 p2) -{ - return ScopeGuardImpl2::MakeGuard(fun, p1, p2); +inline ScopeGuardImpl2 MakeGuard(F fun, P1 p1, P2 p2) { + return ScopeGuardImpl2::MakeGuard(fun, p1, p2); } template -class ScopeGuardImpl3 : public ScopeGuardImplBase -{ -public: - static ScopeGuardImpl3 MakeGuard(F fun, P1 p1, P2 p2, P3 p3) - { - return ScopeGuardImpl3(fun, p1, p2, p3); - } - ~ScopeGuardImpl3() throw() - { - SafeExecute(*this); - } - void Execute() - { - fun_(p1_, p2_, p3_); - } -protected: - ScopeGuardImpl3(F fun, P1 p1, P2 p2, P3 p3) : fun_(fun), p1_(p1), p2_(p2), p3_(p3) - { - } - F fun_; - const P1 p1_; - const P2 p2_; - const P3 p3_; +class ScopeGuardImpl3 : public ScopeGuardImplBase { + public: + static ScopeGuardImpl3 MakeGuard(F fun, P1 p1, P2 p2, P3 p3) { + return ScopeGuardImpl3(fun, p1, p2, p3); + } + ~ScopeGuardImpl3() throw() { SafeExecute(*this); } + void Execute() { fun_(p1_, p2_, p3_); } + + protected: + ScopeGuardImpl3(F fun, P1 p1, P2 p2, P3 p3) : fun_(fun), p1_(p1), p2_(p2), p3_(p3) {} + F fun_; + const P1 p1_; + const P2 p2_; + const P3 p3_; }; template -inline ScopeGuardImpl3 MakeGuard(F fun, P1 p1, P2 p2, P3 p3) -{ - return ScopeGuardImpl3::MakeGuard(fun, p1, p2, p3); +inline ScopeGuardImpl3 MakeGuard(F fun, P1 p1, P2 p2, P3 p3) { + return ScopeGuardImpl3::MakeGuard(fun, p1, p2, p3); } //************************************************************ -template -class ObjScopeGuardImpl0 : public ScopeGuardImplBase -{ -public: - static ObjScopeGuardImpl0 MakeObjGuard(Obj& obj, MemFun memFun) - { - return ObjScopeGuardImpl0(obj, memFun); - } - ~ObjScopeGuardImpl0() throw() - { - SafeExecute(*this); - } - void Execute() - { - (obj_.*memFun_)(); - } -protected: - ObjScopeGuardImpl0(Obj& obj, MemFun memFun) - : obj_(obj), memFun_(memFun) {} - Obj& obj_; - MemFun memFun_; +template class ObjScopeGuardImpl0 : public ScopeGuardImplBase { + public: + static ObjScopeGuardImpl0 MakeObjGuard(Obj &obj, MemFun memFun) { + return ObjScopeGuardImpl0(obj, memFun); + } + ~ObjScopeGuardImpl0() throw() { SafeExecute(*this); } + void Execute() { (obj_.*memFun_)(); } + + protected: + ObjScopeGuardImpl0(Obj &obj, MemFun memFun) : obj_(obj), memFun_(memFun) {} + Obj &obj_; + MemFun memFun_; }; template -inline ObjScopeGuardImpl0 MakeObjGuard(Obj& obj, MemFun memFun) -{ - return ObjScopeGuardImpl0::MakeObjGuard(obj, memFun); +inline ObjScopeGuardImpl0 MakeObjGuard(Obj &obj, MemFun memFun) { + return ObjScopeGuardImpl0::MakeObjGuard(obj, memFun); } template -class ObjScopeGuardImpl1 : public ScopeGuardImplBase -{ -public: - static ObjScopeGuardImpl1 MakeObjGuard(Obj& obj, MemFun memFun, P1 p1) - { - return ObjScopeGuardImpl1(obj, memFun, p1); - } - ~ObjScopeGuardImpl1() throw() - { - SafeExecute(*this); - } - void Execute() - { - (obj_.*memFun_)(p1_); - } -protected: - ObjScopeGuardImpl1(Obj& obj, MemFun memFun, P1 p1) - : obj_(obj), memFun_(memFun), p1_(p1) {} - Obj& obj_; - MemFun memFun_; - const P1 p1_; +class ObjScopeGuardImpl1 : public ScopeGuardImplBase { + public: + static ObjScopeGuardImpl1 MakeObjGuard(Obj &obj, MemFun memFun, P1 p1) { + return ObjScopeGuardImpl1(obj, memFun, p1); + } + ~ObjScopeGuardImpl1() throw() { SafeExecute(*this); } + void Execute() { (obj_.*memFun_)(p1_); } + + protected: + ObjScopeGuardImpl1(Obj &obj, MemFun memFun, P1 p1) : obj_(obj), memFun_(memFun), p1_(p1) {} + Obj &obj_; + MemFun memFun_; + const P1 p1_; }; template -inline ObjScopeGuardImpl1 MakeObjGuard(Obj& obj, MemFun memFun, P1 p1) -{ - return ObjScopeGuardImpl1::MakeObjGuard(obj, memFun, p1); +inline ObjScopeGuardImpl1 MakeObjGuard(Obj &obj, MemFun memFun, P1 p1) { + return ObjScopeGuardImpl1::MakeObjGuard(obj, memFun, p1); } template -class ObjScopeGuardImpl2 : public ScopeGuardImplBase -{ -public: - static ObjScopeGuardImpl2 MakeObjGuard(Obj& obj, MemFun memFun, P1 p1, P2 p2) - { - return ObjScopeGuardImpl2(obj, memFun, p1, p2); - } - ~ObjScopeGuardImpl2() throw() - { - SafeExecute(*this); - } - void Execute() - { - (obj_.*memFun_)(p1_, p2_); - } -protected: - ObjScopeGuardImpl2(Obj& obj, MemFun memFun, P1 p1, P2 p2) - : obj_(obj), memFun_(memFun), p1_(p1), p2_(p2) {} - Obj& obj_; - MemFun memFun_; - const P1 p1_; - const P2 p2_; +class ObjScopeGuardImpl2 : public ScopeGuardImplBase { + public: + static ObjScopeGuardImpl2 MakeObjGuard(Obj &obj, MemFun memFun, P1 p1, P2 p2) { + return ObjScopeGuardImpl2(obj, memFun, p1, p2); + } + ~ObjScopeGuardImpl2() throw() { SafeExecute(*this); } + void Execute() { (obj_.*memFun_)(p1_, p2_); } + + protected: + ObjScopeGuardImpl2(Obj &obj, MemFun memFun, P1 p1, P2 p2) + : obj_(obj), memFun_(memFun), p1_(p1), p2_(p2) {} + Obj &obj_; + MemFun memFun_; + const P1 p1_; + const P2 p2_; }; template -inline ObjScopeGuardImpl2 MakeObjGuard(Obj& obj, MemFun memFun, P1 p1, P2 p2) -{ - return ObjScopeGuardImpl2::MakeObjGuard(obj, memFun, p1, p2); +inline ObjScopeGuardImpl2 MakeObjGuard(Obj &obj, MemFun memFun, P1 p1, P2 p2) { + return ObjScopeGuardImpl2::MakeObjGuard(obj, memFun, p1, p2); } #define CONCATENATE_DIRECT(s1, s2) s1##s2 @@ -306,4 +212,4 @@ inline ObjScopeGuardImpl2 MakeObjGuard(Obj& obj, MemFun mem #define ON_BLOCK_EXIT ScopeGuard ANONYMOUS_VARIABLE(scopeGuard) = MakeGuard #define ON_BLOCK_EXIT_OBJ ScopeGuard ANONYMOUS_VARIABLE(scopeGuard) = MakeObjGuard -#endif //SCOPEGUARD_H_ +#endif // SCOPEGUARD_H_ diff --git a/CPlusPlus/Sample_Source/_Common/SetupPrintParams.cpp b/CPlusPlus/Sample_Source/_Common/SetupPrintParams.cpp index 1033cdfe..8bb22134 100644 --- a/CPlusPlus/Sample_Source/_Common/SetupPrintParams.cpp +++ b/CPlusPlus/Sample_Source/_Common/SetupPrintParams.cpp @@ -3,8 +3,8 @@ // http://dev.datalogics.com/adobe-pdf-library/license-for-downloaded-pdf-samples/ // //=============================================================================== -// Sample: SetupPrintParams -These functions are intended to assist with -// operations common to most print samples. +// Sample: SetupPrintParams -These functions are intended to assist with +// operations common to most print samples. //=============================================================================== #include "SetupPrintParams.h" @@ -14,8 +14,7 @@ Set up PDPrintParams struct. Set the same independent of platform or destination for printing. Contains options for indicating how a document should be printed or generated. */ -void SetupPDPrintParams(PDPrintParams psParams) -{ +void SetupPDPrintParams(PDPrintParams psParams) { /* Set up the PDPrintParamsRec */ memset(psParams, 0, sizeof(PDPrintParamsRec)); psParams->size = sizeof(PDPrintParamsRec); @@ -25,184 +24,199 @@ void SetupPDPrintParams(PDPrintParams psParams) // When these values conflict, the values specified in PDFLPrintUserParams shall be used. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - psParams->shrinkToFit = true; // If the page is larger than the media, it will be evenly scaled down - // to fit the media (overrides scale parameter) - psParams->psLevel = 3L; // PS Level - 1, 2, or 3 - // Level of PostScript created. In practice, this should match the level of the printer. - // If the printer does not support the level specified, this will be replaced with the - // highest level known to the printer. - psParams->binaryOK = true; // Permits binary operators in PostScript output. If printing to a printer, - // the printers ability to accept binary may override this setting - // ("Output Protocol" device settings. Turning true to false, only). - - psParams->reverse = false; // Reverse the order of page output - // (NOTE: This does NOT add a blank backing page, in the event of - // duplex is true, and number of pages is odd.) - psParams->doOPP = false; // When true, CMYK colors will “mix” in the manner of the OP blending model. - psParams->transparencyQuality = false; // Echoed in PDFLPrintUserParams as the transQuaility attribute. - // Used to establish how much time/resources should be applied to flattening - // transparency while printing the page. At the lowest values, this will - // basically render all transparent areas as bitmaps. - // At the highest setting, it will attempt to render using vector operators - // as much as possible. - psParams->farEastFontOpt = false; // Used to describe how large fonts should he handled, either downloaded, or not. - psParams->rotate = false; // When true, enables page auto rotation to align the long edges of the paper. - psParams->ocContext = NULL; // Optional-content context to use for visibility state information, or NULL - // to use the document's current states in the default context. + psParams->shrinkToFit = true; // If the page is larger than the media, it will be evenly scaled + // down to fit the media (overrides scale parameter) + psParams->psLevel = 3L; // PS Level - 1, 2, or 3 + // Level of PostScript created. In practice, this should match the level + // of the printer. If the printer does not support the level specified, + // this will be replaced with the highest level known to the printer. + psParams->binaryOK = true; // Permits binary operators in PostScript output. If printing to a printer, + // the printers ability to accept binary may override this setting + // ("Output Protocol" device settings. Turning true to false, only). + + psParams->reverse = false; // Reverse the order of page output + // (NOTE: This does NOT add a blank backing page, in the event of + // duplex is true, and number of pages is odd.) + psParams->doOPP = false; // When true, CMYK colors will “mix” in the manner of the OP blending model. + psParams->transparencyQuality = + false; // Echoed in PDFLPrintUserParams as the transQuaility attribute. + // Used to establish how much time/resources should be applied to flattening + // transparency while printing the page. At the lowest values, this will + // basically render all transparent areas as bitmaps. + // At the highest setting, it will attempt to render using vector operators + // as much as possible. + psParams->farEastFontOpt = + false; // Used to describe how large fonts should he handled, either downloaded, or not. + psParams->rotate = false; // When true, enables page auto rotation to align the long edges of the paper. + psParams->ocContext = NULL; // Optional-content context to use for visibility state information, or NULL + // to use the document's current states in the default context. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Attributes effective in all print modes except Print Via DC. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - psParams->expandToFit = false; // Small pages are scaled to fit the printer page size (overrides scale parameter) - psParams->rotateAndCenter = false; // When true, indicate that the long edges of the page, and the media, - // should be aligned, and that the page should be centered in the media. - // (this works in conjunction with shrinkToFit and expandToFit) - psParams->centerCropBox = true; // When true, position the page such that the center of the page is at the - // center of the media. When false, the upper left corner of the page will - // align with the upper left corner of the media. - // (NOTE: This is only effective when expandToFit and/or shrinkToFit is false. - psParams->duplex = kPDDuplexOff; // Simplex or duplex printed pages (single or double sided) - // This is also specified in the DevMode, for Print To PostScript or Print To GDI. - // In case of conflict, the DevMode value will be used. - - psParams->whichMarks = 0; // Page mark indication. It is a bit-wise OR of the PDPageMarkFlags values. - psParams->markStyle = 0; // Specify the style to use for page marks. The PDPrintMarkStyles enum contains - // possible styles. - psParams->customMarksFileName = NULL; // If markStyle == -1, this should be a valid file name pointing to a valid .mrk - // file for custom printer marks. - psParams->scale = 100.0; // Document-wide scale factor - - psParams->hostBasedCM = false; // Do hostBased color management using the destination profile - // (see destProfile parameter). - // The default is false, which means doing CSA generation for profiles instead of - // converting all colors on the host. - - psParams->doProofing = false; // When true, print using proofing settings. - // (see proofProfile, inkBlack, paperWhite parameters) - - psParams->mirrorprint = kPDPrintFlipNone; // Used to mirror page renderings, horizontally, vertically, or both. - // Mirroring is done in the PostScript output stream. - // One of the following constants: - // kPDPrintFlipNone = 0x01 - // kPDPrintFlipX = 0x02 - // kPDPrintFlipY = 0x04 - // kPDPrintFlipXY = 0x08 - psParams->lineWidth = 0; // Width of the line to be used in printer marks. - psParams->disableFlattening = false; // When true, will cause transparency flattening to be bypassed when printing. - psParams->doNotDownloadFauxFonts = false; // When true, disables the downloading of fonts which are created to replace - // fonts not directly usable. - psParams->grayToK = false; // When true, will cause gray colors to be printed as CMYK colors, - // using only the black component. - - psParams->maxFlatSeconds = 0; // When nonzero, sets a limit to the amount of time APDFL will spend attempting - // to flatten a given page to vector art. If the time is exceeded, the page will - // be flattened to a bitmap image. + psParams->expandToFit = false; // Small pages are scaled to fit the printer page size (overrides scale parameter) + psParams->rotateAndCenter = + false; // When true, indicate that the long edges of the page, and the media, + // should be aligned, and that the page should be centered in the media. + // (this works in conjunction with shrinkToFit and expandToFit) + psParams->centerCropBox = + true; // When true, position the page such that the center of the page is at the + // center of the media. When false, the upper left corner of the page will + // align with the upper left corner of the media. + // (NOTE: This is only effective when expandToFit and/or shrinkToFit is false. + psParams->duplex = + kPDDuplexOff; // Simplex or duplex printed pages (single or double sided) + // This is also specified in the DevMode, for Print To PostScript or Print To + // GDI. In case of conflict, the DevMode value will be used. + + psParams->whichMarks = 0; // Page mark indication. It is a bit-wise OR of the PDPageMarkFlags values. + psParams->markStyle = 0; // Specify the style to use for page marks. The PDPrintMarkStyles enum + // contains possible styles. + psParams->customMarksFileName = NULL; // If markStyle == -1, this should be a valid file name + // pointing to a valid .mrk file for custom printer marks. + psParams->scale = 100.0; // Document-wide scale factor + + psParams->hostBasedCM = false; // Do hostBased color management using the destination profile + // (see destProfile parameter). + // The default is false, which means doing CSA generation for + // profiles instead of converting all colors on the host. + + psParams->doProofing = false; // When true, print using proofing settings. + // (see proofProfile, inkBlack, paperWhite parameters) + + psParams->mirrorprint = kPDPrintFlipNone; // Used to mirror page renderings, horizontally, vertically, or both. + // Mirroring is done in the PostScript output stream. + // One of the following constants: + // kPDPrintFlipNone = 0x01 + // kPDPrintFlipX = 0x02 + // kPDPrintFlipY = 0x04 + // kPDPrintFlipXY = 0x08 + psParams->lineWidth = 0; // Width of the line to be used in printer marks. + psParams->disableFlattening = + false; // When true, will cause transparency flattening to be bypassed when printing. + psParams->doNotDownloadFauxFonts = false; // When true, disables the downloading of fonts which + // are created to replace fonts not directly usable. + psParams->grayToK = false; // When true, will cause gray colors to be printed as CMYK colors, + // using only the black component. + + psParams->maxFlatSeconds = 0; // When nonzero, sets a limit to the amount of time APDFL will + // spend attempting to flatten a given page to vector art. If the + // time is exceeded, the page will be flattened to a bitmap image. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Attributes effective in both PostScript to a File, and PostScript to a Printer. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - psParams->setPageSize = false; // When true, causes a PostScript setcachedevice command to be issued, - // setting the page size. - psParams->outputType = PDOutput_PS; // Print PostScript or EPS with or without a preview - - psParams->incBaseFonts = kIncludeOncePerDoc; // Embed the base fonts - psParams->incEmbeddedFonts = kIncludeOncePerDoc; // Embed fonts that are embedded in the PDF file. - // (NOTE: To include an embedded font, need both incEmbeddedFonts - // and the include attribute for that type of font, to specify inclusion.) - psParams->incType1Fonts = kIncludeOncePerDoc; // Embed Type 1 fonts - psParams->incType3Fonts = kIncludeOnEveryPage; // Embed Type 3 fonts (this must be set to kIncludeOnEveryPage) - psParams->incTrueTypeFonts = kIncludeOncePerDoc; // Embed TrueType fonts - psParams->incCIDFonts = kIncludeOncePerDoc; // Embed CID fonts - psParams->incProcsets = kIncludeOncePerDoc; // Embed Procsets in the file + psParams->setPageSize = false; // When true, causes a PostScript setcachedevice command to be + // issued, setting the page size. + psParams->outputType = PDOutput_PS; // Print PostScript or EPS with or without a preview + + psParams->incBaseFonts = kIncludeOncePerDoc; // Embed the base fonts + psParams->incEmbeddedFonts = + kIncludeOncePerDoc; // Embed fonts that are embedded in the PDF file. + // (NOTE: To include an embedded font, need both incEmbeddedFonts + // and the include attribute for that type of font, to specify inclusion.) + psParams->incType1Fonts = kIncludeOncePerDoc; // Embed Type 1 fonts + psParams->incType3Fonts = kIncludeOnEveryPage; // Embed Type 3 fonts (this must be set to kIncludeOnEveryPage) + psParams->incTrueTypeFonts = kIncludeOncePerDoc; // Embed TrueType fonts + psParams->incCIDFonts = kIncludeOncePerDoc; // Embed CID fonts + psParams->incProcsets = kIncludeOncePerDoc; // Embed Procsets in the file psParams->incOtherResources = kIncludeOncePerDoc; // Embed all other types of resources in the file - // emitColorSeps, emitInRIPSeps and negative, can be used (Only when using PostScript to a Printer) - // to print separation colors, rather than composite color pages. - psParams->emitColorSeps = false; // Emit images for Level-1 separations. - psParams->emitInRipSeps = false; // When true, will cause pages to be separated in the RIP engine, - // rather than on the host. This is effective only if emitColorSeps is true. - psParams->negative = false; // When true, invert the plate. - - psParams->emitRawData = false; // When true, will suppress the use of all filters for images. - // (Effectively, turn off compression of images). - - psParams->TTasT42 = true; // If including TrueType fonts, convert to Adobe Type 42 fonts instead of Type 1 fonts. - - psParams->emitPSXObjects = false; // When true, will cause PDF Xobjects to be emitted to PostScript as PostScript XObjects. - // When false, they will be copied to each point of reference. - psParams->useFontAliasNames = false; // When true, uses the name of the font as it was supplied by the system, or subset, - // while downloading the font. When false, the base font name is used. - - psParams->emitPageClip = true; // When true, will emit a clip region around the pages clip path. - // This is useful if the page actually contains content outside of it’s clip path. - psParams->emitTransfer = true; // When true, will emit transfer functions to the PostScript document, - // rather than resolving their usage on the host. - psParams->emitBG = true; // When true, will emit Black Generation values to the PostScript file, - // rather than resolving their usage on the host. - psParams->emitUCR = true; // When true, will emit Under Color Removal values to the PostScript file, - // rather than resolving their usage locally. - - psParams->suppressCJKSubstitution = false; // If allowed, will control the use of printer based substitutes for CJK Fonts. - psParams->brokenCRDs = false; // When true, disables the emission of profiled colors to PostScript. - // In essence, this will force Host color conversion. - - psParams->bitmapResolution = 0; // Set the resolution, in DPI, of emitted bitmaps - // when these are done as actual bitmaps. - psParams->gradientResolution = 0; // Set the resolution, in DPI, of gradients interior to the object (not edges). - // It can generally be lower than the bitmapResolution. - - psParams->flattenInfo = NULL; // When present, is used to control the flattening of translucent pages. - // If not present, a set of default values is used in its place. - - psParams->emitFlatness = false; // When true, causes the flatness setting in Graphics State to be honored. - psParams->trapType = 0; // Controls whether trapping is done on the host or on the printer. - psParams->suppressSnapToDevice = false; // When true, will disable the “Snap To Device” rendering option. - // Snap To Device causes all elements to be pixel aligned at the printer resolution. - psParams->suppressElement = 0; // Controls suppression of XMP data, written to the PostScript stream. - // Data may be controlled by type. + // emitColorSeps, emitInRIPSeps and negative, can be used (Only when using PostScript to a + // Printer) to print separation colors, rather than composite color pages. + psParams->emitColorSeps = false; // Emit images for Level-1 separations. + psParams->emitInRipSeps = false; // When true, will cause pages to be separated in the RIP engine, + // rather than on the host. This is effective only if emitColorSeps is true. + psParams->negative = false; // When true, invert the plate. + + psParams->emitRawData = false; // When true, will suppress the use of all filters for images. + // (Effectively, turn off compression of images). + + psParams->TTasT42 = true; // If including TrueType fonts, convert to Adobe Type 42 fonts instead of Type 1 fonts. + + psParams->emitPSXObjects = + false; // When true, will cause PDF Xobjects to be emitted to PostScript as PostScript + // XObjects. When false, they will be copied to each point of reference. + psParams->useFontAliasNames = + false; // When true, uses the name of the font as it was supplied by the system, or subset, + // while downloading the font. When false, the base font name is used. + + psParams->emitPageClip = true; // When true, will emit a clip region around the pages clip path. + // This is useful if the page actually contains content outside of it’s clip path. + psParams->emitTransfer = true; // When true, will emit transfer functions to the PostScript + // document, rather than resolving their usage on the host. + psParams->emitBG = true; // When true, will emit Black Generation values to the PostScript + // file, rather than resolving their usage on the host. + psParams->emitUCR = true; // When true, will emit Under Color Removal values to the PostScript + // file, rather than resolving their usage locally. + + psParams->suppressCJKSubstitution = + false; // If allowed, will control the use of printer based substitutes for CJK Fonts. + psParams->brokenCRDs = false; // When true, disables the emission of profiled colors to + // PostScript. In essence, this will force Host color conversion. + + psParams->bitmapResolution = 0; // Set the resolution, in DPI, of emitted bitmaps + // when these are done as actual bitmaps. + psParams->gradientResolution = + 0; // Set the resolution, in DPI, of gradients interior to the object (not edges). + // It can generally be lower than the bitmapResolution. + + psParams->flattenInfo = NULL; // When present, is used to control the flattening of translucent pages. + // If not present, a set of default values is used in its place. + + psParams->emitFlatness = false; // When true, causes the flatness setting in Graphics State to be honored. + psParams->trapType = 0; // Controls whether trapping is done on the host or on the printer. + psParams->suppressSnapToDevice = + false; // When true, will disable the “Snap To Device” rendering option. + // Snap To Device causes all elements to be pixel aligned at the printer resolution. + psParams->suppressElement = 0; // Controls suppression of XMP data, written to the PostScript + // stream. Data may be controlled by type. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Attributes effective only in PostScript to a File. (These purely affect PostScript construction.) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Set psParams.ranges = NULL to print entire document or specify ranges as shown below - psParams->numRanges = 1; // Number of print ranges to specify (ignored if ranges == NULL) - psParams->ranges = (PDPageRange*)malloc(psParams->numRanges * sizeof(PDPageRange)); + psParams->numRanges = 1; // Number of print ranges to specify (ignored if ranges == NULL) + psParams->ranges = (PDPageRange *)malloc(psParams->numRanges * sizeof(PDPageRange)); // Repeat the following for each range up to numRanges (ie psParams.ranges[1], psParams.ranges[2], etc) - psParams->ranges[0].startPage = 0; // Specify starting page - psParams->ranges[0].endPage = -1; // Specify ending page or -1 for end of document - psParams->ranges[0].pageSpec = PDAllPages; // Specify PDAllPages, PDEvenPagesOnly, or PDOddPagesOnly - - psParams->printWhat = PDPrintWhat_DOCUMENT; // Print the document, the document and comments, or document form fields only. - // (NOTE: Effective only when printing with PDFLPrintPDF) - psParams->printWhatAnnot = PDPrintWhatAnnot_NoExtras; // Annotation flags which modify PDPrintWhat. - // (NOTE: Effective only when printing with PDFLPrintPDF) - - psParams->emitPS = true; // Emit a PostScript file - psParams->emitShowpage = true; // Controls emission of the showpage command within the page. - // If there are plans for combining pages at a later date, - // may wish to suppress the show page command. - psParams->emitPageRotation = false; // When true, rotates the page according to PDRotate, before printing. - // (NOTE: This is ONLY used when creating EPSF output) - psParams->destCSAtom = 0; // Used only when printing to a file, and describes the desired - // color space of the printer (One of DeviceGray, DeviceRGB, or DeviceCMYK, only). - - psParams->suppressOPPWhenNoSpots = false; // When true, will suppress OP processing of pages which contain no spot colors. - // This attribute may not be effective in all cases - // (That is, OP Processing may be done on some pages which do not contain spot colors, - // regardless of the setting of this flag). - - psParams->optimizeForSpeed = true; // Emit PostScript such that all fonts are emitted once at the beginning - // of the document. This results in faster transmission times and smaller - // PostScript documents but requires more PostScript printer virtual memory. - // If it is set to true, font downloads are forced from - // kIncludeOnEveryPage to kIncludeOncePerDoc. - // Therefore, false means PostScript code must be page-independent. - - psParams->saveVM = true; // When true, attempts to minimize the use of the PostScript virtual memory. + psParams->ranges[0].startPage = 0; // Specify starting page + psParams->ranges[0].endPage = -1; // Specify ending page or -1 for end of document + psParams->ranges[0].pageSpec = PDAllPages; // Specify PDAllPages, PDEvenPagesOnly, or PDOddPagesOnly + + psParams->printWhat = + PDPrintWhat_DOCUMENT; // Print the document, the document and comments, or document form + // fields only. (NOTE: Effective only when printing with PDFLPrintPDF) + psParams->printWhatAnnot = PDPrintWhatAnnot_NoExtras; // Annotation flags which modify PDPrintWhat. + // (NOTE: Effective only when printing with PDFLPrintPDF) + + psParams->emitPS = true; // Emit a PostScript file + psParams->emitShowpage = true; // Controls emission of the showpage command within the page. + // If there are plans for combining pages at a later date, + // may wish to suppress the show page command. + psParams->emitPageRotation = false; // When true, rotates the page according to PDRotate, before printing. + // (NOTE: This is ONLY used when creating EPSF output) + psParams->destCSAtom = 0; // Used only when printing to a file, and describes the desired + // color space of the printer (One of DeviceGray, DeviceRGB, or DeviceCMYK, only). + + psParams->suppressOPPWhenNoSpots = + false; // When true, will suppress OP processing of pages which contain no spot colors. + // This attribute may not be effective in all cases + // (That is, OP Processing may be done on some pages which do not contain spot + // colors, regardless of the setting of this flag). + + psParams->optimizeForSpeed = + true; // Emit PostScript such that all fonts are emitted once at the beginning + // of the document. This results in faster transmission times and smaller + // PostScript documents but requires more PostScript printer virtual memory. + // If it is set to true, font downloads are forced from + // kIncludeOnEveryPage to kIncludeOncePerDoc. + // Therefore, false means PostScript code must be page-independent. + + psParams->saveVM = true; // When true, attempts to minimize the use of the PostScript virtual memory. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Attributes which are no longer effective. @@ -230,10 +244,8 @@ void SetupPDPrintParams(PDPrintParams psParams) psParams->macQDPrinter = false; } -void DisposePDPrintParams(PDPrintParams psParams) -{ - if (psParams->ranges) - { +void DisposePDPrintParams(PDPrintParams psParams) { + if (psParams->ranges) { psParams->numRanges = 0; free(psParams->ranges); psParams->ranges = NULL; @@ -241,183 +253,178 @@ void DisposePDPrintParams(PDPrintParams psParams) } /* -* The PDFLPrintUserParamsRec is used to specify the types of parameters that -* a user would usually specify in the print dialogue box. It is different for -* each platform due to the different printing functionality available. The following -* code uses conditional compilation so that the samples work on all platforms -*/ -void SetupPDFLPrintUserParams(PDFLPrintUserParams userParams) -{ + * The PDFLPrintUserParamsRec is used to specify the types of parameters that + * a user would usually specify in the print dialogue box. It is different for + * each platform due to the different printing functionality available. The following + * code uses conditional compilation so that the samples work on all platforms + */ +void SetupPDFLPrintUserParams(PDFLPrintUserParams userParams) { /* Initialize the struct */ memset(userParams, 0, sizeof(PDFLPrintUserParamsRec)); userParams->size = sizeof(PDFLPrintUserParamsRec); - // Attributes emitToFile and emitToPrinter must not both be true. + // Attributes emitToFile and emitToPrinter must not both be true. // If they are both true, behavior is as if emitToPrinter is false - userParams->emitToPrinter = true; // If emitToPrinter is true, then the printer identification information should be present. - // If it is not, the system default printer will be used. - // If there is no system default printer, an exception will be raised. + userParams->emitToPrinter = + true; // If emitToPrinter is true, then the printer identification information should be present. + // If it is not, the system default printer will be used. + // If there is no system default printer, an exception will be raised. #ifdef WIN_ENV - - userParams->deviceName = NULL; // Printer Identification information consists of device, port, and driver names. - userParams->deviceNameW = NULL; // These may be supplied as either ASCII, or wide text strings. - // If both the ASCII and wide text names are supplied, the wide text name will be used. + + userParams->deviceName = NULL; // Printer Identification information consists of device, port, and driver names. + userParams->deviceNameW = + NULL; // These may be supplied as either ASCII, or wide text strings. + // If both the ASCII and wide text names are supplied, the wide text name will be used. userParams->portName = NULL; userParams->portNameW = NULL; userParams->driverName = NULL; userParams->driverNameW = NULL; - - userParams->inFileName = NULL; // Used only in working with an actual printer. They are supplied to the - userParams->inFileNameW = NULL; // print driver, for use in a separator page (At the drivers discretion). - // When both are supplied, wide form is used. - - userParams->outFileName = NULL; // Used only when printing to a printer. They indicate that the final driver - userParams->outFileNameW = NULL; // file should be saved in the named file, rather than passed to the printer - // Effectively, they are equivalent to the “print to a file” toggle in most - // printer controls. - // When both are supplied, the wide form will be used. - - userParams->pDevMode = NULL; // Optional attribute. Reference to a Windows DevMode structure. - userParams->pDevModeW = NULL; // The use of the wide form is preferable. If both are present, the wide form will be used. - // When present, it will be used to establish values for printer control information. - // When it is NOT present, and printing to a printer, APDFL will obtain the default - // DevMode for the selected printer to use in its place. - // When the user supplies the DevMode, it’s values for nCopies, Duplex, and Collate - // will be used, rather than the values specified in the control structures. - // When it is obtained from the default for the printer, the values specified in the - // control structures will be preferred. - - userParams->farEastFontOpt = false; // Controls if very large fonts are to be downloaded or not. This is effective only for PostScript. - - userParams->transQuality = false; // Echoes the attribute transparencyQuality in the PDPrintParamsRec. - // Controls how the flattener will remove transparency from a page. - - userParams->startResult = 0; // Should be set to the jobId returned by StartDoc, if the application does the StartDoc. - userParams->pDC = NULL; // Will be filled in by APDFL to the DeviceContext for the currently selected printer. - // It will contain the value supplied in hDC, if such a value is supplied. - - userParams->hDC = NULL; // Supplied by the user. This should be a Device Context for the same print device - // as is named in deviceName. If it is not, then deviceName will be replaced with the name of the - // device this context refers to. - - userParams->forceGDIPrint = false; // When true, will cause Print To GDI to be used, even if the printer selected is capable of - // supporting PostScript. + userParams->inFileName = NULL; // Used only in working with an actual printer. They are supplied to the + userParams->inFileNameW = NULL; // print driver, for use in a separator page (At the drivers + // discretion). When both are supplied, wide form is used. + + userParams->outFileName = NULL; // Used only when printing to a printer. They indicate that the final driver + userParams->outFileNameW = + NULL; // file should be saved in the named file, rather than passed to the printer + // Effectively, they are equivalent to the “print to a file” toggle in most + // printer controls. + // When both are supplied, the wide form will be used. + + userParams->pDevMode = NULL; // Optional attribute. Reference to a Windows DevMode structure. + userParams->pDevModeW = + NULL; // The use of the wide form is preferable. If both are present, the wide form will be used. + // When present, it will be used to establish values for printer control information. + // When it is NOT present, and printing to a printer, APDFL will obtain the default + // DevMode for the selected printer to use in its place. + // When the user supplies the DevMode, it’s values for nCopies, Duplex, and Collate + // will be used, rather than the values specified in the control structures. + // When it is obtained from the default for the printer, the values specified in the + // control structures will be preferred. + + userParams->farEastFontOpt = + false; // Controls if very large fonts are to be downloaded or not. This is effective only for PostScript. + + userParams->transQuality = false; // Echoes the attribute transparencyQuality in the PDPrintParamsRec. + // Controls how the flattener will remove transparency from a page. + + userParams->startResult = + 0; // Should be set to the jobId returned by StartDoc, if the application does the StartDoc. + userParams->pDC = NULL; // Will be filled in by APDFL to the DeviceContext for the currently selected printer. + // It will contain the value supplied in hDC, if such a value is supplied. + + userParams->hDC = NULL; // Supplied by the user. This should be a Device Context for the same + // print device as is named in deviceName. If it is not, then deviceName + // will be replaced with the name of the device this context refers to. + + userParams->forceGDIPrint = false; // When true, will cause Print To GDI to be used, even if the + // printer selected is capable of supporting PostScript. #endif - - userParams->paperWidth = kPDPrintUseMediaBox; // Used to select paper. The value kPDPrintUseMediaBox will cause the page - // size to be used, rather than a fixed size. - userParams->paperHeight = kPDPrintUseMediaBox; // Used to select paper. The value kPDPrintUseMediaBox will cause the page - // size to be used, rather than a fixed size. - - userParams->dontEmitList = NULL; // Used only when creating PostScript and indicates fonts that are not to - userParams->dontEmitListLen = 0; // be downloaded to the printer, or included in the PostScript file. - - userParams->cancelProc = NULL; // Establish a procedure, which is called periodically, which is able to cancel a print operation - userParams->clientData = NULL; // in progress. - - userParams->PPDFeatures = NULL; // Used only in printing to PostScript. Normally, the PPD File will be located via the system - userParams->ppdFileName = NULL; // for PostScript to a Printer, and the features available will be only those features in the system - // installed PPD File. This mechanism may be used to attach feature information for PostScript to a File. - - - userParams->progressProc = NULL; // Used to identify a procedure that should be called periodically during printing, to permit a - // progress reporting function. - userParams->userCallbacks = NULL; // Establishes callbacks to be used in this print run. - - - userParams->emitToFile = false; // If emitToFile is true, then the attribute printStm - // must contain a reference to a valid ASStm object, - // which will contain the PostScript file. + + userParams->paperWidth = + kPDPrintUseMediaBox; // Used to select paper. The value kPDPrintUseMediaBox will cause the + // page size to be used, rather than a fixed size. + userParams->paperHeight = + kPDPrintUseMediaBox; // Used to select paper. The value kPDPrintUseMediaBox will cause the + // page size to be used, rather than a fixed size. + + userParams->dontEmitList = NULL; // Used only when creating PostScript and indicates fonts that are not to + userParams->dontEmitListLen = 0; // be downloaded to the printer, or included in the PostScript file. + + userParams->cancelProc = + NULL; // Establish a procedure, which is called periodically, which is able to cancel a print operation + userParams->clientData = NULL; // in progress. + + userParams->PPDFeatures = + NULL; // Used only in printing to PostScript. Normally, the PPD File will be located via the system + userParams->ppdFileName = + NULL; // for PostScript to a Printer, and the features available will be only those features in the system + // installed PPD File. This mechanism may be used to attach feature information for PostScript to a File. + + userParams->progressProc = + NULL; // Used to identify a procedure that should be called periodically during printing, to + // permit a progress reporting function. + userParams->userCallbacks = NULL; // Establishes callbacks to be used in this print run. + + userParams->emitToFile = false; // If emitToFile is true, then the attribute printStm + // must contain a reference to a valid ASStm object, + // which will contain the PostScript file. userParams->printStm = NULL; #ifdef UNIX_ENV - userParams->command = const_cast("lp"); // Optional command line arguments (used only if emitToPrinter is true) + userParams->command = const_cast("lp"); // Optional command line arguments (used only if emitToPrinter is true) #endif #ifndef UNIX_ENV - userParams->nCopies = 1; // Number of copies to print - // (applies to both a PostScript printer and a file) - userParams->startPage = 0; // Page to start printing with, using zero-based numbering - // When we are printing PostScript to a File, this is ignored - // and the range defined in the PDPrintParamsRec is used instead. - userParams->endPage = 1; // Page on which to finish printing (applies to a printer) - // When we are printing PostScript to a File, this is ignored - // and the range defined in the PDPrintParamsRec is used instead. - - userParams->psLevel = 3; // Controls the contents of a PostScript file to be limited to - // the specified level. If the printer itself specifies a lower level, - // then that level will be used. - userParams->shrinkToFit = true; // When true, will cause the page size to be decreased to match the media size. - - userParams->printAnnots = false; // When true, will cause annotations, only those allowed to be printed, to print. - userParams->binaryOK = false; // When true, will permit binary content in generated PostScript. - userParams->emitHalftones = false; // When true, halftone data will be included in a PostScript rendering. - userParams->reverse = false; // When true, will cause the pages to be printed from last to first. - - userParams->doOPP = false; // Echoes the PDPrintParamsRec attribute of the same name. When true, we will “blend” CMYK colors - // using the OP transparency model. + userParams->nCopies = 1; // Number of copies to print + // (applies to both a PostScript printer and a file) + userParams->startPage = 0; // Page to start printing with, using zero-based numbering + // When we are printing PostScript to a File, this is ignored + // and the range defined in the PDPrintParamsRec is used instead. + userParams->endPage = 1; // Page on which to finish printing (applies to a printer) + // When we are printing PostScript to a File, this is ignored + // and the range defined in the PDPrintParamsRec is used instead. + + userParams->psLevel = 3; // Controls the contents of a PostScript file to be limited to + // the specified level. If the printer itself specifies a lower level, + // then that level will be used. + userParams->shrinkToFit = true; // When true, will cause the page size to be decreased to match the media size. + + userParams->printAnnots = false; // When true, will cause annotations, only those allowed to be printed, to print. + userParams->binaryOK = false; // When true, will permit binary content in generated PostScript. + userParams->emitHalftones = false; // When true, halftone data will be included in a PostScript rendering. + userParams->reverse = false; // When true, will cause the pages to be printed from last to first. + + userParams->doOPP = false; // Echoes the PDPrintParamsRec attribute of the same name. When true, + // we will “blend” CMYK colors using the OP transparency model. #endif } -void DisposePDFLPrintUserParams(PDFLPrintUserParams userParams) -{ +void DisposePDFLPrintUserParams(PDFLPrintUserParams userParams) { #ifdef WIN_ENV - if (userParams->pDevMode) - { + if (userParams->pDevMode) { free(userParams->pDevMode); } - if (userParams->pDevModeW) - { + if (userParams->pDevModeW) { free(userParams->pDevModeW); } - if (userParams->deviceName) - { + if (userParams->deviceName) { delete[] userParams->deviceName; } - if (userParams->deviceNameW) - { + if (userParams->deviceNameW) { delete[] userParams->deviceNameW; } - if (userParams->portName) - { + if (userParams->portName) { delete[] userParams->portName; } - if (userParams->portNameW) - { + if (userParams->portNameW) { delete[] userParams->portNameW; } - if (userParams->driverName) - { + if (userParams->driverName) { delete[] userParams->driverName; } - if (userParams->driverNameW) - { + if (userParams->driverNameW) { delete[] userParams->driverNameW; } - if (userParams->inFileName) - { + if (userParams->inFileName) { delete[] userParams->inFileName; } - if (userParams->inFileNameW) - { + if (userParams->inFileNameW) { delete[] userParams->inFileNameW; } - if (userParams->outFileName) - { + if (userParams->outFileName) { delete[] userParams->outFileName; } - if (userParams->outFileNameW) - { + if (userParams->outFileNameW) { delete[] userParams->outFileNameW; } #endif diff --git a/CPlusPlus/Sample_Source/_Common/SetupPrintParams.h b/CPlusPlus/Sample_Source/_Common/SetupPrintParams.h index 2343799f..db7baed0 100644 --- a/CPlusPlus/Sample_Source/_Common/SetupPrintParams.h +++ b/CPlusPlus/Sample_Source/_Common/SetupPrintParams.h @@ -25,4 +25,4 @@ void SetupPDFLPrintUserParams(PDFLPrintUserParams userParams); // Cleanup the PDFL user print parameters void DisposePDFLPrintUserParams(PDFLPrintUserParams userParams); -#endif /* _SETUPPRINTPARAMS_H_ */ +#endif /* _SETUPPRINTPARAMS_H_ */ diff --git a/CPlusPlus/Sample_Source/_Common/ThirdParty/ScopeGuard.h b/CPlusPlus/Sample_Source/_Common/ThirdParty/ScopeGuard.h index 5112ddaf..a3b93809 100644 --- a/CPlusPlus/Sample_Source/_Common/ThirdParty/ScopeGuard.h +++ b/CPlusPlus/Sample_Source/_Common/ThirdParty/ScopeGuard.h @@ -6,297 +6,203 @@ * * @file ScopeGuard.h * @date 9/21/2009 17:20 - * + * * @brief Scope guard objects - * + * * Source code from: Generic: Change the Way You Write Exception-Safe Code Forever * by Andrei Alexandrescu and Petru Marginean - * + * * Appeared in CUJ (Dec 2000) and DDJ (April 15, 2003) - * + * * Article: http://www.ddj.com/dept/cpp/184403758 * Download: ftp://66.77.27.238/sourcecode/cuj/2000/cujdec2000.zip - * + * * ScopeGuard creates automatic variables that can cause functions to be called * when going out of scope (including function return and exception throw). * Implements RAII. - * + * */ #ifndef SCOPEGUARD_H_ #define SCOPEGUARD_H_ -template -class RefHolder -{ - T& ref_; -public: - RefHolder(T& ref) : ref_(ref) {} - operator T& () const - { - return ref_; - } -private: +template class RefHolder { + T &ref_; + + public: + RefHolder(T &ref) : ref_(ref) {} + operator T &() const { return ref_; } + + private: // Disable assignment - not implemented - RefHolder& operator=(const RefHolder&); + RefHolder &operator=(const RefHolder &); }; -template -inline RefHolder ByRef(T& t) -{ - return RefHolder(t); -} - -class ScopeGuardImplBase -{ - ScopeGuardImplBase& operator =(const ScopeGuardImplBase&); -protected: - ~ScopeGuardImplBase() - { - } - ScopeGuardImplBase(const ScopeGuardImplBase& other) throw() - : dismissed_(other.dismissed_) - { - other.Dismiss(); - } - template - static void SafeExecute(J& j) throw() - { - if (!j.dismissed_) - try - { - j.Execute(); - } - catch(...) - { - } - } - - mutable bool dismissed_; -public: - ScopeGuardImplBase() throw() : dismissed_(false) - { - } - void Dismiss() const throw() - { - dismissed_ = true; - } +template inline RefHolder ByRef(T &t) { return RefHolder(t); } + +class ScopeGuardImplBase { + ScopeGuardImplBase &operator=(const ScopeGuardImplBase &); + + protected: + ~ScopeGuardImplBase() {} + ScopeGuardImplBase(const ScopeGuardImplBase &other) throw() : dismissed_(other.dismissed_) { + other.Dismiss(); + } + template static void SafeExecute(J &j) throw() { + if (!j.dismissed_) + try { + j.Execute(); + } catch (...) { + } + } + + mutable bool dismissed_; + + public: + ScopeGuardImplBase() throw() : dismissed_(false) {} + void Dismiss() const throw() { dismissed_ = true; } }; -typedef const ScopeGuardImplBase& ScopeGuard; - -template -class ScopeGuardImpl0 : public ScopeGuardImplBase -{ -public: - static ScopeGuardImpl0 MakeGuard(F fun) - { - return ScopeGuardImpl0(fun); - } - ~ScopeGuardImpl0() throw() - { - SafeExecute(*this); - } - void Execute() - { - fun_(); - } -protected: - ScopeGuardImpl0(F fun) : fun_(fun) - { - } - F fun_; +typedef const ScopeGuardImplBase &ScopeGuard; + +template class ScopeGuardImpl0 : public ScopeGuardImplBase { + public: + static ScopeGuardImpl0 MakeGuard(F fun) { return ScopeGuardImpl0(fun); } + ~ScopeGuardImpl0() throw() { SafeExecute(*this); } + void Execute() { fun_(); } + + protected: + ScopeGuardImpl0(F fun) : fun_(fun) {} + F fun_; }; -template -inline ScopeGuardImpl0 MakeGuard(F fun) -{ - return ScopeGuardImpl0::MakeGuard(fun); +template inline ScopeGuardImpl0 MakeGuard(F fun) { + return ScopeGuardImpl0::MakeGuard(fun); } -template -class ScopeGuardImpl1 : public ScopeGuardImplBase -{ -public: - static ScopeGuardImpl1 MakeGuard(F fun, P1 p1) - { - return ScopeGuardImpl1(fun, p1); - } - ~ScopeGuardImpl1() throw() - { - SafeExecute(*this); - } - void Execute() - { - fun_(p1_); - } -protected: - ScopeGuardImpl1(F fun, P1 p1) : fun_(fun), p1_(p1) - { - } - F fun_; - const P1 p1_; +template class ScopeGuardImpl1 : public ScopeGuardImplBase { + public: + static ScopeGuardImpl1 MakeGuard(F fun, P1 p1) { + return ScopeGuardImpl1(fun, p1); + } + ~ScopeGuardImpl1() throw() { SafeExecute(*this); } + void Execute() { fun_(p1_); } + + protected: + ScopeGuardImpl1(F fun, P1 p1) : fun_(fun), p1_(p1) {} + F fun_; + const P1 p1_; }; -template -inline ScopeGuardImpl1 MakeGuard(F fun, P1 p1) -{ - return ScopeGuardImpl1::MakeGuard(fun, p1); +template inline ScopeGuardImpl1 MakeGuard(F fun, P1 p1) { + return ScopeGuardImpl1::MakeGuard(fun, p1); } -template -class ScopeGuardImpl2: public ScopeGuardImplBase -{ -public: - static ScopeGuardImpl2 MakeGuard(F fun, P1 p1, P2 p2) - { - return ScopeGuardImpl2(fun, p1, p2); - } - ~ScopeGuardImpl2() throw() - { - SafeExecute(*this); - } - void Execute() - { - fun_(p1_, p2_); - } -protected: - ScopeGuardImpl2(F fun, P1 p1, P2 p2) : fun_(fun), p1_(p1), p2_(p2) - { - } - F fun_; - const P1 p1_; - const P2 p2_; +template class ScopeGuardImpl2 : public ScopeGuardImplBase { + public: + static ScopeGuardImpl2 MakeGuard(F fun, P1 p1, P2 p2) { + return ScopeGuardImpl2(fun, p1, p2); + } + ~ScopeGuardImpl2() throw() { SafeExecute(*this); } + void Execute() { fun_(p1_, p2_); } + + protected: + ScopeGuardImpl2(F fun, P1 p1, P2 p2) : fun_(fun), p1_(p1), p2_(p2) {} + F fun_; + const P1 p1_; + const P2 p2_; }; template -inline ScopeGuardImpl2 MakeGuard(F fun, P1 p1, P2 p2) -{ - return ScopeGuardImpl2::MakeGuard(fun, p1, p2); +inline ScopeGuardImpl2 MakeGuard(F fun, P1 p1, P2 p2) { + return ScopeGuardImpl2::MakeGuard(fun, p1, p2); } template -class ScopeGuardImpl3 : public ScopeGuardImplBase -{ -public: - static ScopeGuardImpl3 MakeGuard(F fun, P1 p1, P2 p2, P3 p3) - { - return ScopeGuardImpl3(fun, p1, p2, p3); - } - ~ScopeGuardImpl3() throw() - { - SafeExecute(*this); - } - void Execute() - { - fun_(p1_, p2_, p3_); - } -protected: - ScopeGuardImpl3(F fun, P1 p1, P2 p2, P3 p3) : fun_(fun), p1_(p1), p2_(p2), p3_(p3) - { - } - F fun_; - const P1 p1_; - const P2 p2_; - const P3 p3_; +class ScopeGuardImpl3 : public ScopeGuardImplBase { + public: + static ScopeGuardImpl3 MakeGuard(F fun, P1 p1, P2 p2, P3 p3) { + return ScopeGuardImpl3(fun, p1, p2, p3); + } + ~ScopeGuardImpl3() throw() { SafeExecute(*this); } + void Execute() { fun_(p1_, p2_, p3_); } + + protected: + ScopeGuardImpl3(F fun, P1 p1, P2 p2, P3 p3) : fun_(fun), p1_(p1), p2_(p2), p3_(p3) {} + F fun_; + const P1 p1_; + const P2 p2_; + const P3 p3_; }; template -inline ScopeGuardImpl3 MakeGuard(F fun, P1 p1, P2 p2, P3 p3) -{ - return ScopeGuardImpl3::MakeGuard(fun, p1, p2, p3); +inline ScopeGuardImpl3 MakeGuard(F fun, P1 p1, P2 p2, P3 p3) { + return ScopeGuardImpl3::MakeGuard(fun, p1, p2, p3); } //************************************************************ -template -class ObjScopeGuardImpl0 : public ScopeGuardImplBase -{ -public: - static ObjScopeGuardImpl0 MakeObjGuard(Obj& obj, MemFun memFun) - { - return ObjScopeGuardImpl0(obj, memFun); - } - ~ObjScopeGuardImpl0() throw() - { - SafeExecute(*this); - } - void Execute() - { - (obj_.*memFun_)(); - } -protected: - ObjScopeGuardImpl0(Obj& obj, MemFun memFun) - : obj_(obj), memFun_(memFun) {} - Obj& obj_; - MemFun memFun_; +template class ObjScopeGuardImpl0 : public ScopeGuardImplBase { + public: + static ObjScopeGuardImpl0 MakeObjGuard(Obj &obj, MemFun memFun) { + return ObjScopeGuardImpl0(obj, memFun); + } + ~ObjScopeGuardImpl0() throw() { SafeExecute(*this); } + void Execute() { (obj_.*memFun_)(); } + + protected: + ObjScopeGuardImpl0(Obj &obj, MemFun memFun) : obj_(obj), memFun_(memFun) {} + Obj &obj_; + MemFun memFun_; }; template -inline ObjScopeGuardImpl0 MakeObjGuard(Obj& obj, MemFun memFun) -{ - return ObjScopeGuardImpl0::MakeObjGuard(obj, memFun); +inline ObjScopeGuardImpl0 MakeObjGuard(Obj &obj, MemFun memFun) { + return ObjScopeGuardImpl0::MakeObjGuard(obj, memFun); } template -class ObjScopeGuardImpl1 : public ScopeGuardImplBase -{ -public: - static ObjScopeGuardImpl1 MakeObjGuard(Obj& obj, MemFun memFun, P1 p1) - { - return ObjScopeGuardImpl1(obj, memFun, p1); - } - ~ObjScopeGuardImpl1() throw() - { - SafeExecute(*this); - } - void Execute() - { - (obj_.*memFun_)(p1_); - } -protected: - ObjScopeGuardImpl1(Obj& obj, MemFun memFun, P1 p1) - : obj_(obj), memFun_(memFun), p1_(p1) {} - Obj& obj_; - MemFun memFun_; - const P1 p1_; +class ObjScopeGuardImpl1 : public ScopeGuardImplBase { + public: + static ObjScopeGuardImpl1 MakeObjGuard(Obj &obj, MemFun memFun, P1 p1) { + return ObjScopeGuardImpl1(obj, memFun, p1); + } + ~ObjScopeGuardImpl1() throw() { SafeExecute(*this); } + void Execute() { (obj_.*memFun_)(p1_); } + + protected: + ObjScopeGuardImpl1(Obj &obj, MemFun memFun, P1 p1) : obj_(obj), memFun_(memFun), p1_(p1) {} + Obj &obj_; + MemFun memFun_; + const P1 p1_; }; template -inline ObjScopeGuardImpl1 MakeObjGuard(Obj& obj, MemFun memFun, P1 p1) -{ - return ObjScopeGuardImpl1::MakeObjGuard(obj, memFun, p1); +inline ObjScopeGuardImpl1 MakeObjGuard(Obj &obj, MemFun memFun, P1 p1) { + return ObjScopeGuardImpl1::MakeObjGuard(obj, memFun, p1); } template -class ObjScopeGuardImpl2 : public ScopeGuardImplBase -{ -public: - static ObjScopeGuardImpl2 MakeObjGuard(Obj& obj, MemFun memFun, P1 p1, P2 p2) - { - return ObjScopeGuardImpl2(obj, memFun, p1, p2); - } - ~ObjScopeGuardImpl2() throw() - { - SafeExecute(*this); - } - void Execute() - { - (obj_.*memFun_)(p1_, p2_); - } -protected: - ObjScopeGuardImpl2(Obj& obj, MemFun memFun, P1 p1, P2 p2) - : obj_(obj), memFun_(memFun), p1_(p1), p2_(p2) {} - Obj& obj_; - MemFun memFun_; - const P1 p1_; - const P2 p2_; +class ObjScopeGuardImpl2 : public ScopeGuardImplBase { + public: + static ObjScopeGuardImpl2 MakeObjGuard(Obj &obj, MemFun memFun, P1 p1, P2 p2) { + return ObjScopeGuardImpl2(obj, memFun, p1, p2); + } + ~ObjScopeGuardImpl2() throw() { SafeExecute(*this); } + void Execute() { (obj_.*memFun_)(p1_, p2_); } + + protected: + ObjScopeGuardImpl2(Obj &obj, MemFun memFun, P1 p1, P2 p2) + : obj_(obj), memFun_(memFun), p1_(p1), p2_(p2) {} + Obj &obj_; + MemFun memFun_; + const P1 p1_; + const P2 p2_; }; template -inline ObjScopeGuardImpl2 MakeObjGuard(Obj& obj, MemFun memFun, P1 p1, P2 p2) -{ - return ObjScopeGuardImpl2::MakeObjGuard(obj, memFun, p1, p2); +inline ObjScopeGuardImpl2 MakeObjGuard(Obj &obj, MemFun memFun, P1 p1, P2 p2) { + return ObjScopeGuardImpl2::MakeObjGuard(obj, memFun, p1, p2); } #define CONCATENATE_DIRECT(s1, s2) s1##s2 @@ -306,4 +212,4 @@ inline ObjScopeGuardImpl2 MakeObjGuard(Obj& obj, MemFun mem #define ON_BLOCK_EXIT ScopeGuard ANONYMOUS_VARIABLE(scopeGuard) = MakeGuard #define ON_BLOCK_EXIT_OBJ ScopeGuard ANONYMOUS_VARIABLE(scopeGuard) = MakeObjGuard -#endif //SCOPEGUARD_H_ +#endif // SCOPEGUARD_H_ diff --git a/DotNET/Sample_Source/Annotations/AnnotationCopyPaste/AnnotationCopyPaste.cs b/DotNET/Sample_Source/Annotations/AnnotationCopyPaste/AnnotationCopyPaste.cs index 38a4fa1f..a50764bc 100644 --- a/DotNET/Sample_Source/Annotations/AnnotationCopyPaste/AnnotationCopyPaste.cs +++ b/DotNET/Sample_Source/Annotations/AnnotationCopyPaste/AnnotationCopyPaste.cs @@ -33,8 +33,8 @@ static void Main(string[] args) { Console.WriteLine("Initialized the library."); - String sInput1 = "../../Resources/Sample_Input/sample_annotations.pdf"; - String sInput2 = "../../Resources/Sample_Input/Layers.pdf"; + String sInput1 = Library.ResourceDirectory + "Sample_Input/sample_annotations.pdf"; + String sInput2 = Library.ResourceDirectory + "Sample_Input/Layers.pdf"; String sOutput = "../AnnotationCopyPaste-out.pdf"; if (args.Length > 0) diff --git a/DotNET/Sample_Source/Annotations/InkAnnotations/InkAnnotations.cs b/DotNET/Sample_Source/Annotations/InkAnnotations/InkAnnotations.cs index cd56cb24..b0cea858 100644 --- a/DotNET/Sample_Source/Annotations/InkAnnotations/InkAnnotations.cs +++ b/DotNET/Sample_Source/Annotations/InkAnnotations/InkAnnotations.cs @@ -116,7 +116,7 @@ static void Main(string[] args) // Update the page's content and save the file with clipping page.UpdateContent(); - doc.Save(SaveFlags.Full, "InkAnnotations-out1.pdf"); + doc.Save(SaveFlags.Full, "../InkAnnotations-out1.pdf"); Console.WriteLine("Saved InkAnnotations-out1.pdf"); // Remove 0th scribble @@ -129,7 +129,7 @@ static void Main(string[] args) // Update the page's content and save the file with clipping page.UpdateContent(); - doc.Save(SaveFlags.Full, "InkAnnotations-out2.pdf"); + doc.Save(SaveFlags.Full, "../InkAnnotations-out2.pdf"); // Kill the doc object doc.Dispose(); diff --git a/DotNET/Sample_Source/ContentModification/Action/Action.cs b/DotNET/Sample_Source/ContentModification/Action/Action.cs index c7791b67..3589bb1b 100644 --- a/DotNET/Sample_Source/ContentModification/Action/Action.cs +++ b/DotNET/Sample_Source/ContentModification/Action/Action.cs @@ -43,7 +43,7 @@ static void Main(string[] args) Console.WriteLine(newLink.ToString()); doc.BaseURI = "http://www.datalogics.com"; - URIAction uri = new URIAction("/products/pdfl/pdflibrary.asp", false); + URIAction uri = new URIAction("/products/pdf/pdflibrary/", false); Console.WriteLine("Action data: " + uri.ToString()); newLink.Action = uri; @@ -69,7 +69,7 @@ static void Main(string[] args) // Change the URI properties doc.BaseURI = "http://www.datalogics.com"; - uri.URI = "/products/pdfl/pdflibrary.asp"; + uri.URI = "/products/pdf/pdflibrary/"; uri.IsMap = true; diff --git a/DotNET/Sample_Source/Display/DotNETViewer/DotNETViewer.cs b/DotNET/Sample_Source/Display/DotNETViewer/DotNETViewer.cs index 13345420..52bd0ab6 100644 --- a/DotNET/Sample_Source/Display/DotNETViewer/DotNETViewer.cs +++ b/DotNET/Sample_Source/Display/DotNETViewer/DotNETViewer.cs @@ -27,7 +27,11 @@ static class DotNETViewer static void Main(String[] args) { commandLineArgs = args; - using (Library lib = new Library()) + List paths = new List(); + paths.Add(Library.ResourceDirectory + "Fonts"); + paths.Add(Library.ResourceDirectory + "CMaps"); + + using (Library lib = new Library(paths, Library.ResourceDirectory + "CMap", Library.ResourceDirectory + "Unicode", Library.ResourceDirectory + "Color", LibraryFlags.NoFlags)) { // Set visual styles // Set default thread exceptions diff --git a/DotNET/Sample_Source/Display/DotNETViewerComponent/DotNETPrintController.cs b/DotNET/Sample_Source/Display/DotNETViewerComponent/DotNETPrintController.cs index cada2f50..ca1a99e7 100644 --- a/DotNET/Sample_Source/Display/DotNETViewerComponent/DotNETPrintController.cs +++ b/DotNET/Sample_Source/Display/DotNETViewerComponent/DotNETPrintController.cs @@ -158,7 +158,9 @@ private void printDocument_PrintPage(object sender, PrintPageEventArgs ev) drawParams.UpdateRect = updateRect; drawParams.SmoothFlags = SmoothFlags.Image | SmoothFlags.LineArt | SmoothFlags.Text; - drawParams.Flags = DrawFlags.UseAnnotFaces; + // If we use 'DrawFlags.OptimizeForInteractive' here, we also have to set the same + // flag in the 'ImageArray2DManager.cs', function 'PageCache::Create(...)'. + drawParams.Flags = DrawFlags.UseAnnotFaces | DrawFlags.OptimizeForInteractive; #if DRAWWITHBITMAPS drawParams.Matrix = matrix; diff --git a/DotNET/Sample_Source/Display/DotNETViewerComponent/DotNETPrintDialog.cs b/DotNET/Sample_Source/Display/DotNETViewerComponent/DotNETPrintDialog.cs index d888cd27..8465af55 100644 --- a/DotNET/Sample_Source/Display/DotNETViewerComponent/DotNETPrintDialog.cs +++ b/DotNET/Sample_Source/Display/DotNETViewerComponent/DotNETPrintDialog.cs @@ -72,8 +72,37 @@ private struct PRINTDLG public IntPtr hSetupTemplate; } + [StructLayout(LayoutKind.Sequential, Pack = 8, CharSet = CharSet.Auto)] + private struct PRINTDLG_64 + { + public Int32 lStructSize; + public IntPtr hwndOwner; + public IntPtr hDevMode; + public IntPtr hDevNames; + public IntPtr hDC; + public Int32 Flags; + public UInt16 nFromPage; + public UInt16 nToPage; + public UInt16 nMinPage; + public UInt16 nMaxPage; + public UInt16 nCopies; + public IntPtr hInstance; + public Int32 lCustData; + public PrintHookProc lpfnPrintHook; + public IntPtr lpfnSetupHook; + public string lpPrintTemplateName; + public string lpSetupTemplateName; + public IntPtr hPrintTemplate; + public IntPtr hSetupTemplate; + } + +#if X64 + [DllImport("comdlg32.dll", CharSet = CharSet.Auto)] + private static extern bool PrintDlg(ref PRINTDLG_64 pdlg); +#else [DllImport("comdlg32.dll", CharSet = CharSet.Auto)] - private static extern bool PrintDlg(ref PRINTDLG pdlg); + private static extern bool PrintDlg(ref PRINTDLG pdlg); +#endif [DllImport("comdlg32.dll", CharSet = CharSet.Auto)] private static extern Int32 CommDlgExtendedError(); @@ -128,7 +157,12 @@ private struct POINT private bool fShrinkToFit; private bool allowShrinkToFit = false; +#if X64 + private PRINTDLG_64 pdlg; +#else private PRINTDLG pdlg; +#endif + private PrintDocument pDoc = null; private PrinterSettings pSettings = null; private CheckBox shrinkToFitCheckBox = new CheckBox(); @@ -198,7 +232,11 @@ public DotNETPrintDialog() public override void Reset() { +#if X64 + pdlg = new PRINTDLG_64(); +#else pdlg = new PRINTDLG(); +#endif pdlg.lStructSize = Marshal.SizeOf(pdlg); pDoc = null; pSettings = new PrinterSettings(); diff --git a/DotNET/Sample_Source/Display/DotNETViewerComponent/DotNETView.cs b/DotNET/Sample_Source/Display/DotNETViewerComponent/DotNETView.cs index 4032c2ac..ff9b4502 100644 --- a/DotNET/Sample_Source/Display/DotNETViewerComponent/DotNETView.cs +++ b/DotNET/Sample_Source/Display/DotNETViewerComponent/DotNETView.cs @@ -898,6 +898,7 @@ private IList GetPageQuads(int pageNum) config.NoStyleInfo = true; config.PreserveSpaces = false; config.PreserveRedundantChars = false; + config.DisableTaggedPDF = true; using (WordFinder wordFinder = new WordFinder(document, WordFinderVersion.Latest, config)) { @@ -1947,6 +1948,7 @@ private void TestMarkup() config.NoStyleInfo = true; config.PreserveSpaces = false; config.PreserveRedundantChars = false; + config.DisableTaggedPDF = true; using (WordFinder wordFinder = new WordFinder(document, WordFinderVersion.Latest, config)) { diff --git a/DotNET/Sample_Source/Display/DotNETViewerComponent/ImageArray2DManager.cs b/DotNET/Sample_Source/Display/DotNETViewerComponent/ImageArray2DManager.cs index 56a6a477..79aea1df 100644 --- a/DotNET/Sample_Source/Display/DotNETViewerComponent/ImageArray2DManager.cs +++ b/DotNET/Sample_Source/Display/DotNETViewerComponent/ImageArray2DManager.cs @@ -63,9 +63,12 @@ public Tile Create(Rectangle tileRect) return new Tile(); } DrawParams drawParams = new DrawParams(); + // If we use 'DrawFlags.OptimizeForInteractive' here, we also have + // to set the same flag in the 'DotNETPrintController.cs', function + // 'DotNETPrintController::printDocument_PrintPage'. drawParams.Flags = DrawFlags.UseAnnotFaces | DrawFlags.DoLazyErase | DrawFlags.OptimizeForInteractive; drawParams.SmoothFlags = SmoothFlags.LineArt | SmoothFlags.Text | SmoothFlags.Image; - drawParams.BypassCopyPerm = true; + drawParams.BypassCopyPerm = false; drawParams.OptionalContentContext = occ; Matrix pageMatrix = new Matrix(); diff --git a/DotNET/Sample_Source/Display/DotNETViewerComponent/TextSearchManager.cs b/DotNET/Sample_Source/Display/DotNETViewerComponent/TextSearchManager.cs index bf4c2e62..b90337f5 100644 --- a/DotNET/Sample_Source/Display/DotNETViewerComponent/TextSearchManager.cs +++ b/DotNET/Sample_Source/Display/DotNETViewerComponent/TextSearchManager.cs @@ -91,6 +91,13 @@ private void search(int PageNum) // create the config for the wordfinder WordFinderConfig config = new WordFinderConfig(); config.IgnoreCharGaps = true; + config.NoAnnots = true; + config.NoEncodingGuess = true; + config.NoSkewedQuads = false; + config.NoStyleInfo = false; + config.PreserveSpaces = false; + config.PreserveRedundantChars = false; + config.DisableTaggedPDF = true; // create a wordfinder for the current page using (WordFinder wordFinder = new WordFinder(dleController.Document, WordFinderVersion.Latest, config)) diff --git a/DotNET/Sample_Source/Images/DrawToBitmap/DrawToBitmap.cs b/DotNET/Sample_Source/Images/DrawToBitmap/DrawToBitmap.cs index bed3ad69..713516f0 100644 --- a/DotNET/Sample_Source/Images/DrawToBitmap/DrawToBitmap.cs +++ b/DotNET/Sample_Source/Images/DrawToBitmap/DrawToBitmap.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Collections.Generic; +using System.Diagnostics; using System.Drawing; using System.Drawing.Imaging; using System.Runtime.InteropServices; @@ -11,7 +12,7 @@ * * This program sample converts a PDF file to a series of bitmap image files. * - * For more detail see the description of the DrawtoBitmap sample program on our Developer’s site, + * For more detail see the description of the DrawtoBitmap sample program on our Developer's site, * http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/net-sample-programs/converting-pdf-pages-to-images/#drawtobitmap * * @@ -310,6 +311,7 @@ static void DrawToByteArray(Page pg, double width, double height, Matrix matrix) { Byte[] rawBytes = null; + Rect roundedDestRect; using (DrawParams parms = new DrawParams()) { parms.ColorSpace = ColorSpace.DeviceRGB; @@ -317,7 +319,19 @@ static void DrawToByteArray(Page pg, double width, double height, Matrix matrix) parms.Matrix = matrix; parms.Flags = DrawFlags.DoLazyErase | DrawFlags.UseAnnotFaces | DrawFlags.SwapComponents; parms.SmoothFlags = SmoothFlags.Image | SmoothFlags.Text; - parms.DestRect = parms.UpdateRect.Transform(matrix); + var destRect = parms.UpdateRect.Transform(matrix); + + // Round the corners of the destRect so that it's a whole number of pixels. + // This removes any ambiguity about how DrawContents treats a rectangle that has + // a width or height that contains a fraction. It ensures that our assumptions about + // the data in the returned Byte array are the same as those made by DrawContents. + roundedDestRect = new Rect( + Math.Round(destRect.LLx), + Math.Round(destRect.LLy), + Math.Round(destRect.URx), + Math.Round(destRect.URy)); + + parms.DestRect = roundedDestRect; parms.CancelProc = new SampleCancelProc(); parms.ProgressProc = new SampleRenderProgressProc(); @@ -330,29 +344,22 @@ static void DrawToByteArray(Page pg, double width, double height, Matrix matrix) return; } - // - // Get an (unsafe) pointer to the beginning of the array - // + // Make a Bitmap. Get the dimensions from the same rectangle specified + // as the DestRect in the DrawParams. + int w = (int) roundedDestRect.Width; + int h = (int) roundedDestRect.Height; + int stride = (w * 3 /* components */ + 3 /* padding */) & ~3; - GCHandle arrayHandle = GCHandle.Alloc(rawBytes, GCHandleType.Pinned); - try + using (Bitmap bitmap = new Bitmap(w, h, PixelFormat.Format24bppRgb)) { - IntPtr p = Marshal.UnsafeAddrOfPinnedArrayElement(rawBytes, 0); - if (p != null) - { // Make a Bitmap... - int w = (int)width; - int h = (int)height; - int stride = (w * 3 /* components */ + 3 /* padding */) & ~3; - - using (Bitmap bitmap = new Bitmap(w, h, stride, PixelFormat.Format24bppRgb, p)) - { - bitmap.Save("DrawToByteArray.png", ImageFormat.Png); - } - } - } - finally - { // Must unpin the byte array or it'll hang around forever - arrayHandle.Free(); + Rectangle rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height); + var bitmapData = + bitmap.LockBits(rect, System.Drawing.Imaging.ImageLockMode.WriteOnly, + bitmap.PixelFormat); + Debug.Assert(stride == bitmapData.Stride); + Marshal.Copy(rawBytes, 0, bitmapData.Scan0, rawBytes.Length); + bitmap.UnlockBits(bitmapData); + bitmap.Save("DrawToByteArray.png", ImageFormat.Png); } } diff --git a/DotNET/Sample_Source/Printing/PrintPDFGUI/PrintPDFForm.Designer.cs b/DotNET/Sample_Source/Printing/PrintPDFGUI/PrintPDFForm.Designer.cs index 854717dd..4cc37206 100644 --- a/DotNET/Sample_Source/Printing/PrintPDFGUI/PrintPDFForm.Designer.cs +++ b/DotNET/Sample_Source/Printing/PrintPDFGUI/PrintPDFForm.Designer.cs @@ -44,6 +44,7 @@ private void InitializeComponent() this.label1 = new System.Windows.Forms.Label(); this.textBox1 = new System.Windows.Forms.TextBox(); this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); this.SuspendLayout(); // // label1 @@ -59,13 +60,14 @@ private void InitializeComponent() // this.textBox1.Location = new System.Drawing.Point(15, 25); this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(598, 20); + this.textBox1.ReadOnly = true; + this.textBox1.Size = new System.Drawing.Size(523, 20); this.textBox1.TabIndex = 1; - this.textBox1.Text = @""; // // button1 // - this.button1.Location = new System.Drawing.Point(538, 62); + this.button1.Enabled = false; + this.button1.Location = new System.Drawing.Point(544, 66); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 2; @@ -73,11 +75,22 @@ private void InitializeComponent() this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // + // button2 + // + this.button2.Location = new System.Drawing.Point(544, 25); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(50, 20); + this.button2.TabIndex = 3; + this.button2.Text = "Browse"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // // PrintPDFForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(627, 101); + this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Controls.Add(this.textBox1); this.Controls.Add(this.label1); @@ -93,6 +106,7 @@ private void InitializeComponent() private System.Windows.Forms.Label label1; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.Button button1; + private Button button2; } } diff --git a/DotNET/Sample_Source/Printing/PrintPDFGUI/PrintPDFForm.cs b/DotNET/Sample_Source/Printing/PrintPDFGUI/PrintPDFForm.cs index d24adac0..108ded01 100644 --- a/DotNET/Sample_Source/Printing/PrintPDFGUI/PrintPDFForm.cs +++ b/DotNET/Sample_Source/Printing/PrintPDFGUI/PrintPDFForm.cs @@ -1,107 +1,25 @@ using System; -using System.IO; -using System.Threading; +using System.Windows.Forms; +using Datalogics.PDFL; /* - * A sample which demonstrates the use of the DLE API to print a - * PDF file to a windows printer output device. - * - * Copyright 2015, Datalogics, Inc. All rights reserved. + * This sample printing a PDF file. It is similar to PrintPDF, but this + * program provides a user interface. * - * The information and code in this sample is for the exclusive use of Datalogics - * customers and evaluation users only. Datalogics permits you to use, modify and - * distribute this file in accordance with the terms of your license agreement. - * Sample code is for demonstrative purposes only and is not intended for production use. + * For more detail see the description of the PrintPDFGUI sample program on our Developer’s site, + * http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/net-sample-programs/printing-pdf-files-and-generating-postscript-ps-files-from-pdf + * + * Copyright (c) 2007-2018, Datalogics, Inc. All rights reserved. + * + * For complete copyright information, refer to: + * http://dev.datalogics.com/adobe-pdf-library/license-for-downloaded-pdf-samples/ * */ namespace PrintPDFGUI { - public class SimpleDelegate - { - #region ProgressForm - private PrintProgressForm mProgressForm; - public PrintProgressForm ProgressForm - { // Reference to the Progress window (form)... - set - { - this.mProgressForm = value; - } - private get - { - return this.mProgressForm; - } - } - #endregion - - #region PDFInfo - private FileInfo mPDFInfo; - public FileInfo PDFInfo - { // Storage for the PDF's FileInfo block... - set - { - this.mPDFInfo = value; - } - get - { - return this.mPDFInfo; - } - } - #endregion - - public void Work() - { // The threaded work... - PrintPDF.PrintOnePDF(PDFInfo, ProgressForm.CancelHandler, ProgressForm.ProgressHandler); - } - }; - public partial class PrintPDFForm : System.Windows.Forms.Form { - #region PrintThread - private Thread mPrintThread; - private Thread PrintThread - { // Reference to the print thread... - set - { - this.mPrintThread = value; - } - get - { - return this.mPrintThread; - } - } - #endregion - - #region ProgressForm - private PrintProgressForm mProgressForm; - private PrintProgressForm ProgressForm - { // Reference to the Progress window (form)... - set - { - this.mProgressForm = value; - } - get - { - return this.mProgressForm; - } - } - #endregion - - #region PDFInfo - private FileInfo mPDFInfo; - private FileInfo PDFInfo - { // Storage for the PDF's FileInfo block... - set - { - this.mPDFInfo = value; - } - get - { - return this.mPDFInfo; - } - } - #endregion - public PrintPDFForm() { InitializeComponent(); @@ -109,72 +27,48 @@ public PrintPDFForm() private void button1_Click(object sender, EventArgs e) { - string filename = textBox1.Text.ToString(); - if (filename.Length < 1) - { // Invalid entry... - this.Close(); - return; - } - - PDFInfo = new FileInfo(filename.Trim('"')); - if (!PDFInfo.Exists) - { // Invalid entry... - this.Close(); - return; - } - - if (PrintThread != null && PrintThread.IsAlive) + try { - // - // Simultaneous print cycles are not supported by this sample (or DLE/APDFL). - // - // If one wants something like that, they'll need to capture the humans - // desires in a List and serialize the act of printing - // N-many times into a larger, linear (one after the other) design. - // - - return; + using (Library lib = new Library()) + { + using (Document doc = new Document(textBox1.Text)) + { + using (PrintUserParams userParams = new PrintUserParams()) + { + userParams.NCopies = 1; + + if (userParams.PosePrintDialog(doc)) + { + userParams.PrintParams.ShrinkToFit = true; + userParams.ShrinkToFit = userParams.PrintParams.ShrinkToFit; + userParams.PaperHeight = PrintUserParams.UseMediaBox; + userParams.PaperWidth = PrintUserParams.UseMediaBox; + + // If you un-comment the file path (binding) below, DLE will print via the platform print driver to disk. + // The type of file produced when doing so (e.g., PS, PCL, PCLXL) depends upon the type of printer/driver. + //userParams.OutFileName = String.Format("{0}\\{1}.prn", finfo.Directory.FullName, System.IO.Path.GetFileNameWithoutExtension(finfo.FullName)); + + doc.Print(userParams, null, null); + } + } + } + } } - - // - // One cannot print and update UI on a common thread. To present - // a GUI one MUST construct a multi-threaded application (like that - // shown here). Along with that come requirements for cross-thread - // information sharing. Consequently, one must know how to use - // (older) BeginInvoke delegation (as shown here) and/or .Net Task - // functionality as well as become well versed in how to deal with - // exceptions and memory management under such conditions. Memory - // management does not "just happen for for free" (even in a GCed - // environment). - // - - // - // WARNING: An application like this (that invokes DLE/APDFL on - // child threads MUST have a base "using(Library lib = new Library)" - // on the primary (application) thread. This requirement is not optional - // and must be provided or the application may (likely will) crash when - // one least expects! For more on why, please go find/read the commentary - // near the base Library invocation in PrintPDFGUI.cs - // - - ProgressForm = new PrintProgressForm(); - - SimpleDelegate d = new SimpleDelegate(); - d.ProgressForm = ProgressForm; - d.PDFInfo = PDFInfo; - - PrintThread = new Thread(new ThreadStart(d.Work)); - PrintThread.Start(); - - while (ProgressForm.ProgressHandler.PrintingStarted == false) - { // Wait for printing to start - Thread.Sleep(0); + catch (Exception ex) + { + Console.WriteLine("Exception when printing...{0}{1}", Environment.NewLine, ex.Message); } + } - if (ProgressForm.ProgressHandler.PrintingStarted) - { // The human didn't cancel (when they could have) at the print dialog... - // So, we're just about ready to (actually) begin printing... - ProgressForm.Show(); + private void button2_Click(object sender, EventArgs e) + { + using (OpenFileDialog dialog = new OpenFileDialog()) + { + if (dialog.ShowDialog() == DialogResult.OK) + { + textBox1.Text = dialog.FileName; + button1.Enabled = true; + } } } } diff --git a/DotNET/Sample_Source/Printing/PrintPDFGUI/PrintPDFGUI.cs b/DotNET/Sample_Source/Printing/PrintPDFGUI/PrintPDFGUI.cs index 7458dd44..e5003d72 100644 --- a/DotNET/Sample_Source/Printing/PrintPDFGUI/PrintPDFGUI.cs +++ b/DotNET/Sample_Source/Printing/PrintPDFGUI/PrintPDFGUI.cs @@ -10,7 +10,7 @@ * For more detail see the description of the PrintPDFGUI sample program on our Developer’s site, * http://dev.datalogics.com/adobe-pdf-library/sample-program-descriptions/net-sample-programs/printing-pdf-files-and-generating-postscript-ps-files-from-pdf * - * Copyright (c) 2007-2017, Datalogics, Inc. All rights reserved. + * Copyright (c) 2007-2018, Datalogics, Inc. All rights reserved. * * For complete copyright information, refer to: * http://dev.datalogics.com/adobe-pdf-library/license-for-downloaded-pdf-samples/ @@ -27,26 +27,9 @@ static class PrintPDFGUI [STAThread] static void Main() { - using (Library lib = new Library()) - { - // - // This outer-most library instance is CRITICAL for an application - // (like this) that has other uses of (other instances of) the - // Library running on separate threads! It may appear to be - // redundant and not necessary to a developer new to DLE/PDFL. - // But if this instance is removed an application like this may - // actually crash, exhibit memory corruption or leakage after - // another thread ends. - // - // For more information on this topic consult: - // - // https://wiki.datalogics.com/pages/viewpage.action?title=Best+Practices+for+Highly+Reliable+DLE+Systems&spaceKey=EN - // - - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new PrintPDFForm()); - } + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new PrintPDFForm()); } } } diff --git a/DotNET/Sample_Source/Samples_32Bit.sln b/DotNET/Sample_Source/Samples_32Bit.sln deleted file mode 100644 index d396d751..00000000 --- a/DotNET/Sample_Source/Samples_32Bit.sln +++ /dev/null @@ -1,444 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.40629.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnnotationCopyPaste", "Annotations\AnnotationCopyPaste\AnnotationCopyPaste.csproj", "{F5F0FD77-A6B6-4918-B7ED-B956331F4516}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Annotations", "Annotations\Annotations\Annotations.csproj", "{E3C437A0-DC43-41FC-89AC-BD345CA22AAE}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlashAnnotCreate", "Annotations\FlashAnnotCreate\FlashAnnotCreate.csproj", "{D066FF9B-9BBF-42AB-8ECC-368AAA7674ED}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InkAnnotations", "Annotations\InkAnnotations\InkAnnotations.csproj", "{17CD026A-89E2-4E0B-82CB-DC85CB02C51E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LinkAnnotation", "Annotations\LinkAnnotation\LinkAnnotation.csproj", "{8B2CE459-4608-44B1-85E0-6DF205F9F002}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PolygonAnnotations", "Annotations\PolygonAnnotations\PolygonAnnotations.csproj", "{55753F1A-B35C-4345-8F16-8260B62C870C}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PolyLineAnnotations", "Annotations\PolyLineAnnotations\PolyLineAnnotations.csproj", "{678DD4F3-1D5D-499E-8CF1-97F1EA44F64A}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddElements", "ContentCreation\AddElements\AddElements.csproj", "{36B7F256-AD9E-4828-9D78-943B052AD0F4}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Clips", "ContentCreation\Clips\Clips.csproj", "{F9E17B0A-769F-413A-A0A0-6EBBD9C2F11D}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreateBookmarks", "ContentCreation\CreateBookmarks\CreateBookmarks.csproj", "{157F72BC-DCD4-496B-A5EE-FC50AADAFA3F}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MakeDocWithCalGrayColorSpace", "ContentCreation\MakeDocWithCalGrayColorSpace\MakeDocWithCalGrayColorSpace.csproj", "{72187BB0-1790-4F1F-8A89-5D2BC8A8A6E5}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MakeDocWithCalRGBColorSpace", "ContentCreation\MakeDocWithCalRGBColorSpace\MakeDocWithCalRGBColorSpace.csproj", "{9B44B30E-26B0-4E91-9B2A-9C9B56BCA768}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MakeDocWithDeviceNColorSpace", "ContentCreation\MakeDocWithDeviceNColorSpace\MakeDocWithDeviceNColorSpace.csproj", "{5DDCD3E2-C232-4742-87B9-ECA560D9F597}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MakeDocWithICCBasedColorSpace", "ContentCreation\MakeDocWithICCBasedColorSpace\MakeDocWithICCBasedColorSpace.csproj", "{DA62157D-BED2-44F9-9B72-D026BBF7B7E0}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MakeDocWithIndexedColorSpace", "ContentCreation\MakeDocWithIndexedColorSpace\MakeDocWithIndexedColorSpace.csproj", "{D7ACD8D9-C90D-4E31-8402-9960FD7E9A41}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MakeDocWithLabColorSpace", "ContentCreation\MakeDocWithLabColorSpace\MakeDocWithLabColorSpace.csproj", "{7D8F2614-BCBD-42EE-916C-CDBFDC239B08}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MakeDocWithSeparationColorSpace", "ContentCreation\MakeDocWithSeparationColorSpace\MakeDocWithSeparationColorSpace.csproj", "{B2296819-DC29-4DC1-84FE-4C349B145195}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NameTrees", "ContentCreation\NameTrees\NameTrees.csproj", "{E96ED8FE-BBA4-4928-A0AF-053D67897167}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NumberTrees", "ContentCreation\NumberTrees\NumberTrees.csproj", "{B86ACE3A-65F7-4794-8542-434CE8003346}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RemoteGoToActions", "ContentCreation\RemoteGoToActions\RemoteGoToActions.csproj", "{9E259727-BEAD-4F52-B969-4AA447A0DBB1}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WriteNChannelTiff", "ContentCreation\WriteNChannelTiff\WriteNChannelTiff.csproj", "{13AFB8B0-8E0E-495C-A675-D9F9601739BB}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Action", "ContentModification\Action\Action.csproj", "{3A7670C4-BE60-4AE8-8E79-8281206BB4DA}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddCollection", "ContentModification\AddCollection\AddCollection.csproj", "{BEC20051-FF71-42FA-B46A-0909ECE10765}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChangeLayerConfiguration", "ContentModification\ChangeLayerConfiguration\ChangeLayerConfiguration.csproj", "{C5493EAE-45F6-4502-9D26-5BFEC574729F}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChangeLinkColors", "ContentModification\ChangeLinkColors\ChangeLinkColors.csproj", "{AB0B44A2-B267-4E5C-BEFA-5405DEDC21B1}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreateLayer", "ContentModification\CreateLayer\CreateLayer.csproj", "{B5E6E0A0-B56C-47B0-B935-DE1A405D3145}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExtendedGraphicStates", "ContentModification\ExtendedGraphicStates\ExtendedGraphicStates.csproj", "{3F4BD32C-B09C-48D6-A8FD-2AE18FB76C4C}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlattenTransparency", "ContentModification\FlattenTransparency\FlattenTransparency.csproj", "{464BB47E-F378-4320-9453-6B036F9F28D0}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LaunchActions", "ContentModification\LaunchActions\LaunchActions.csproj", "{08CA7C3A-0DBE-4482-8A8C-1DB21F8FAD66}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MergePDF", "ContentModification\MergePDF\MergePDF.csproj", "{36B9519E-0B6A-497E-9328-458F6ED54E48}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PageLabels", "ContentModification\PageLabels\PageLabels.csproj", "{A986F254-EB7B-460E-9ED5-2B000CD0D24E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PDFObject", "ContentModification\PDFObject\PDFObject.csproj", "{114BC49A-2BA1-48E2-BA74-28D761C05E7D}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnderlinesAndHighlights", "ContentModification\UnderlinesAndHighlights\UnderlinesAndHighlights.csproj", "{8B2CE459-4608-44B1-85E0-21549A13BF04}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WaterMark", "ContentModification\Watermark\WaterMark.csproj", "{FA83DE47-3771-47EE-8EA8-EB202F5241A0}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DisplayPDF", "Display\DisplayPDF\DisplayPDF.csproj", "{D9B028A3-02EE-4A8F-95B2-68BD3C4F812B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNETViewer", "Display\DotNETViewer\DotNETViewer.csproj", "{8AD1F5CA-98E7-4262-85F0-9A46E8BFCA55}" - ProjectSection(ProjectDependencies) = postProject - {4820C609-0261-4D9D-93AA-A231FA70151D} = {4820C609-0261-4D9D-93AA-A231FA70151D} - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNETViewerComponent", "Display\DotNETViewerComponent\DotNETViewerComponent.csproj", "{4820C609-0261-4D9D-93AA-A231FA70151D}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PDFObjectExplorer", "Display\PDFObjectExplorer\PDFObjectExplorer.csproj", "{B4F2E320-7125-4D31-8AB8-302CC4D82E79}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorConvertDocument", "DocumentConversion\ColorConvertDocument\ColorConvertDocument.csproj", "{D0E85D80-0332-40F2-A9DB-43C02F4544BC}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreateDocFromXPS", "DocumentConversion\CreateDocFromXPS\CreateDocFromXPS.csproj", "{06CC71DB-4C98-4F80-BC4F-AA1CE8785CF3}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PDFAConverter", "DocumentConversion\PDFAConverter\PDFAConverter.csproj", "{6E7363CC-D687-43A0-A6F6-7E408B06446B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PDFXConverter", "DocumentConversion\PDFXConverter\PDFXConverter.csproj", "{AC0B6462-750A-4DF6-BB63-29878969670D}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PDFOptimizerSample", "DocumentOptimization\PDFOptimizerSample\PDFOptimizerSample.csproj", "{2A9B8CE3-2CF0-4FA3-AD73-EB5BA16580C4}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocToImages", "Images\DocToImages\DocToImages.csproj", "{C7E8B4B7-7402-4959-8EC6-28C5BF80F790}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DrawSeparations", "Images\DrawSeparations\DrawSeparations.csproj", "{1653C796-99B6-40C6-947E-3333E8E6B090}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DrawToBitmap", "Images\DrawToBitmap\DrawToBitmap.csproj", "{2CA38708-C14D-47CF-8CA7-C46EF5830B2C}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EPSSeparations", "Images\EPSSeparations\EPSSeparations.csproj", "{D6B23507-1E17-4561-9349-EA3D2018978F}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GetSeparatedImages", "Images\GetSeparatedImages\GetSeparatedImages.csproj", "{16ABC796-99B8-AEC6-947E-3355E8E6B090}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageEmbedICCProfile", "Images\ImageEmbedICCProfile\ImageEmbedICCProfile.csproj", "{820B3EF6-7E0E-4D11-99DE-E28E887F0B2F}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageExport", "Images\ImageExport\ImageExport.csproj", "{381E8A0C-9523-40F6-B0A1-26D7378737D1}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageExtraction", "Images\ImageExtraction\ImageExtraction.csproj", "{8428868D-2886-4A50-AFA8-B2BEB15E94F8}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageFromStream", "Images\ImageFromStream\ImageFromStream.csproj", "{A86FF86A-8589-421D-AC4C-3AB808DD8C5A}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageImport", "Images\ImageImport\ImageImport.csproj", "{4A56E61F-25F5-4C05-AEB0-76570F620CB9}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageResampling", "Images\ImageResampling\ImageResampling.csproj", "{24D3D10F-C380-43F9-8851-F5D2F11E5208}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageSoftMask", "Images\ImageSoftMask\ImageSoftMask.csproj", "{F8D69741-DBD7-4413-B348-F17DF5DC7184}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RasterizePage", "Images\RasterizePage\RasterizePage.csproj", "{A96AB9D0-86A5-4ADF-A222-BC91924BC5FA}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ListBookmarks", "InformationExtraction\ListBookmarks\ListBookmarks.csproj", "{BEF227A8-326C-4CDE-B2FA-41DEA3BC378C}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ListInfo", "InformationExtraction\ListInfo\ListInfo.csproj", "{CCF41E07-BAB6-41A0-8D66-DDFF39EC19B0}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ListLayers", "InformationExtraction\ListLayers\ListLayers.csproj", "{AF683F4F-9A49-48A1-8045-61EC6510E2D3}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ListPaths", "InformationExtraction\ListPaths\ListPaths.csproj", "{A6381316-3211-4D8A-95E1-020289E6CCDB}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Metadata", "InformationExtraction\Metadata\Metadata.csproj", "{9F15FD38-6FE0-4D20-9349-7F0221CE4C53}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MemoryFileSystem", "Other\MemoryFileSystem\MemoryFileSystem.csproj", "{81EFB00E-32B7-48F1-9BFC-D17253D52148}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StreamIO", "Other\StreamIO\StreamIO.csproj", "{38DF6203-BFFF-4C5C-AAA8-ECCE6F08EEE3}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrintPDF", "Printing\PrintPDF\PrintPDF.csproj", "{E71D73AD-6972-409C-860F-AA055B126DB2}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrintPDFGUI", "Printing\PrintPDFGUI\PrintPDFGUI.csproj", "{D0CACF47-7CA9-4E32-8B64-F4A27A1B95C4}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Redactions", "Security\Redactions\Redactions.csproj", "{3790CE63-DB43-4F16-8226-BDFEFA25BCDD}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddGlyphs", "Text\AddGlyphs\AddGlyphs.csproj", "{9920FBEE-6060-4931-8B85-7B7BC90BDEF9}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddUnicodeText", "Text\AddUnicodeText\AddUnicodeText.csproj", "{0DBEE6CB-EF3E-4748-94F5-4C14F59C0314}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddVerticalText", "Text\AddVerticalText\AddVerticalText.csproj", "{C87E9F27-BA3A-4174-8861-D2B47EA1C33A}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ListWords", "Text\ListWords\ListWords.csproj", "{7801882E-1CF5-49C4-A4FE-34ED5F4901E5}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TextExtract", "Text\TextExtract\TextExtract.csproj", "{8868F71F-36E1-4AD2-94D5-ABC8047A9D0B}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F5F0FD77-A6B6-4918-B7ED-B956331F4516}.Debug|x86.ActiveCfg = Debug|x86 - {F5F0FD77-A6B6-4918-B7ED-B956331F4516}.Debug|x86.Build.0 = Debug|x86 - {F5F0FD77-A6B6-4918-B7ED-B956331F4516}.Release|x86.ActiveCfg = Release|x86 - {F5F0FD77-A6B6-4918-B7ED-B956331F4516}.Release|x86.Build.0 = Release|x86 - {E3C437A0-DC43-41FC-89AC-BD345CA22AAE}.Debug|x86.ActiveCfg = Debug|x86 - {E3C437A0-DC43-41FC-89AC-BD345CA22AAE}.Debug|x86.Build.0 = Debug|x86 - {E3C437A0-DC43-41FC-89AC-BD345CA22AAE}.Release|x86.ActiveCfg = Release|x86 - {E3C437A0-DC43-41FC-89AC-BD345CA22AAE}.Release|x86.Build.0 = Release|x86 - {D066FF9B-9BBF-42AB-8ECC-368AAA7674ED}.Debug|x86.ActiveCfg = Debug|x86 - {D066FF9B-9BBF-42AB-8ECC-368AAA7674ED}.Debug|x86.Build.0 = Debug|x86 - {D066FF9B-9BBF-42AB-8ECC-368AAA7674ED}.Release|x86.ActiveCfg = Release|x86 - {D066FF9B-9BBF-42AB-8ECC-368AAA7674ED}.Release|x86.Build.0 = Release|x86 - {17CD026A-89E2-4E0B-82CB-DC85CB02C51E}.Debug|x86.ActiveCfg = Debug|x86 - {17CD026A-89E2-4E0B-82CB-DC85CB02C51E}.Debug|x86.Build.0 = Debug|x86 - {17CD026A-89E2-4E0B-82CB-DC85CB02C51E}.Release|x86.ActiveCfg = Release|x86 - {17CD026A-89E2-4E0B-82CB-DC85CB02C51E}.Release|x86.Build.0 = Release|x86 - {8B2CE459-4608-44B1-85E0-6DF205F9F002}.Debug|x86.ActiveCfg = Debug|x86 - {8B2CE459-4608-44B1-85E0-6DF205F9F002}.Debug|x86.Build.0 = Debug|x86 - {8B2CE459-4608-44B1-85E0-6DF205F9F002}.Release|x86.ActiveCfg = Release|x86 - {8B2CE459-4608-44B1-85E0-6DF205F9F002}.Release|x86.Build.0 = Release|x86 - {55753F1A-B35C-4345-8F16-8260B62C870C}.Debug|x86.ActiveCfg = Debug|x86 - {55753F1A-B35C-4345-8F16-8260B62C870C}.Debug|x86.Build.0 = Debug|x86 - {55753F1A-B35C-4345-8F16-8260B62C870C}.Release|x86.ActiveCfg = Release|x86 - {55753F1A-B35C-4345-8F16-8260B62C870C}.Release|x86.Build.0 = Release|x86 - {678DD4F3-1D5D-499E-8CF1-97F1EA44F64A}.Debug|x86.ActiveCfg = Debug|x86 - {678DD4F3-1D5D-499E-8CF1-97F1EA44F64A}.Debug|x86.Build.0 = Debug|x86 - {678DD4F3-1D5D-499E-8CF1-97F1EA44F64A}.Release|x86.ActiveCfg = Release|x86 - {678DD4F3-1D5D-499E-8CF1-97F1EA44F64A}.Release|x86.Build.0 = Release|x86 - {36B7F256-AD9E-4828-9D78-943B052AD0F4}.Debug|x86.ActiveCfg = Debug|x86 - {36B7F256-AD9E-4828-9D78-943B052AD0F4}.Debug|x86.Build.0 = Debug|x86 - {36B7F256-AD9E-4828-9D78-943B052AD0F4}.Release|x86.ActiveCfg = Release|x86 - {36B7F256-AD9E-4828-9D78-943B052AD0F4}.Release|x86.Build.0 = Release|x86 - {F9E17B0A-769F-413A-A0A0-6EBBD9C2F11D}.Debug|x86.ActiveCfg = Debug|x86 - {F9E17B0A-769F-413A-A0A0-6EBBD9C2F11D}.Debug|x86.Build.0 = Debug|x86 - {F9E17B0A-769F-413A-A0A0-6EBBD9C2F11D}.Release|x86.ActiveCfg = Release|x86 - {F9E17B0A-769F-413A-A0A0-6EBBD9C2F11D}.Release|x86.Build.0 = Release|x86 - {157F72BC-DCD4-496B-A5EE-FC50AADAFA3F}.Debug|x86.ActiveCfg = Debug|x86 - {157F72BC-DCD4-496B-A5EE-FC50AADAFA3F}.Debug|x86.Build.0 = Debug|x86 - {157F72BC-DCD4-496B-A5EE-FC50AADAFA3F}.Release|x86.ActiveCfg = Release|x86 - {157F72BC-DCD4-496B-A5EE-FC50AADAFA3F}.Release|x86.Build.0 = Release|x86 - {72187BB0-1790-4F1F-8A89-5D2BC8A8A6E5}.Debug|x86.ActiveCfg = Debug|x86 - {72187BB0-1790-4F1F-8A89-5D2BC8A8A6E5}.Debug|x86.Build.0 = Debug|x86 - {72187BB0-1790-4F1F-8A89-5D2BC8A8A6E5}.Release|x86.ActiveCfg = Release|x86 - {72187BB0-1790-4F1F-8A89-5D2BC8A8A6E5}.Release|x86.Build.0 = Release|x86 - {9B44B30E-26B0-4E91-9B2A-9C9B56BCA768}.Debug|x86.ActiveCfg = Debug|x86 - {9B44B30E-26B0-4E91-9B2A-9C9B56BCA768}.Debug|x86.Build.0 = Debug|x86 - {9B44B30E-26B0-4E91-9B2A-9C9B56BCA768}.Release|x86.ActiveCfg = Release|x86 - {9B44B30E-26B0-4E91-9B2A-9C9B56BCA768}.Release|x86.Build.0 = Release|x86 - {5DDCD3E2-C232-4742-87B9-ECA560D9F597}.Debug|x86.ActiveCfg = Debug|x86 - {5DDCD3E2-C232-4742-87B9-ECA560D9F597}.Debug|x86.Build.0 = Debug|x86 - {5DDCD3E2-C232-4742-87B9-ECA560D9F597}.Release|x86.ActiveCfg = Release|x86 - {5DDCD3E2-C232-4742-87B9-ECA560D9F597}.Release|x86.Build.0 = Release|x86 - {DA62157D-BED2-44F9-9B72-D026BBF7B7E0}.Debug|x86.ActiveCfg = Debug|x86 - {DA62157D-BED2-44F9-9B72-D026BBF7B7E0}.Debug|x86.Build.0 = Debug|x86 - {DA62157D-BED2-44F9-9B72-D026BBF7B7E0}.Release|x86.ActiveCfg = Release|x86 - {DA62157D-BED2-44F9-9B72-D026BBF7B7E0}.Release|x86.Build.0 = Release|x86 - {D7ACD8D9-C90D-4E31-8402-9960FD7E9A41}.Debug|x86.ActiveCfg = Debug|x86 - {D7ACD8D9-C90D-4E31-8402-9960FD7E9A41}.Debug|x86.Build.0 = Debug|x86 - {D7ACD8D9-C90D-4E31-8402-9960FD7E9A41}.Release|x86.ActiveCfg = Release|x86 - {D7ACD8D9-C90D-4E31-8402-9960FD7E9A41}.Release|x86.Build.0 = Release|x86 - {7D8F2614-BCBD-42EE-916C-CDBFDC239B08}.Debug|x86.ActiveCfg = Debug|x86 - {7D8F2614-BCBD-42EE-916C-CDBFDC239B08}.Debug|x86.Build.0 = Debug|x86 - {7D8F2614-BCBD-42EE-916C-CDBFDC239B08}.Release|x86.ActiveCfg = Release|x86 - {7D8F2614-BCBD-42EE-916C-CDBFDC239B08}.Release|x86.Build.0 = Release|x86 - {B2296819-DC29-4DC1-84FE-4C349B145195}.Debug|x86.ActiveCfg = Debug|x86 - {B2296819-DC29-4DC1-84FE-4C349B145195}.Debug|x86.Build.0 = Debug|x86 - {B2296819-DC29-4DC1-84FE-4C349B145195}.Release|x86.ActiveCfg = Release|x86 - {B2296819-DC29-4DC1-84FE-4C349B145195}.Release|x86.Build.0 = Release|x86 - {E96ED8FE-BBA4-4928-A0AF-053D67897167}.Debug|x86.ActiveCfg = Debug|x86 - {E96ED8FE-BBA4-4928-A0AF-053D67897167}.Debug|x86.Build.0 = Debug|x86 - {E96ED8FE-BBA4-4928-A0AF-053D67897167}.Release|x86.ActiveCfg = Release|x86 - {E96ED8FE-BBA4-4928-A0AF-053D67897167}.Release|x86.Build.0 = Release|x86 - {B86ACE3A-65F7-4794-8542-434CE8003346}.Debug|x86.ActiveCfg = Debug|x86 - {B86ACE3A-65F7-4794-8542-434CE8003346}.Debug|x86.Build.0 = Debug|x86 - {B86ACE3A-65F7-4794-8542-434CE8003346}.Release|x86.ActiveCfg = Release|x86 - {B86ACE3A-65F7-4794-8542-434CE8003346}.Release|x86.Build.0 = Release|x86 - {9E259727-BEAD-4F52-B969-4AA447A0DBB1}.Debug|x86.ActiveCfg = Debug|x86 - {9E259727-BEAD-4F52-B969-4AA447A0DBB1}.Debug|x86.Build.0 = Debug|x86 - {9E259727-BEAD-4F52-B969-4AA447A0DBB1}.Release|x86.ActiveCfg = Release|x86 - {9E259727-BEAD-4F52-B969-4AA447A0DBB1}.Release|x86.Build.0 = Release|x86 - {13AFB8B0-8E0E-495C-A675-D9F9601739BB}.Debug|x86.ActiveCfg = Debug|x86 - {13AFB8B0-8E0E-495C-A675-D9F9601739BB}.Debug|x86.Build.0 = Debug|x86 - {13AFB8B0-8E0E-495C-A675-D9F9601739BB}.Release|x86.ActiveCfg = Release|x86 - {13AFB8B0-8E0E-495C-A675-D9F9601739BB}.Release|x86.Build.0 = Release|x86 - {3A7670C4-BE60-4AE8-8E79-8281206BB4DA}.Debug|x86.ActiveCfg = Debug|x86 - {3A7670C4-BE60-4AE8-8E79-8281206BB4DA}.Debug|x86.Build.0 = Debug|x86 - {3A7670C4-BE60-4AE8-8E79-8281206BB4DA}.Release|x86.ActiveCfg = Release|x86 - {3A7670C4-BE60-4AE8-8E79-8281206BB4DA}.Release|x86.Build.0 = Release|x86 - {BEC20051-FF71-42FA-B46A-0909ECE10765}.Debug|x86.ActiveCfg = Debug|x86 - {BEC20051-FF71-42FA-B46A-0909ECE10765}.Debug|x86.Build.0 = Debug|x86 - {BEC20051-FF71-42FA-B46A-0909ECE10765}.Release|x86.ActiveCfg = Release|x86 - {BEC20051-FF71-42FA-B46A-0909ECE10765}.Release|x86.Build.0 = Release|x86 - {C5493EAE-45F6-4502-9D26-5BFEC574729F}.Debug|x86.ActiveCfg = Debug|x86 - {C5493EAE-45F6-4502-9D26-5BFEC574729F}.Debug|x86.Build.0 = Debug|x86 - {C5493EAE-45F6-4502-9D26-5BFEC574729F}.Release|x86.ActiveCfg = Release|x86 - {C5493EAE-45F6-4502-9D26-5BFEC574729F}.Release|x86.Build.0 = Release|x86 - {AB0B44A2-B267-4E5C-BEFA-5405DEDC21B1}.Debug|x86.ActiveCfg = Debug|x86 - {AB0B44A2-B267-4E5C-BEFA-5405DEDC21B1}.Debug|x86.Build.0 = Debug|x86 - {AB0B44A2-B267-4E5C-BEFA-5405DEDC21B1}.Release|x86.ActiveCfg = Release|x86 - {AB0B44A2-B267-4E5C-BEFA-5405DEDC21B1}.Release|x86.Build.0 = Release|x86 - {B5E6E0A0-B56C-47B0-B935-DE1A405D3145}.Debug|x86.ActiveCfg = Debug|x86 - {B5E6E0A0-B56C-47B0-B935-DE1A405D3145}.Debug|x86.Build.0 = Debug|x86 - {B5E6E0A0-B56C-47B0-B935-DE1A405D3145}.Release|x86.ActiveCfg = Release|x86 - {B5E6E0A0-B56C-47B0-B935-DE1A405D3145}.Release|x86.Build.0 = Release|x86 - {3F4BD32C-B09C-48D6-A8FD-2AE18FB76C4C}.Debug|x86.ActiveCfg = Debug|x86 - {3F4BD32C-B09C-48D6-A8FD-2AE18FB76C4C}.Debug|x86.Build.0 = Debug|x86 - {3F4BD32C-B09C-48D6-A8FD-2AE18FB76C4C}.Release|x86.ActiveCfg = Release|x86 - {3F4BD32C-B09C-48D6-A8FD-2AE18FB76C4C}.Release|x86.Build.0 = Release|x86 - {464BB47E-F378-4320-9453-6B036F9F28D0}.Debug|x86.ActiveCfg = Debug|x86 - {464BB47E-F378-4320-9453-6B036F9F28D0}.Debug|x86.Build.0 = Debug|x86 - {464BB47E-F378-4320-9453-6B036F9F28D0}.Release|x86.ActiveCfg = Release|x86 - {464BB47E-F378-4320-9453-6B036F9F28D0}.Release|x86.Build.0 = Release|x86 - {08CA7C3A-0DBE-4482-8A8C-1DB21F8FAD66}.Debug|x86.ActiveCfg = Debug|x86 - {08CA7C3A-0DBE-4482-8A8C-1DB21F8FAD66}.Debug|x86.Build.0 = Debug|x86 - {08CA7C3A-0DBE-4482-8A8C-1DB21F8FAD66}.Release|x86.ActiveCfg = Release|x86 - {08CA7C3A-0DBE-4482-8A8C-1DB21F8FAD66}.Release|x86.Build.0 = Release|x86 - {36B9519E-0B6A-497E-9328-458F6ED54E48}.Debug|x86.ActiveCfg = Debug|x86 - {36B9519E-0B6A-497E-9328-458F6ED54E48}.Debug|x86.Build.0 = Debug|x86 - {36B9519E-0B6A-497E-9328-458F6ED54E48}.Release|x86.ActiveCfg = Release|x86 - {36B9519E-0B6A-497E-9328-458F6ED54E48}.Release|x86.Build.0 = Release|x86 - {A986F254-EB7B-460E-9ED5-2B000CD0D24E}.Debug|x86.ActiveCfg = Debug|x86 - {A986F254-EB7B-460E-9ED5-2B000CD0D24E}.Debug|x86.Build.0 = Debug|x86 - {A986F254-EB7B-460E-9ED5-2B000CD0D24E}.Release|x86.ActiveCfg = Release|x86 - {A986F254-EB7B-460E-9ED5-2B000CD0D24E}.Release|x86.Build.0 = Release|x86 - {114BC49A-2BA1-48E2-BA74-28D761C05E7D}.Debug|x86.ActiveCfg = Debug|x86 - {114BC49A-2BA1-48E2-BA74-28D761C05E7D}.Debug|x86.Build.0 = Debug|x86 - {114BC49A-2BA1-48E2-BA74-28D761C05E7D}.Release|x86.ActiveCfg = Release|x86 - {114BC49A-2BA1-48E2-BA74-28D761C05E7D}.Release|x86.Build.0 = Release|x86 - {8B2CE459-4608-44B1-85E0-21549A13BF04}.Debug|x86.ActiveCfg = Debug|x86 - {8B2CE459-4608-44B1-85E0-21549A13BF04}.Debug|x86.Build.0 = Debug|x86 - {8B2CE459-4608-44B1-85E0-21549A13BF04}.Release|x86.ActiveCfg = Release|x86 - {8B2CE459-4608-44B1-85E0-21549A13BF04}.Release|x86.Build.0 = Release|x86 - {FA83DE47-3771-47EE-8EA8-EB202F5241A0}.Debug|x86.ActiveCfg = Debug|x86 - {FA83DE47-3771-47EE-8EA8-EB202F5241A0}.Debug|x86.Build.0 = Debug|x86 - {FA83DE47-3771-47EE-8EA8-EB202F5241A0}.Release|x86.ActiveCfg = Release|x86 - {FA83DE47-3771-47EE-8EA8-EB202F5241A0}.Release|x86.Build.0 = Release|x86 - {D9B028A3-02EE-4A8F-95B2-68BD3C4F812B}.Debug|x86.ActiveCfg = Debug|x86 - {D9B028A3-02EE-4A8F-95B2-68BD3C4F812B}.Debug|x86.Build.0 = Debug|x86 - {D9B028A3-02EE-4A8F-95B2-68BD3C4F812B}.Release|x86.ActiveCfg = Release|x86 - {D9B028A3-02EE-4A8F-95B2-68BD3C4F812B}.Release|x86.Build.0 = Release|x86 - {8AD1F5CA-98E7-4262-85F0-9A46E8BFCA55}.Debug|x86.ActiveCfg = Debug|x86 - {8AD1F5CA-98E7-4262-85F0-9A46E8BFCA55}.Debug|x86.Build.0 = Debug|x86 - {8AD1F5CA-98E7-4262-85F0-9A46E8BFCA55}.Release|x86.ActiveCfg = Release|x86 - {8AD1F5CA-98E7-4262-85F0-9A46E8BFCA55}.Release|x86.Build.0 = Release|x86 - {4820C609-0261-4D9D-93AA-A231FA70151D}.Debug|x86.ActiveCfg = Debug|x86 - {4820C609-0261-4D9D-93AA-A231FA70151D}.Debug|x86.Build.0 = Debug|x86 - {4820C609-0261-4D9D-93AA-A231FA70151D}.Release|x86.ActiveCfg = Release|x86 - {4820C609-0261-4D9D-93AA-A231FA70151D}.Release|x86.Build.0 = Release|x86 - {B4F2E320-7125-4D31-8AB8-302CC4D82E79}.Debug|x86.ActiveCfg = Debug|x86 - {B4F2E320-7125-4D31-8AB8-302CC4D82E79}.Debug|x86.Build.0 = Debug|x86 - {B4F2E320-7125-4D31-8AB8-302CC4D82E79}.Release|x86.ActiveCfg = Release|x86 - {B4F2E320-7125-4D31-8AB8-302CC4D82E79}.Release|x86.Build.0 = Release|x86 - {D0E85D80-0332-40F2-A9DB-43C02F4544BC}.Debug|x86.ActiveCfg = Debug|x86 - {D0E85D80-0332-40F2-A9DB-43C02F4544BC}.Debug|x86.Build.0 = Debug|x86 - {D0E85D80-0332-40F2-A9DB-43C02F4544BC}.Release|x86.ActiveCfg = Release|x86 - {D0E85D80-0332-40F2-A9DB-43C02F4544BC}.Release|x86.Build.0 = Release|x86 - {06CC71DB-4C98-4F80-BC4F-AA1CE8785CF3}.Debug|x86.ActiveCfg = Debug|x86 - {06CC71DB-4C98-4F80-BC4F-AA1CE8785CF3}.Debug|x86.Build.0 = Debug|x86 - {06CC71DB-4C98-4F80-BC4F-AA1CE8785CF3}.Release|x86.ActiveCfg = Release|x86 - {06CC71DB-4C98-4F80-BC4F-AA1CE8785CF3}.Release|x86.Build.0 = Release|x86 - {6E7363CC-D687-43A0-A6F6-7E408B06446B}.Debug|x86.ActiveCfg = Debug|x86 - {6E7363CC-D687-43A0-A6F6-7E408B06446B}.Debug|x86.Build.0 = Debug|x86 - {6E7363CC-D687-43A0-A6F6-7E408B06446B}.Release|x86.ActiveCfg = Release|x86 - {6E7363CC-D687-43A0-A6F6-7E408B06446B}.Release|x86.Build.0 = Release|x86 - {AC0B6462-750A-4DF6-BB63-29878969670D}.Debug|x86.ActiveCfg = Debug|x86 - {AC0B6462-750A-4DF6-BB63-29878969670D}.Debug|x86.Build.0 = Debug|x86 - {AC0B6462-750A-4DF6-BB63-29878969670D}.Release|x86.ActiveCfg = Release|x86 - {AC0B6462-750A-4DF6-BB63-29878969670D}.Release|x86.Build.0 = Release|x86 - {2A9B8CE3-2CF0-4FA3-AD73-EB5BA16580C4}.Debug|x86.ActiveCfg = Debug|x86 - {2A9B8CE3-2CF0-4FA3-AD73-EB5BA16580C4}.Debug|x86.Build.0 = Debug|x86 - {2A9B8CE3-2CF0-4FA3-AD73-EB5BA16580C4}.Release|x86.ActiveCfg = Release|x86 - {2A9B8CE3-2CF0-4FA3-AD73-EB5BA16580C4}.Release|x86.Build.0 = Release|x86 - {C7E8B4B7-7402-4959-8EC6-28C5BF80F790}.Debug|x86.ActiveCfg = Debug|x86 - {C7E8B4B7-7402-4959-8EC6-28C5BF80F790}.Debug|x86.Build.0 = Debug|x86 - {C7E8B4B7-7402-4959-8EC6-28C5BF80F790}.Release|x86.ActiveCfg = Release|x86 - {C7E8B4B7-7402-4959-8EC6-28C5BF80F790}.Release|x86.Build.0 = Release|x86 - {1653C796-99B6-40C6-947E-3333E8E6B090}.Debug|x86.ActiveCfg = Debug|x86 - {1653C796-99B6-40C6-947E-3333E8E6B090}.Debug|x86.Build.0 = Debug|x86 - {1653C796-99B6-40C6-947E-3333E8E6B090}.Release|x86.ActiveCfg = Release|x86 - {1653C796-99B6-40C6-947E-3333E8E6B090}.Release|x86.Build.0 = Release|x86 - {2CA38708-C14D-47CF-8CA7-C46EF5830B2C}.Debug|x86.ActiveCfg = Debug|x86 - {2CA38708-C14D-47CF-8CA7-C46EF5830B2C}.Debug|x86.Build.0 = Debug|x86 - {2CA38708-C14D-47CF-8CA7-C46EF5830B2C}.Release|x86.ActiveCfg = Release|x86 - {2CA38708-C14D-47CF-8CA7-C46EF5830B2C}.Release|x86.Build.0 = Release|x86 - {D6B23507-1E17-4561-9349-EA3D2018978F}.Debug|x86.ActiveCfg = Debug|x86 - {D6B23507-1E17-4561-9349-EA3D2018978F}.Debug|x86.Build.0 = Debug|x86 - {D6B23507-1E17-4561-9349-EA3D2018978F}.Release|x86.ActiveCfg = Release|x86 - {D6B23507-1E17-4561-9349-EA3D2018978F}.Release|x86.Build.0 = Release|x86 - {16ABC796-99B8-AEC6-947E-3355E8E6B090}.Debug|x86.ActiveCfg = Debug|x86 - {16ABC796-99B8-AEC6-947E-3355E8E6B090}.Debug|x86.Build.0 = Debug|x86 - {16ABC796-99B8-AEC6-947E-3355E8E6B090}.Release|x86.ActiveCfg = Release|x86 - {16ABC796-99B8-AEC6-947E-3355E8E6B090}.Release|x86.Build.0 = Release|x86 - {820B3EF6-7E0E-4D11-99DE-E28E887F0B2F}.Debug|x86.ActiveCfg = Debug|x86 - {820B3EF6-7E0E-4D11-99DE-E28E887F0B2F}.Debug|x86.Build.0 = Debug|x86 - {820B3EF6-7E0E-4D11-99DE-E28E887F0B2F}.Release|x86.ActiveCfg = Release|x86 - {820B3EF6-7E0E-4D11-99DE-E28E887F0B2F}.Release|x86.Build.0 = Release|x86 - {381E8A0C-9523-40F6-B0A1-26D7378737D1}.Debug|x86.ActiveCfg = Debug|x86 - {381E8A0C-9523-40F6-B0A1-26D7378737D1}.Debug|x86.Build.0 = Debug|x86 - {381E8A0C-9523-40F6-B0A1-26D7378737D1}.Release|x86.ActiveCfg = Release|x86 - {381E8A0C-9523-40F6-B0A1-26D7378737D1}.Release|x86.Build.0 = Release|x86 - {8428868D-2886-4A50-AFA8-B2BEB15E94F8}.Debug|x86.ActiveCfg = Debug|x86 - {8428868D-2886-4A50-AFA8-B2BEB15E94F8}.Debug|x86.Build.0 = Debug|x86 - {8428868D-2886-4A50-AFA8-B2BEB15E94F8}.Release|x86.ActiveCfg = Release|x86 - {8428868D-2886-4A50-AFA8-B2BEB15E94F8}.Release|x86.Build.0 = Release|x86 - {A86FF86A-8589-421D-AC4C-3AB808DD8C5A}.Debug|x86.ActiveCfg = Debug|x86 - {A86FF86A-8589-421D-AC4C-3AB808DD8C5A}.Debug|x86.Build.0 = Debug|x86 - {A86FF86A-8589-421D-AC4C-3AB808DD8C5A}.Release|x86.ActiveCfg = Release|x86 - {A86FF86A-8589-421D-AC4C-3AB808DD8C5A}.Release|x86.Build.0 = Release|x86 - {4A56E61F-25F5-4C05-AEB0-76570F620CB9}.Debug|x86.ActiveCfg = Debug|x86 - {4A56E61F-25F5-4C05-AEB0-76570F620CB9}.Debug|x86.Build.0 = Debug|x86 - {4A56E61F-25F5-4C05-AEB0-76570F620CB9}.Release|x86.ActiveCfg = Release|x86 - {4A56E61F-25F5-4C05-AEB0-76570F620CB9}.Release|x86.Build.0 = Release|x86 - {24D3D10F-C380-43F9-8851-F5D2F11E5208}.Debug|x86.ActiveCfg = Debug|x86 - {24D3D10F-C380-43F9-8851-F5D2F11E5208}.Debug|x86.Build.0 = Debug|x86 - {24D3D10F-C380-43F9-8851-F5D2F11E5208}.Release|x86.ActiveCfg = Release|x86 - {24D3D10F-C380-43F9-8851-F5D2F11E5208}.Release|x86.Build.0 = Release|x86 - {F8D69741-DBD7-4413-B348-F17DF5DC7184}.Debug|x86.ActiveCfg = Debug|x86 - {F8D69741-DBD7-4413-B348-F17DF5DC7184}.Debug|x86.Build.0 = Debug|x86 - {F8D69741-DBD7-4413-B348-F17DF5DC7184}.Release|x86.ActiveCfg = Release|x86 - {F8D69741-DBD7-4413-B348-F17DF5DC7184}.Release|x86.Build.0 = Release|x86 - {A96AB9D0-86A5-4ADF-A222-BC91924BC5FA}.Debug|x86.ActiveCfg = Debug|x86 - {A96AB9D0-86A5-4ADF-A222-BC91924BC5FA}.Debug|x86.Build.0 = Debug|x86 - {A96AB9D0-86A5-4ADF-A222-BC91924BC5FA}.Release|x86.ActiveCfg = Release|x86 - {A96AB9D0-86A5-4ADF-A222-BC91924BC5FA}.Release|x86.Build.0 = Release|x86 - {BEF227A8-326C-4CDE-B2FA-41DEA3BC378C}.Debug|x86.ActiveCfg = Debug|x86 - {BEF227A8-326C-4CDE-B2FA-41DEA3BC378C}.Debug|x86.Build.0 = Debug|x86 - {BEF227A8-326C-4CDE-B2FA-41DEA3BC378C}.Release|x86.ActiveCfg = Release|x86 - {BEF227A8-326C-4CDE-B2FA-41DEA3BC378C}.Release|x86.Build.0 = Release|x86 - {CCF41E07-BAB6-41A0-8D66-DDFF39EC19B0}.Debug|x86.ActiveCfg = Debug|x86 - {CCF41E07-BAB6-41A0-8D66-DDFF39EC19B0}.Debug|x86.Build.0 = Debug|x86 - {CCF41E07-BAB6-41A0-8D66-DDFF39EC19B0}.Release|x86.ActiveCfg = Release|x86 - {CCF41E07-BAB6-41A0-8D66-DDFF39EC19B0}.Release|x86.Build.0 = Release|x86 - {AF683F4F-9A49-48A1-8045-61EC6510E2D3}.Debug|x86.ActiveCfg = Debug|x86 - {AF683F4F-9A49-48A1-8045-61EC6510E2D3}.Debug|x86.Build.0 = Debug|x86 - {AF683F4F-9A49-48A1-8045-61EC6510E2D3}.Release|x86.ActiveCfg = Release|x86 - {AF683F4F-9A49-48A1-8045-61EC6510E2D3}.Release|x86.Build.0 = Release|x86 - {A6381316-3211-4D8A-95E1-020289E6CCDB}.Debug|x86.ActiveCfg = Debug|x86 - {A6381316-3211-4D8A-95E1-020289E6CCDB}.Debug|x86.Build.0 = Debug|x86 - {A6381316-3211-4D8A-95E1-020289E6CCDB}.Release|x86.ActiveCfg = Release|x86 - {A6381316-3211-4D8A-95E1-020289E6CCDB}.Release|x86.Build.0 = Release|x86 - {9F15FD38-6FE0-4D20-9349-7F0221CE4C53}.Debug|x86.ActiveCfg = Debug|x86 - {9F15FD38-6FE0-4D20-9349-7F0221CE4C53}.Debug|x86.Build.0 = Debug|x86 - {9F15FD38-6FE0-4D20-9349-7F0221CE4C53}.Release|x86.ActiveCfg = Release|x86 - {9F15FD38-6FE0-4D20-9349-7F0221CE4C53}.Release|x86.Build.0 = Release|x86 - {81EFB00E-32B7-48F1-9BFC-D17253D52148}.Debug|x86.ActiveCfg = Debug|x86 - {81EFB00E-32B7-48F1-9BFC-D17253D52148}.Debug|x86.Build.0 = Debug|x86 - {81EFB00E-32B7-48F1-9BFC-D17253D52148}.Release|x86.ActiveCfg = Release|x86 - {81EFB00E-32B7-48F1-9BFC-D17253D52148}.Release|x86.Build.0 = Release|x86 - {38DF6203-BFFF-4C5C-AAA8-ECCE6F08EEE3}.Debug|x86.ActiveCfg = Debug|x86 - {38DF6203-BFFF-4C5C-AAA8-ECCE6F08EEE3}.Debug|x86.Build.0 = Debug|x86 - {38DF6203-BFFF-4C5C-AAA8-ECCE6F08EEE3}.Release|x86.ActiveCfg = Release|x86 - {38DF6203-BFFF-4C5C-AAA8-ECCE6F08EEE3}.Release|x86.Build.0 = Release|x86 - {E71D73AD-6972-409C-860F-AA055B126DB2}.Debug|x86.ActiveCfg = Debug|x86 - {E71D73AD-6972-409C-860F-AA055B126DB2}.Debug|x86.Build.0 = Debug|x86 - {E71D73AD-6972-409C-860F-AA055B126DB2}.Release|x86.ActiveCfg = Release|x86 - {E71D73AD-6972-409C-860F-AA055B126DB2}.Release|x86.Build.0 = Release|x86 - {D0CACF47-7CA9-4E32-8B64-F4A27A1B95C4}.Debug|x86.ActiveCfg = Debug|x86 - {D0CACF47-7CA9-4E32-8B64-F4A27A1B95C4}.Debug|x86.Build.0 = Debug|x86 - {D0CACF47-7CA9-4E32-8B64-F4A27A1B95C4}.Release|x86.ActiveCfg = Release|x86 - {D0CACF47-7CA9-4E32-8B64-F4A27A1B95C4}.Release|x86.Build.0 = Release|x86 - {3790CE63-DB43-4F16-8226-BDFEFA25BCDD}.Debug|x86.ActiveCfg = Debug|x86 - {3790CE63-DB43-4F16-8226-BDFEFA25BCDD}.Debug|x86.Build.0 = Debug|x86 - {3790CE63-DB43-4F16-8226-BDFEFA25BCDD}.Release|x86.ActiveCfg = Release|x86 - {3790CE63-DB43-4F16-8226-BDFEFA25BCDD}.Release|x86.Build.0 = Release|x86 - {9920FBEE-6060-4931-8B85-7B7BC90BDEF9}.Debug|x86.ActiveCfg = Debug|x86 - {9920FBEE-6060-4931-8B85-7B7BC90BDEF9}.Debug|x86.Build.0 = Debug|x86 - {9920FBEE-6060-4931-8B85-7B7BC90BDEF9}.Release|x86.ActiveCfg = Release|x86 - {9920FBEE-6060-4931-8B85-7B7BC90BDEF9}.Release|x86.Build.0 = Release|x86 - {0DBEE6CB-EF3E-4748-94F5-4C14F59C0314}.Debug|x86.ActiveCfg = Debug|x86 - {0DBEE6CB-EF3E-4748-94F5-4C14F59C0314}.Debug|x86.Build.0 = Debug|x86 - {0DBEE6CB-EF3E-4748-94F5-4C14F59C0314}.Release|x86.ActiveCfg = Release|x86 - {0DBEE6CB-EF3E-4748-94F5-4C14F59C0314}.Release|x86.Build.0 = Release|x86 - {C87E9F27-BA3A-4174-8861-D2B47EA1C33A}.Debug|x86.ActiveCfg = Debug|x86 - {C87E9F27-BA3A-4174-8861-D2B47EA1C33A}.Debug|x86.Build.0 = Debug|x86 - {C87E9F27-BA3A-4174-8861-D2B47EA1C33A}.Release|x86.ActiveCfg = Release|x86 - {C87E9F27-BA3A-4174-8861-D2B47EA1C33A}.Release|x86.Build.0 = Release|x86 - {7801882E-1CF5-49C4-A4FE-34ED5F4901E5}.Debug|x86.ActiveCfg = Debug|x86 - {7801882E-1CF5-49C4-A4FE-34ED5F4901E5}.Debug|x86.Build.0 = Debug|x86 - {7801882E-1CF5-49C4-A4FE-34ED5F4901E5}.Release|x86.ActiveCfg = Release|x86 - {7801882E-1CF5-49C4-A4FE-34ED5F4901E5}.Release|x86.Build.0 = Release|x86 - {8868F71F-36E1-4AD2-94D5-ABC8047A9D0B}.Debug|x86.ActiveCfg = Debug|x86 - {8868F71F-36E1-4AD2-94D5-ABC8047A9D0B}.Debug|x86.Build.0 = Debug|x86 - {8868F71F-36E1-4AD2-94D5-ABC8047A9D0B}.Release|x86.ActiveCfg = Release|x86 - {8868F71F-36E1-4AD2-94D5-ABC8047A9D0B}.Release|x86.Build.0 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/DotNET/Sample_Source/Text/AddGlyphs/AddGlyphs.cs b/DotNET/Sample_Source/Text/AddGlyphs/AddGlyphs.cs index 776ff127..2e4b3e2b 100644 --- a/DotNET/Sample_Source/Text/AddGlyphs/AddGlyphs.cs +++ b/DotNET/Sample_Source/Text/AddGlyphs/AddGlyphs.cs @@ -42,7 +42,7 @@ static void Main(string[] args) Page docpage = doc.CreatePage(Document.BeforeFirstPage, pageRect); Console.WriteLine("Created page."); - Font font = new Font("Arial"); + Font font = new Font("Times-Roman"); List glyphIDs = new List(); glyphIDs.Add('\u002b'); diff --git a/DotNET/Sample_Source/Text/TextExtract/TextExtract.cs b/DotNET/Sample_Source/Text/TextExtract/TextExtract.cs index 60a2f6b3..00731d07 100644 --- a/DotNET/Sample_Source/Text/TextExtract/TextExtract.cs +++ b/DotNET/Sample_Source/Text/TextExtract/TextExtract.cs @@ -121,7 +121,8 @@ static void ExtractTextUntagged(Document doc, WordFinder wordFinder) // // For the purposes of this sample, we'll remove all hyphens. In practice, you may need to check // words against a dictionary to determine if the hyphenated word is actually one word or two. - string[] splitstrs = s.Split(new Char[] {'-', '\u00ad'}); + // Note we remove ascii hyphen, Unicode soft hyphen(\u00ad) and Unicode hyphen(0x2010). + string[] splitstrs = s.Split(new char[] {'-', '\u00ad', '\x2010'}); textToExtract += splitstrs[0] + splitstrs[1]; } else @@ -176,8 +177,8 @@ static void ExtractTextTagged(Document doc, WordFinder wordFinder) if (((wInfo.Attributes & WordAttributeFlags.HasSoftHyphen) == WordAttributeFlags.HasSoftHyphen)) { // Remove the hyphen and combine the two parts of the word before adding to the extracted text. - // Note that we pass in the Unicode character for soft hyphen. - string[] splitstrs = s.Split(new Char[] { '\u00ad' }); + // Note that we pass in the Unicode character for soft hyphen(\u00ad) and hyphen(0x2010). + string[] splitstrs = s.Split(new char[] { '\u00ad', '\x2010' }); textToExtract += splitstrs[0] + splitstrs[1]; } else diff --git a/DotNETCore/Sample_Source/ContentModification/UnderlinesAndHighlights/UnderlinesAndHighlights.cs b/DotNETCore/Sample_Source/ContentModification/UnderlinesAndHighlights/UnderlinesAndHighlights.cs index aa0a7e4d..e02c564f 100644 --- a/DotNETCore/Sample_Source/ContentModification/UnderlinesAndHighlights/UnderlinesAndHighlights.cs +++ b/DotNETCore/Sample_Source/ContentModification/UnderlinesAndHighlights/UnderlinesAndHighlights.cs @@ -47,7 +47,7 @@ static void Main(string[] args) // Highlight occurrences of the word "cloudy" on the page. // Underline occurrences of the word "rain" on the page. // - // For a more in-depth example of using the WordFinder, see the TextExtraction sample. + // For a more in-depth example of using the WordFinder, see the TextExtract sample. // List cloudyQuads = new List(); List rainQuads = new List(); diff --git a/DotNETCore/Sample_Source/Display/DisplayPDF/PasswordForm.Designer.cs b/DotNETCore/Sample_Source/Display/DisplayPDF/PasswordForm.Designer.cs index eff20c62..eada77e3 100644 --- a/DotNETCore/Sample_Source/Display/DisplayPDF/PasswordForm.Designer.cs +++ b/DotNETCore/Sample_Source/Display/DisplayPDF/PasswordForm.Designer.cs @@ -103,8 +103,8 @@ private void InitializeComponent() #endregion private Button OkButton; - private Button CancelButton; + private new Button CancelButton; private TextBox passwordtext; private Label PasswordLabel; } -} \ No newline at end of file +} diff --git a/DotNETCore/Sample_Source/Text/TextExtract/TextExtract.cs b/DotNETCore/Sample_Source/Text/TextExtract/TextExtract.cs index af37aed4..ea0aaeae 100644 --- a/DotNETCore/Sample_Source/Text/TextExtract/TextExtract.cs +++ b/DotNETCore/Sample_Source/Text/TextExtract/TextExtract.cs @@ -120,7 +120,8 @@ static void ExtractTextUntagged(Document doc, WordFinder wordFinder) // // For the purposes of this sample, we'll remove all hyphens. In practice, you may need to check // words against a dictionary to determine if the hyphenated word is actually one word or two. - string[] splitstrs = s.Split(new[] {'-', '\u00ad'}); + // Note we remove ascii hyphen, Unicode soft hyphen(\u00ad) and Unicode hyphen(0x2010). + string[] splitstrs = s.Split(new[] {'-', '\u00ad', '\x2010'}); textToExtract += splitstrs[0] + splitstrs[1]; } else @@ -177,8 +178,8 @@ static void ExtractTextTagged(Document doc, WordFinder wordFinder) if (((wInfo.Attributes & WordAttributeFlags.HasSoftHyphen) == WordAttributeFlags.HasSoftHyphen)) { // Remove the hyphen and combine the two parts of the word before adding to the extracted text. - // Note that we pass in the Unicode character for soft hyphen. - string[] splitstrs = s.Split(new[] {'\u00ad'}); + // Note that we pass in the Unicode character for soft hyphen(\u00ad) and hyphen(0x2010). + string[] splitstrs = s.Split(new[] {'\u00ad','\x2010'}); textToExtract += splitstrs[0] + splitstrs[1]; } else