summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfedit_embeddertest.cpp
AgeCommit message (Collapse)Author
2017-08-16API and test for retrieving metadata from image objectsJane Liu
Added FPDFImageObj_GetImageMetadata() for retriving the image metadata of image objects, including its dimension, DPI, bits per pixel, and colorspace. * Added a corresponding embedder test. Bug=pdfium:677 Change-Id: I4229334d1ac2125b21a46e2e44ea937ea2e94b51 Reviewed-on: https://pdfium-review.googlesource.com/10110 Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Jane Liu <janeliulwq@google.com>
2017-08-09API and test for retrieving image filters from image objectsJane Liu
Added FPDFImageObj_GetImageFilterCount() and FPDFImageObj_GetImageFilters() for retrieving image filters of image objects. * Added a corresponding embedder test. * Changed the filter of an image object in embedded_image.pdf from DCTDecode to ASCIIHexDecode + DCTDecode, so we have a test case for images with more than one filter. Bug=pdfium:677 Change-Id: I398790a2cad33fea4ca16a0eb0889c04caa6b962 Reviewed-on: https://pdfium-review.googlesource.com/10130 Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Jane Liu <janeliulwq@google.com>
2017-08-08Added FPDFPageObj_Destroy() for freeing page objects createdJane Liu
Bug=pdfium:854 Change-Id: I227418cdcb77e0aa7d48338f1ee0d753cef6bfdb Reviewed-on: https://pdfium-review.googlesource.com/10390 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Jane Liu <janeliulwq@google.com>
2017-08-03APIs and tests for retrieving raw/decoded data from image objectsJane Liu
Added FPDFImageObj_GetImageDataDecoded() for retrieving the uncompressed data of an image, and FPDFImageObj_GetImageDataRaw() for retrieving the raw data of an image. * Refactored out DecodeStreamMaybeCopyAndReturnLength(), which is used to decode both attachment data and image data. * Within DecodeStreamMaybeCopyAndReturnLength(), used a different decoder function which takes care of multiple filters if exist. As a result, CPDF_StreamParser::DecodeInlineStream() which was made static previously is now moved back into namespace. Bug=pdfium:677 Change-Id: I22a22c99acaca98ef8c15f88911f2646a2c854d5 Reviewed-on: https://pdfium-review.googlesource.com/9811 Commit-Queue: Jane Liu <janeliulwq@google.com> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-08-03APIs and tests for extracting bitmaps from image objectsJane Liu
Added FPDFImageObj_GetBitmap() that returns the bitmap of an image object, and a FPDFBitmap_GetFormat() that returns the format of a bitmap. * Fixed a small bitmap conversion bug in cfx_dibsource.cpp. * Enabled EmbedderTest::CompareBitmap() to support different formats of bitmaps. * Added an embedder test and a test PDF file with images of many different formats. Bug=pdfium:677 Change-Id: I6a72f9d969cf5f3577db9400ca33197c213622ed Reviewed-on: https://pdfium-review.googlesource.com/9690 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Jane Liu <janeliulwq@google.com>
2017-07-10Roll FreeType to c56d8851ea987023cc73981a70d261b3f6427545chromium/3156chromium/3155chromium/3154Nicolas Pena
Bug: chromium:738919 Change-Id: I2ea99a47f45e2e68650bd1fa9ad7554d8df79874 Reviewed-on: https://pdfium-review.googlesource.com/7351 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-07-05Allow EmbedderTest to test savingNicolas Pena
This CL adds helper methods for EmbedderTest to save. This means that TestSaver is no longer needed and all the methods it uses are moved to the EmbedderTest. Change-Id: I740f29699bfd8c6b570cb1fd85e7aab9bc1d3f6f Reviewed-on: https://pdfium-review.googlesource.com/7171 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-06-29Add TestSaved helper method in FPDFEditEmbeddertestNicolas Pena
The saving testing is used in multiple methods. This CL adds a helper to reduce duplicated code. Change-Id: I5a36d41b5fc03a63092eaf642c3461695b5b9805 Reviewed-on: https://pdfium-review.googlesource.com/7091 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-06-28Set default graphics before generating page contentsNicolas Pena
In this CL, the content generator sets some default graphics states before processing the page objects. In particular, a default ExtGState is now set before processing, and the last CTM is now stored right after parsing finishes: the only command to change matrix is ctm, and it concatenates, so inverting requires knowing the current value. Bug: pdfium:779 Change-Id: I35b1c07550ce91839fb0e20fbf717e3e80c9b9d6 Reviewed-on: https://pdfium-review.googlesource.com/7070 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-06-27Changed the return type for annotation APIsJane Liu
Before: When returning FPDF_ANNOTATION, the APIs would take in a FPDF_ANNTOATION* and write the handle of the annotation to it, while returning a boolean as status. This CL: This CL changes the APIs to directly return FPDF_ANNOTATION, which would be null on failure. Also adds more null checks within the annotation APIs. Bug=pdfium:737 Change-Id: I4f77dd1b16d43eab3f16c303598b76591da0dcab Reviewed-on: https://pdfium-review.googlesource.com/6952 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Jane Liu <janeliulwq@google.com>
2017-06-20Wrapper class for annotation dictionary + CPDF_Formchromium/3137Jane Liu
Simple wrapper class for annotation + its path parsing form object. This will be used in APIs for extracting and setting annotation paths. Bug=pdfium:737 Change-Id: I2e8131672d087613213735295c6d01e377b956e7 Reviewed-on: https://pdfium-review.googlesource.com/6730 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-06-14Fix crash when inserting empty pathNicolas Pena
The path creation method begins with an open MoveTo point. If nothing else is added, CFX_PathData::GetBoundingBox will try an OOB access in its m_Points. This CL adds a check similar to the one in CPDF_StreamContentParser::AddPathObject. Change-Id: Iec7cfe3379253c021ba7d5f276306a66009f84e2 Reviewed-on: https://pdfium-review.googlesource.com/6593 Commit-Queue: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-06-14Add blend to GraphicsDataNicolas Pena
CL [1] added the ability to set the blend mode for a page object. This CL adds the corresponding component to GraphicsData since the blend mode is part of ExtGSState. In addition, a test using the SetBlendMode method is added. [1] https://pdfium-review.googlesource.com/c/5953/ Bug: pdfium:720 Change-Id: I49120284345185c200a45cc3b37ec59f0658e2dc Reviewed-on: https://pdfium-review.googlesource.com/6510 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-06-07Fixing FPDFPage_TransformAnnotsJane Liu
Came across this error in FPDFPage_TransformAnnots, where SetNewAt() would fail on a bound assertion when a newly created array calls it. This CL contains a fix in the function and adds an embedder test for this. Bug=pdfium:745 Change-Id: I569f225598d956d270ef8f11ee3225acf48aadc7 Reviewed-on: https://pdfium-review.googlesource.com/6353 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Jane Liu <janeliulwq@google.com>
2017-06-07Fix EmptyCreation testNicolas Pena
The Contents stream of a page is optional per PDF spec 1.7 Table 3.27. This CL fixes the empty creation test to acknowledge that. Change-Id: I1e59a1fedbf00eafabe87962830d62d8883a5e1f Reviewed-on: https://pdfium-review.googlesource.com/6311 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-06-01Fix content generation to only generate dirty page objects.wileyrya
BUG=pdfium:717 R=dsinclair@chromium.org,thestig@chromium.org Change-Id: I7e0e6fd301d40f9b5341d40cf11167b7748af243 Reviewed-on: https://pdfium-review.googlesource.com/6071 Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-26Eliminate unneeded calls to FPDFPage_GenerateContentchromium/3115chromium/3114Nicolas Pena
The generating method is not needed for just inserting and rendering. Its purpose seems to be for usage when an already inserted image has been modified or when a copy of the PDF will be saved. Change-Id: I72250b3ba8c53b75249b4ef9ca1bef2d1231288d Reviewed-on: https://pdfium-review.googlesource.com/6091 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-05-18Bad cast to CPDF_Document in FPDFEditEmbeddertestTom Sepez
The test, as written, is only correct for the non-xfa case, where the FPDF_Document opaque type is equivalent to the CPDF_Document. Under XFA, however, there is another layer of indirection that the test harness needs to respect. Sorry, I missed this the first time around when I signed off on the CL that introduced this test. Change-Id: Ida3579edf639fbfca2939dc151c0420247e90ab3 Reviewed-on: https://pdfium-review.googlesource.com/5657 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-05-17Use more static_cast in fpdfsdkNicolas Pena
This CL replaces some reinterpret_cast with static_cast in fpdfsdk. It also removes an obsolete comment in fpdfedit.h Change-Id: I36c29bfcd6382490a8c955b50ccfa4c93ab351c7 Reviewed-on: https://pdfium-review.googlesource.com/5632 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-05-08fpdfsdk: add minimal FPDFPageObj_GetType() testcasechromium/3094Miklos Vajna
I did not realize it's possible to easily test public API when the function itself was added in commit 1423319f52c5e80253d337ad02b19187c6d66ff1 (Add public method FPDFPageObj_GetType to get type of a page object., 2017-04-03). Change-Id: I4b6f4a18eabbebbebb350e69db2b187b35c38da6 Reviewed-on: https://pdfium-review.googlesource.com/5071 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-04Make CPDF_Font member variables protected.Lei Zhang
Change-Id: I5d452ea907f4d243645ddae3512776096a827522 Reviewed-on: https://pdfium-review.googlesource.com/4872 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-05-03Add a ToUnicode mapping when loading CID fontsNicolas Pena
This CL adds ToUnicode for CID fonts and adds a test to prove that using it works as intended. The test uses a Linux font for Japanese characters, and tests for other OS will be added in a followup. The ToUnicode works by defining the PDF charcodes as equal to the glyph indices and assuming that the freetype charcodes given by FXFT_Get_Next_Char are in fact the unicode values. Bug: pdfium:667 Change-Id: I419724b87c3936c730a05f771548ae4787a576eb Reviewed-on: https://pdfium-review.googlesource.com/4810 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-05-02Roll FreeType to 5a3490e.Lei Zhang
This follows Chromium's FreeType DEPS roll. Potentially addresses Clang on Windows LLP64 build failure. Roll testing corpus to 5379e0a with updated expectations. BUG=pdfium:705 Change-Id: Ie494b68a52f953436accf8fd1961244f70a92cab Reviewed-on: https://pdfium-review.googlesource.com/4632 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-05-02Add API to create a text object using a loaded font.Nicolas Pena
There is already a method to add text from standard font, this CL adds an option to add text using a loaded font. The font set into a text object is ref counted and may be released, so call LoadFont on this new text obj, and add a method to close the font. This CL also improves the SetText method so that it now uses a WideString, in preparation for CID fonts with non-Latin characters. Bug: pdfium:667 Change-Id: I6829d702357d2a898a12f5297e4fd2ec993a9891 Reviewed-on: https://pdfium-review.googlesource.com/4770 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-04-29Fix rotationschromium/3086chromium/3085rbpotter
Normalize rotations read from PDF documents. Make FPDFPage_GetRotation always return a value 0 to 3 as specified in fpdf_edit.h instead of returning the page rotation / 90 (page rotation may be negative for some PDFs). BUG=chromium:713197 Change-Id: Ie477803f7d298b777a3ace89b21cfda8b7f6808b Reviewed-on: https://pdfium-review.googlesource.com/4532 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-04-13Add embeddertest for form text rendering and savingNicolas Pena
This CL adds an embeddertest that adds text to a textfield and saves it. It also adds a new 'charcode' option for .evt files in pdfium_test. Change-Id: I14fbf50e2b1d5ae0bdc68d1dd25dc4f889c49bfb Reviewed-on: https://pdfium-review.googlesource.com/4150 Commit-Queue: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-04-05Add public method FPDFPath_GetFillColor to get fill color of a path object.Miklos Vajna
It was already possible to set the fill color, this is the other direction. Change-Id: Id53f3c9969ca036ec1f9383a2cdbaf224395215f Reviewed-on: https://pdfium-review.googlesource.com/3690 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-03-30Upgrade to FreeType 2.7.1.Lei Zhang
BUG=pdfium:601 Change-Id: I07756cd208cd2221802ff2d331f316b6618a41e0 Reviewed-on: https://pdfium-review.googlesource.com/3120 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-03-27Remove old test expectations after the Mac 10.12 upgrade.Lei Zhang
BUG=chromium:703912 Change-Id: I5b4e582afc95b845e8e5e7a4e14581127c18de2d Reviewed-on: https://pdfium-review.googlesource.com/3193 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-03-22Fix Mac tests on 10.12Nicolas Pena
md5's with text are changed, so need to allow both the previous and the new one. Pixel tests with text also fail on 10.12, so suppressing those. Found many unexpected successes, so will unsuppress those once all bots are 10.12 BUG=chromium:703912 Change-Id: I6b34aa2f581eb8ea705f3876960b49c89e249347 Reviewed-on: https://pdfium-review.googlesource.com/3144 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-03-16Move FPDFImageObj_LoadJpegHelper() into an anonymous namespace.Lei Zhang
Add public FPDFPageObj_NewImageObj() call to replace FPDFPageObj_NewImgeObj() which is missing a letter. Change-Id: I5355ee5e5bf7e6e161e2004ec7e9257c85a463f7 Reviewed-on: https://pdfium-review.googlesource.com/2840 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-03-06Add public method FPDFText_LoadFont to load some types of fonts.Nicolas Pena
The new method replaces the previous one for loading only type1 fonts. This will create the font dictionary with the very basics needed, according to the tables in chapter 5 of the PDF spec. The tests for now are only checking that the information is getting passed on properly. Followup: adding text with those fonts, generating the contents (doing that will allow testing whether the parts that I've skipped like Encoding and cmaps are needed or not). BUG=pdfium:667 Change-Id: Id1a61501e09542804a391552fd002f2caed41939 Reviewed-on: https://pdfium-review.googlesource.com/2915 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-02-27Add public API for creating a Type1 fontNicolas Pena
Given a stream of data, we create a type1 font and fill up the required dictionary entries according to PDF spec 1.7. Table 5.8 describes Type 1 font dictionaries, and Table 5.19 describes font descriptors. BUG=pdfium:667 Change-Id: I571b09fb533467d77ed0104e613726387aec1f87 Reviewed-on: https://pdfium-review.googlesource.com/2835 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-02-15Move generated graphics and font maps to CPDF_PageNicolas Pena
A new CPDF_PageContentGenerator is created for every call of FPDFPage_GenerateContent, so having the maps there will cause duplicated resources to be created every time this method is called. Thus it is better to move these to the page. Change-Id: I47804f79790fc5354f8a94b6387d66b65eda5a20 Reviewed-on: https://pdfium-review.googlesource.com/2717 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-02-15Add public API for adding text with standard fontsNicolas Pena
BUG=pdfium:667 Change-Id: I05e301385a7af4b6ce27dc0b885e23646abf3dd9 Reviewed-on: https://pdfium-review.googlesource.com/2711 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-02-10Add line width option for stroking pathschromium/3011chromium/3010chromium/3009Nicolas Pena
BUG=pdfium:661 Change-Id: Ie1dc82a1323a35ebbd63a5b7b8f8c95f9a5325fe Reviewed-on: https://pdfium-review.googlesource.com/2613 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-02-08Add EmbedderTest for adding and filling pathsNicolas Pena
The PathObject uses GraphState to obtain the bounding box, so I set defaults, according to Table 4.2 of PDF spec 1.7. Not testing stroke for now because the default line width seems to be too small and is not being rendered. Methodology: add the test methods to the RenderPage method in pdfium_test, and run with --png and --md5. Check that the png is reasonable with respect to the expected result, and use the output md5 on the embeddertest. BUG=pdfium:661 Change-Id: I674fe3a68374c8d58cd99aaf9dad66e29e057281 Reviewed-on: https://pdfium-review.googlesource.com/2554 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2016-11-21Add a regression test for rasterizing PDFs.thestig
BUG=chromium:667012 Review-Url: https://codereview.chromium.org/2508203007
2016-11-21Fixup lint flags.Dan Sinclair
The -build/include setting was masking out build/include_what_you_use. This CL restores them, fixes any build errors, and adds NOLINT as needed. As well, the runtime/explicit and runtime/printf flags are aslo enabled and NOLINT'd. lint cleanups Change-Id: Ib013b3eb29c8d0e48cad74c5df9028684130719f Reviewed-on: https://pdfium-review.googlesource.com/2030 Reviewed-by: Tom Sepez <tsepez@chromium.org>
2016-08-19Fix an embedder test with leaked page objectchromium/2836chromium/2835weili
The public API FPDFPage_New() incorrectly said to use FPDFPage_Delete() instead of FPDF_ClosePage() to free the new page. This led to a page object leak in an embedder test. Correct the public API description as well as its usage in the embedder test. BUG=pdfium:242 Review-Url: https://codereview.chromium.org/2260683003
2016-04-26Fix unittest with embedded NUL character.etienneb
There is an embedded NUL character (previously line 40). The test was working because the beginning ot the string is identical. But, the rest of the string wasn't compare at all. TESTED: manually etienneb@burger:~/src/pdfium/pdfium$ out/Debug/pdfium_embeddertests --gtest_filter=*.EmptyCreation Note: Google Test filter = *.EmptyCreation [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from FPDFEditEmbeddertest [ RUN ] FPDFEditEmbeddertest.EmptyCreation [ OK ] FPDFEditEmbeddertest.EmptyCreation (13 ms) [----------] 1 test from FPDFEditEmbeddertest (13 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. (13 ms total) [ PASSED ] 1 test. R=dsinclair BUG=589955 Review URL: https://codereview.chromium.org/1916083002
2016-03-14Move fpdfsdk/src up to fpdfsdk/.Dan Sinclair
This CL moves the files in fpdfsdk/src/ up one level to fpdfsdk/ and fixes up the include paths, include guards and build files. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1799773002 .