The response has been limited to 50k tokens of the smallest files in the repo. You can remove this limitation by removing the max tokens filter.
├── .github
    ├── ISSUE_TEMPLATE
    │   ├── bug_report.md
    │   └── feature_request.md
    └── workflows
    │   └── greetings.yml
├── ACKNOWLEDGEMENTS.md
├── LICENSE.md
├── README.md
├── annotator
    └── annotator.go
├── common
    ├── common.go
    └── license
    │   └── license.go
├── contentstream
    ├── contentstream.go
    └── draw
    │   └── draw.go
├── core
    ├── core.go
    └── security
    │   ├── crypt
    │       └── crypt.go
    │   └── security.go
├── creator
    └── creator.go
├── extractor
    └── extractor.go
├── fdf
    └── fdf.go
├── fjson
    └── fjson.go
├── go.mod
├── go.sum
├── internal
    ├── bitwise
    │   └── bitwise.go
    ├── ccittfax
    │   └── ccittfax.go
    ├── cmap
    │   ├── bcmaps
    │   │   └── bcmaps.go
    │   └── cmap.go
    ├── endian
    │   └── endian.go
    ├── graphic2d
    │   └── graphic2d.go
    ├── imageutil
    │   └── imageutil.go
    ├── integrations
    │   └── unichart
    │   │   └── unichart.go
    ├── jbig2
    │   ├── basic
    │   │   └── basic.go
    │   ├── bench
    │   │   └── bench.go
    │   ├── bitmap
    │   │   └── bitmap.go
    │   ├── decoder
    │   │   ├── arithmetic
    │   │   │   └── arithmetic.go
    │   │   ├── decoder.go
    │   │   ├── huffman
    │   │   │   └── huffman.go
    │   │   └── mmr
    │   │   │   └── mmr.go
    │   ├── document
    │   │   ├── document.go
    │   │   └── segments
    │   │   │   └── segments.go
    │   ├── encoder
    │   │   ├── arithmetic
    │   │   │   └── arithmetic.go
    │   │   └── classer
    │   │   │   └── classer.go
    │   ├── errors
    │   │   └── errors.go
    │   ├── internal
    │   │   └── internal.go
    │   └── jbig2.go
    ├── license
    │   └── license.go
    ├── precision
    │   └── precision.go
    ├── sampling
    │   └── sampling.go
    ├── strutils
    │   └── strutils.go
    ├── testutils
    │   └── testutils.go
    ├── textencoding
    │   ├── internal
    │   │   └── syncmap
    │   │   │   └── syncmap.go
    │   └── textencoding.go
    ├── timeutils
    │   └── timeutils.go
    ├── transform
    │   └── transform.go
    └── uuid
    │   └── uuid.go
├── model
    ├── internal
    │   ├── colorprofile
    │   │   └── colorprofile.go
    │   ├── docutil
    │   │   └── docutil.go
    │   └── fonts
    │   │   └── fonts.go
    ├── mdp
    │   └── mdp.go
    ├── model.go
    ├── optimize
    │   ├── optimize.go
    │   └── tests
    │   │   └── tests.go
    ├── pdfa
    │   └── pdfa.go
    ├── sighandler
    │   └── sighandler.go
    ├── sigutil
    │   └── sigutil.go
    └── xmputil
    │   ├── pdfaextension
    │       └── pdfaextension.go
    │   ├── pdfaid
    │       └── pdfaid.go
    │   └── xmputil.go
├── pdfutil
    └── pdfutil.go
├── ps
    └── ps.go
├── redactor
    └── redactor.go
├── render
    ├── internal
    │   └── context
    │   │   ├── context.go
    │   │   └── imagerender
    │   │       └── imagerender.go
    └── render.go
├── sanitize
    └── sanitize.go
├── textshaping
    └── textshaping.go
└── unipdf.go


/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
 1 | ---
 2 | name: Bug report
 3 | about: Create a report to help us improve
 4 | title: "[BUG]"
 5 | labels: ''
 6 | assignees: ''
 7 | 
 8 | ---
 9 | 
10 | ## Description
11 | A clear and concise description of what the bug is.
12 | 
13 | ## Expected Behavior
14 | A clear and concise description of what you expected to happen.
15 | 
16 | ## Actual Behavior
17 | Steps to reproduce the behavior:
18 | 1. Go to '...'
19 | 2. Click on '....'
20 | 3. Scroll down to '....'
21 | 4. See error
22 | 
23 | ## Attachments
24 | Include a self-contained reproducible code snippet and PDF file that demonstrates the issue.
25 | 


--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
 1 | ---
 2 | name: Feature request
 3 | about: Suggest an idea for this project
 4 | title: "[FEATURE]"
 5 | labels: ''
 6 | assignees: ''
 7 | 
 8 | ---
 9 | 
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is.
12 | 
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 | 
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 | 
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 | 


--------------------------------------------------------------------------------
/.github/workflows/greetings.yml:
--------------------------------------------------------------------------------
 1 | name: Greetings
 2 | 
 3 | on: [issues]
 4 | 
 5 | jobs:
 6 |   greeting:
 7 |     runs-on: ubuntu-latest
 8 |     steps:
 9 |     - uses: actions/first-interaction@v1
10 |       with:
11 |         repo-token: ${{ secrets.GITHUB_TOKEN }}
12 |         issue-message: >
13 |           Welcome! Thanks for posting your first issue. The way things work here is that while customer issues are prioritized,
14 |           other issues go into our backlog where they are assessed and fitted into the roadmap when suitable.
15 |           If you need to get this done, consider buying a license which also enables you to use it in your commercial products.
16 |           More information can be found on https://unidoc.io/
17 |         pr-message: >
18 |           Thanks for posting your first PR. Please be sure to sign the CLA and make sure that the
19 |           the Developer Guidelines https://github.com/unidoc/unipdf/wiki/UniPDF-Developer-Guide were followed.
20 |           You can expect that we will review the PR and post comments. The timeframe fpr this can vary depending
21 |           on various factors, including which issue(s) the PR addresses and where it fits in the roadmap.
22 |           Note also that customer PRs are prioritized.
23 | 


--------------------------------------------------------------------------------
/ACKNOWLEDGEMENTS.md:
--------------------------------------------------------------------------------
  1 | Acknowledgements
  2 | ----------------
  3 | 
  4 | The UniDoc library uses resources from the following open source projects:
  5 | 
  6 | * [The standard Go library](https://golang.org/pkg/#stdlib), 
  7 | and [Go supplementary image libraries](https://godoc.org/golang.org/x/image/tiff/lzw), BSD-3 license:
  8 |   - Used for TIFF LZW encoding support.
  9 |   - PNG paeth algorithm
 10 |   
 11 | ```
 12 | Copyright (c) 2009 The Go Authors. All rights reserved.
 13 | 
 14 | Redistribution and use in source and binary forms, with or without
 15 | modification, are permitted provided that the following conditions are
 16 | met:
 17 | 
 18 |    * Redistributions of source code must retain the above copyright
 19 | notice, this list of conditions and the following disclaimer.
 20 |    * Redistributions in binary form must reproduce the above
 21 | copyright notice, this list of conditions and the following disclaimer
 22 | in the documentation and/or other materials provided with the
 23 | distribution.
 24 |    * Neither the name of Google Inc. nor the names of its
 25 | contributors may be used to endorse or promote products derived from
 26 | this software without specific prior written permission.
 27 | 
 28 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 29 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 30 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 31 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 32 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 33 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 34 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 35 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 36 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 37 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 38 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 39 | ```
 40 | 
 41 | 
 42 | * [fpdf - Kurt Jung](https://github.com/jung-kurt/gofpdf), MIT license.
 43 | 
 44 |   - Used for TrueType (TTF) font file parsing (unidoc/pdf/model/fonts/ttfparser.go).
 45 | ```
 46 | MIT License
 47 | 
 48 | Copyright (c) 2017 Kurt Jung and contributors acknowledged in the documentation
 49 | 
 50 | Permission is hereby granted, free of charge, to any person obtaining a copy
 51 | of this software and associated documentation files (the "Software"), to deal
 52 | in the Software without restriction, including without limitation the rights
 53 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 54 | copies of the Software, and to permit persons to whom the Software is
 55 | furnished to do so, subject to the following conditions:
 56 | 
 57 | The above copyright notice and this permission notice shall be included in all
 58 | copies or substantial portions of the Software.
 59 | 
 60 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 61 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 62 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 63 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 64 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 65 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 66 | SOFTWARE.
 67 | ```
 68 | 
 69 | * [Adobe Font Metrics PDF Core 14 fonts](http://www.adobe.com/devnet/font.html), with the following license:
 70 | ```
 71 | This file and the 14 PostScript(R) AFM files it accompanies may be used,
 72 | copied, and distributed for any purpose and without charge, with or without
 73 | modification, provided that all copyright notices are retained; that the
 74 | AFM files are not distributed without this file; that all modifications
 75 | to this file or any of the AFM files are prominently noted in the modified
 76 | file(s); and that this paragraph is not modified. Adobe Systems has no
 77 | responsibility or obligation to support the use of the AFM files.
 78 | ```
 79 | 
 80 |   - Used for support of the 14 core fonts (see unidoc/pdf/model/fonts/afms).
 81 | 
 82 | * [Adobe Glyph List](https://github.com/adobe-type-tools/agl-aglfn), BSD-3 license.
 83 |   - Used for glyph and textencoding support (see unidoc/pdf/model/textencoding/glyphlist).
 84 | 
 85 | ```
 86 | Redistribution and use in source and binary forms, with or without
 87 | modification, are permitted provided that the following conditions are
 88 | met:
 89 | 
 90 | Redistributions of source code must retain the above copyright notice,
 91 | this list of conditions and the following disclaimer.
 92 | 
 93 | Redistributions in binary form must reproduce the above copyright
 94 | notice, this list of conditions and the following disclaimer in the
 95 | documentation and/or other materials provided with the distribution.
 96 | 
 97 | Neither the name of Adobe Systems Incorporated nor the names of its
 98 | contributors may be used to endorse or promote products derived from
 99 | this software without specific prior written permission.
100 | 
101 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
102 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
103 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
104 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
105 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
106 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
107 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
108 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
109 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
110 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
111 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
112 | ```
113 | 
114 | * [Apache Java PDFBox JBIG2 Decoder](https://github.com/apache/pdfbox-jbig2), Apache License 2.0.
115 |     In order to achieve full support for the JBIG2 Decoder, it was necessary to implement all possible decoding
116 |     combinations defined in the JBIG2 standard, aka ITU T.88 and ISO/IEC 14492.
117 |     With a lack of Golang JBIG2 Open Source package, we’ve decided that it would be best to base our own implementation
118 |     on some solid and reliable library.
119 |     The Apache PDFBox JBIG2 library fulfilled all our requirements. It has a really good quality of the code along with
120 |     the detailed comments on each function and class. It also implemented  MMR, Huffman tables and arithmetic
121 |     decompressors along with all JBIG2 segments.
122 | 
123 | * [AGL JBIG2 Encoder](https://github.com/agl/jbig2enc), Apache License 2.0.
124 |     The complexity and lack of comprehensive documentation for the JBIG2 encoding process, lead us to look at the
125 |     AGL JBIG2 Encoder library. At the moment of implementing our encoder it was the only Open Source JBIG2 encoder.
126 |     It’s a C++ based library that implements both lossless and lossy encoding methods, where most of the image
127 |     operations are done using DanBloomberg Leptonica library.
128 | 
129 |     The core encoding processes in the UniPDF JBIG2 Encoder were based on that well documented and solid library
130 | 
131 | 
132 | * [DanBloomberg Leptonica](https://github.com/DanBloomberg/leptonica), The 2-Clause BSD License,
133 |     DanBloomberg Leptonica is an amazing C/C++ Open Source library. It provides raster operations, binary expansion and
134 |     reduction, JBIG2 component creators, correlation scoring and a lot more perfectly commented image operation functions.
135 |     That library was used as a very solid base for our image operation algorithms used by the JBIG2 Encoder.
136 | 
137 | * [sRGB2014 - Color Profile](http://www.color.org/srgbprofiles.xalter), Copyright International Color Consortium, 2015
138 |     This profile is made available by the International Color Consortium, and may be copied,
139 |     distributed, embedded, made, used, and sold without restriction. Altered versions of this
140 |     profile shall have the original identification and copyright information removed and
141 |     shall not be misrepresented as the original profile.
142 | 
143 | * [sRGB v4 ICC preference - Color Profile](http://www.color.org/srgbprofiles.xalter), Copyright 2007 International Color Consortium
144 |     This profile is made available by the International Color Consortium, and may be copied,
145 |     distributed, embedded, made, used, and sold without restriction. Altered versions of this
146 |     profile shall have the original identification and copyright information removed and
147 |     shall not be misrepresented as the original profile.
148 |  
149 | * [ISO Coated v2 Grey1c bas - Color Profile](https://www.colormanagement.org/en/isoprofile2009.html#ISOcoated_v2_grey1c_bas), 
150 |     Copyright (c) 2007, basICColor GmbH
151 |     
152 |     This software is provided 'as-is', without any express or implied
153 |     warranty. In no event will the authors be held liable for any damages
154 |     arising from the use of this software.
155 |     
156 |     Permission is granted to anyone to use this software for any purpose,
157 |     including commercial applications, and to alter it and redistribute it
158 |     freely, subject to the following restrictions:
159 |     
160 |     1. The origin of this software must not be misrepresented; you must  
161 |        not
162 |        claim that you wrote the original software. If you use this software
163 |        in a product, an acknowledgment in the product documentation would be
164 |        appreciated but is not required.
165 |     
166 |     2. Altered source versions must be plainly marked as such, and must  
167 |        not be
168 |        misrepresented as being the original software.
169 |     
170 |     3. This notice may not be removed or altered from any source
171 |        distribution.
172 | 
173 | * [ISO Coated v2 300 bas - Color Profile](https://www.colormanagement.org/en/isoprofile2009.html#ISOcoated_v2_300_bas), 
174 |     Copyright (c) 2007-2010, basICColor GmbH
175 |     
176 |     This software is provided 'as-is', without any express or implied
177 |     warranty. In no event will the authors be held liable for any damages
178 |     arising from the use of this software.
179 |     
180 |     Permission is granted to anyone to use this software for any purpose,
181 |     including commercial applications, and to alter it and redistribute it
182 |     freely, subject to the following restrictions:
183 |     
184 |     1. The origin of this software must not be misrepresented; you must  
185 |        not
186 |        claim that you wrote the original software. If you use this software
187 |        in a product, an acknowledgment in the product documentation would be
188 |        appreciated but is not required.
189 |     
190 |     2. Altered source versions must be plainly marked as such, and must  
191 |        not be
192 |        misrepresented as being the original software.
193 |     
194 |     3. This notice may not be removed or altered from any source
195 |        distribution.
196 | 
197 | * [Go-XMP Native SDK](https://github.com/trimmer-io/go-xmp), Copyright 2017 Alexander Eichhorn
198 | 
199 |   Licensed under the Apache License, Version 2.0 (the "License");
200 |   you may not use this file except in compliance with the License.
201 |   You may obtain a copy of the License at
202 |   http://www.apache.org/licenses/LICENSE-2.0
203 | 
204 |   The native Go-XMP SDK was used as a core of the XMP utilities in the package 
205 |   `github.com/unidoc/unipdf/model/xmputil`.
206 | 
207 | * [CCITTFax Decoder](https://github.com/haraldk/TwelveMonkeys/blob/master/imageio/imageio-tiff/src/main/java/com/twelvemonkeys/imageio/plugins/tiff/CCITTFaxDecoderStream.java), Copyright (c) 2008-2020, Harald Kuhr
208 |   All rights reserved.
209 | 
210 |     Redistribution and use in source and binary forms, with or without
211 |     modification, are permitted provided that the following conditions are met:
212 |     
213 |     o Redistributions of source code must retain the above copyright notice, this
214 |     list of conditions and the following disclaimer.
215 |     
216 |     o Redistributions in binary form must reproduce the above copyright notice,
217 |     this list of conditions and the following disclaimer in the documentation
218 |     and/or other materials provided with the distribution.
219 |     
220 |     o Neither the name of the copyright holder nor the names of its
221 |     contributors may be used to endorse or promote products derived from
222 |     this software without specific prior written permission.
223 |     
224 |     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
225 |     AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
226 |     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
227 |     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
228 |     FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
229 |     DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
230 |     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
231 |     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
232 |     OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
233 |     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
234 |   
235 |     UniPDF architectural concept of ccittfax decoder was based on the Java implementation defined in the https://github.com/haraldk/TwelveMonkeys.
236 |     
237 | * [i18n/linebreak](https://github.com/gorilla/i18n), BSD-3 license:
238 |   - Used for word line break.
239 |   
240 | ```
241 | Copyright (c) 2013, Gorilla web toolkit
242 | All rights reserved.
243 | 
244 | Redistribution and use in source and binary forms, with or without modification,
245 | are permitted provided that the following conditions are met:
246 | 
247 |   Redistributions of source code must retain the above copyright notice, this
248 |   list of conditions and the following disclaimer.
249 | 
250 |   Redistributions in binary form must reproduce the above copyright notice, this
251 |   list of conditions and the following disclaimer in the documentation and/or
252 |   other materials provided with the distribution.
253 | 
254 |   Neither the name of the {organization} nor the names of its
255 |   contributors may be used to endorse or promote products derived from
256 |   this software without specific prior written permission.
257 | 
258 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
259 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
260 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
261 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
262 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
263 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
264 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
265 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
266 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
267 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
268 | ```
269 | 
270 | * [Bidi implementation of pdf.js](https://github.com/mozilla/pdf.js/blob/master/src/core/bidi.js), Apache License, Version 2.0:
271 | 
272 |   - Used to process Bidirectional text extraction.
273 | ```
274 | 
275 | Copyright 2012 Mozilla Foundation
276 |  
277 |  Licensed under the Apache License, Version 2.0 (the "License");
278 |  you may not use this file except in compliance with the License.
279 |  You may obtain a copy of the License at
280 |  
281 |      http://www.apache.org/licenses/LICENSE-2.0
282 |  
283 |  Unless required by applicable law or agreed to in writing, software
284 |  distributed under the License is distributed on an "AS IS" BASIS,
285 |  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
286 |  See the License for the specific language governing permissions and
287 |  limitations under the License.
288 | 
289 | ```


--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
 1 | ## Licensing Information
 2 | 
 3 | This software package is a commercial product and requires a license
 4 | code to operate.
 5 | 
 6 | The use of this software package is governed by the end-user license agreement 
 7 | (EULA) available at: https://unidoc.io/eula/
 8 | 
 9 | To obtain a Trial license code to evaluate the software, please visit
10 | https://unidoc.io/
11 | 


--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
 1 | # UniPDF - PDF for Go
 2 | 
 3 | [UniDoc](http://unidoc.io) UniPDF is a PDF library for Go (golang) with capabilities for
 4 | creating and reading, processing PDF files. The library is written and supported by 
 5 | [FoxyUtils.com](https://foxyutils.com), where the library is used to power many of its services. 
 6 | 
 7 | [![GitHub (pre-)release](https://img.shields.io/github/release/unidoc/unipdf/all.svg)](https://github.com/unidoc/unipdf/releases)
 8 | [![License: UniDoc EULA](https://img.shields.io/badge/license-UniDoc%20EULA-blue)](https://unidoc.io/eula/)
 9 | [![ApiDocs](https://img.shields.io/badge/godoc-reference-blue.svg)](https://apidocs.unidoc.io/unipdf/latest/)
10 | 
11 | ## Features
12 | 
13 | - [Create PDF reports](https://github.com/unidoc/unipdf-examples/blob/master/report/pdf_report.go). Example output: [unidoc-report.pdf](https://github.com/unidoc/unipdf-examples/blob/master/report/unidoc-report.pdf).
14 | - [Table PDF reports](https://github.com/unidoc/unipdf-examples/blob/master/report/pdf_tables.go). Example output: [unipdf-tables.pdf](https://github.com/unidoc/unipdf-examples/blob/master/report/unipdf-tables.pdf).
15 | - [Invoice creation](https://unidoc.io/news/simple-invoices)
16 | - [Styled paragraphs](https://github.com/unidoc/unipdf-examples/blob/master/text/pdf_formatted_text.go)
17 | - [Merge PDF pages](https://github.com/unidoc/unipdf-examples/blob/master/pages/pdf_merge.go)
18 | - [Split PDF pages](https://github.com/unidoc/unipdf-examples/blob/master/pages/pdf_split.go) and change page order
19 | - [Rotate pages](https://github.com/unidoc/unipdf-examples/blob/master/pages/pdf_rotate.go)
20 | - [Extract text from PDF files](https://github.com/unidoc/unipdf-examples/blob/master/extract/pdf_extract_text.go)
21 | - [Text extraction support with size, position and formatting info](https://github.com/unidoc/unipdf-examples/blob/master/text/pdf_text_locations.go)
22 | - [PDF to CSV](https://github.com/unidoc/unipdf-examples/blob/master/text/pdf_to_csv.go) illustrates extracting tabular data from PDF.
23 | - [Extract images](https://github.com/unidoc/unipdf-examples/blob/master/extract/pdf_extract_images.go) with coordinates
24 | - [Images to PDF](https://github.com/unidoc/unipdf-examples/blob/master/image/pdf_images_to_pdf.go)
25 | - [Add images to pages](https://github.com/unidoc/unipdf-examples/blob/master/image/pdf_add_image_to_page.go)
26 | - [Compress and optimize PDF](https://github.com/unidoc/unipdf-examples/blob/master/compress/pdf_optimize.go)
27 | - [Watermark PDF files](https://github.com/unidoc/unipdf-examples/blob/master/image/pdf_watermark_image.go)
28 | - Advanced page manipulation:  [Put 4 pages on 1](https://github.com/unidoc/unipdf-examples/blob/master/pages/pdf_4up.go)
29 | - Load PDF templates and modify
30 | - [Form creation](https://github.com/unidoc/unipdf-examples/blob/master/forms/pdf_form_add.go)
31 | - [Fill and flatten forms](https://github.com/unidoc/unipdf-examples/blob/master/forms/pdf_form_flatten.go)
32 | - [Fill out forms](https://github.com/unidoc/unipdf-examples/blob/master/forms/pdf_form_fill_json.go) and [FDF merging](https://github.com/unidoc/unipdf-examples/blob/master/forms/pdf_form_fill_fdf_merge.go)
33 | - [Unlock PDF files / remove password](https://github.com/unidoc/unipdf-examples/blob/master/security/pdf_unlock.go)
34 | - [Protect PDF files with a password](https://github.com/unidoc/unipdf-examples/blob/master/security/pdf_protect.go)
35 | - [Digital signing validation and signing](https://github.com/unidoc/unipdf-examples/tree/master/signatures)
36 | - CCITTFaxDecode decoding and encoding support
37 | - JBIG2 decoding support
38 | 
39 | Multiple examples are provided in our example repository https://github.com/unidoc/unipdf-examples.
40 | 
41 | Contact us if you need any specific examples.
42 | 
43 | ## Installation
44 | With modules:
45 | ~~~
46 | go get github.com/unidoc/unipdf/v4
47 | ~~~
48 | 
49 | ## License key
50 | This software package (unipdf) is a commercial product and requires a license code to operate.
51 | 
52 | To Get a Metered License API Key in for free in the Free Tier, sign up on https://cloud.unidoc.io
53 | 
54 | 
55 | ## How can I convince myself and my boss to buy unipdf rather using a free alternative?
56 | 
57 | The choice is yours. There are multiple respectable efforts out there that can do many useful things.
58 | 
59 | In UniDoc, we work hard to provide production quality builds taking every detail into consideration and providing excellent support to our customers.  See our [testimonials](https://unidoc.io) for example.
60 | 
61 | Security.  We take security very seriously and we restrict access to github.com/unidoc/unipdf repository with protected branches and only the founders have access and every commit is reviewed prior to being accepted.
62 | 
63 | The profits are invested back into making unipdf better. We want to make the best possible product and in order to do that we need the best people to contribute. A large fraction of the profits made goes back into developing unipdf.  That way we have been able to get many excellent people to work and contribute to unipdf that would not be able to contribute their work for free.
64 | 
65 | 
66 | ## Contributing
67 | 
68 | If you are interested in contributing, please contact us.
69 | 
70 | ## Go Version Compatibility
71 | 
72 | Officially we support three latest Go versions, but internally we would test the build with up to five latest Go versions in our CI runner.
73 | 
74 | ## Support and consulting
75 | 
76 | Please email us at support@unidoc.io for any queries.
77 | 
78 | If you have any specific tasks that need to be done, we offer consulting in certain cases.
79 | Please contact us with a brief summary of what you need and we will get back to you with a quote, if appropriate.
80 | 
81 | ## License agreement
82 | 
83 | The use of this software package is governed by the end-user license agreement 
84 | (EULA) available at: https://unidoc.io/eula/
85 | 


--------------------------------------------------------------------------------
/common/common.go:
--------------------------------------------------------------------------------
  1 | //
  2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
  3 | //
  4 | // This is a commercial product and requires a license to operate.
  5 | // A trial license can be obtained at https://unidoc.io
  6 | //
  7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
  8 | //
  9 | // Use of this source code is governed by the UniDoc End User License Agreement
 10 | // terms that can be accessed at https://unidoc.io/eula/
 11 | 
 12 | // Package common contains common properties used by the subpackages.
 13 | package common ;import (_e "fmt";_dd "io";_c "os";_d "path/filepath";_b "runtime";_ab "time";);
 14 | 
 15 | // IsLogLevel returns true from dummy logger.
 16 | func (DummyLogger )IsLogLevel (level LogLevel )bool {return true };func (_gdb WriterLogger )logToWriter (_da _dd .Writer ,_fg string ,_gf string ,_dfd ...interface{}){_ee (_da ,_fg ,_gf ,_dfd );};
 17 | 
 18 | // Error logs error message.
 19 | func (_bcb WriterLogger )Error (format string ,args ...interface{}){if _bcb .LogLevel >=LogLevelError {_gc :="\u005b\u0045\u0052\u0052\u004f\u0052\u005d\u0020";_bcb .logToWriter (_bcb .Output ,_gc ,format ,args ...);};};const _egd ="\u0032\u0020\u004aan\u0075\u0061\u0072\u0079\u0020\u0032\u0030\u0030\u0036\u0020\u0061\u0074\u0020\u0031\u0035\u003a\u0030\u0034";
 20 | 
 21 | 
 22 | // DummyLogger does nothing.
 23 | type DummyLogger struct{};
 24 | 
 25 | // Trace does nothing for dummy logger.
 26 | func (DummyLogger )Trace (format string ,args ...interface{}){};
 27 | 
 28 | // LogLevel is the verbosity level for logging.
 29 | type LogLevel int ;const _gbe =2025;
 30 | 
 31 | // Debug logs debug message.
 32 | func (_dce ConsoleLogger )Debug (format string ,args ...interface{}){if _dce .LogLevel >=LogLevelDebug {_f :="\u005b\u0044\u0045\u0042\u0055\u0047\u005d\u0020";_dce .output (_c .Stdout ,_f ,format ,args ...);};};
 33 | 
 34 | // ConsoleLogger is a logger that writes logs to the 'os.Stdout'
 35 | type ConsoleLogger struct{LogLevel LogLevel ;};
 36 | 
 37 | // Notice logs notice message.
 38 | func (_df WriterLogger )Notice (format string ,args ...interface{}){if _df .LogLevel >=LogLevelNotice {_de :="\u005bN\u004f\u0054\u0049\u0043\u0045\u005d ";_df .logToWriter (_df .Output ,_de ,format ,args ...);};};
 39 | 
 40 | // Error does nothing for dummy logger.
 41 | func (DummyLogger )Error (format string ,args ...interface{}){};
 42 | 
 43 | // Info logs info message.
 44 | func (_def WriterLogger )Info (format string ,args ...interface{}){if _def .LogLevel >=LogLevelInfo {_fc :="\u005bI\u004e\u0046\u004f\u005d\u0020";_def .logToWriter (_def .Output ,_fc ,format ,args ...);};};
 45 | 
 46 | // Logger is the interface used for logging in the unipdf package.
 47 | type Logger interface{Error (_g string ,_ge ...interface{});Warning (_bd string ,_ae ...interface{});Notice (_gg string ,_bc ...interface{});Info (_ea string ,_ac ...interface{});Debug (_cf string ,_ce ...interface{});Trace (_acf string ,_dc ...interface{});
 48 | IsLogLevel (_eg LogLevel )bool ;};
 49 | 
 50 | // Notice logs notice message.
 51 | func (_bdd ConsoleLogger )Notice (format string ,args ...interface{}){if _bdd .LogLevel >=LogLevelNotice {_cc :="\u005bN\u004f\u0054\u0049\u0043\u0045\u005d ";_bdd .output (_c .Stdout ,_cc ,format ,args ...);};};
 52 | 
 53 | // Trace logs trace message.
 54 | func (_dge WriterLogger )Trace (format string ,args ...interface{}){if _dge .LogLevel >=LogLevelTrace {_fe :="\u005b\u0054\u0052\u0041\u0043\u0045\u005d\u0020";_dge .logToWriter (_dge .Output ,_fe ,format ,args ...);};};func (_ceb ConsoleLogger )output (_af _dd .Writer ,_eae string ,_ccd string ,_fb ...interface{}){_ee (_af ,_eae ,_ccd ,_fb ...);
 55 | };var Log Logger =DummyLogger {};
 56 | 
 57 | // WriterLogger is the logger that writes data to the Output writer
 58 | type WriterLogger struct{LogLevel LogLevel ;Output _dd .Writer ;};
 59 | 
 60 | // IsLogLevel returns true if log level is greater or equal than `level`.
 61 | // Can be used to avoid resource intensive calls to loggers.
 62 | func (_ag ConsoleLogger )IsLogLevel (level LogLevel )bool {return _ag .LogLevel >=level };
 63 | 
 64 | // Info logs info message.
 65 | func (_cd ConsoleLogger )Info (format string ,args ...interface{}){if _cd .LogLevel >=LogLevelInfo {_gd :="\u005bI\u004e\u0046\u004f\u005d\u0020";_cd .output (_c .Stdout ,_gd ,format ,args ...);};};
 66 | 
 67 | // UtcTimeFormat returns a formatted string describing a UTC timestamp.
 68 | func UtcTimeFormat (t _ab .Time )string {return t .Format (_egd )+"\u0020\u0055\u0054\u0043"};const _aae =6;
 69 | 
 70 | // Info does nothing for dummy logger.
 71 | func (DummyLogger )Info (format string ,args ...interface{}){};
 72 | 
 73 | // Warning logs warning message.
 74 | func (_ba ConsoleLogger )Warning (format string ,args ...interface{}){if _ba .LogLevel >=LogLevelWarning {_aa :="\u005b\u0057\u0041\u0052\u004e\u0049\u004e\u0047\u005d\u0020";_ba .output (_c .Stdout ,_aa ,format ,args ...);};};
 75 | 
 76 | // Debug logs debug message.
 77 | func (_fbe WriterLogger )Debug (format string ,args ...interface{}){if _fbe .LogLevel >=LogLevelDebug {_abg :="\u005b\u0044\u0045\u0042\u0055\u0047\u005d\u0020";_fbe .logToWriter (_fbe .Output ,_abg ,format ,args ...);};};
 78 | 
 79 | // NewConsoleLogger creates new console logger.
 80 | func NewConsoleLogger (logLevel LogLevel )*ConsoleLogger {return &ConsoleLogger {LogLevel :logLevel }};const _fdg =23;const _ad =30;var ReleasedAt =_ab .Date (_gbe ,_aae ,_fdg ,_feb ,_ad ,0,0,_ab .UTC );
 81 | 
 82 | // Trace logs trace message.
 83 | func (_dg ConsoleLogger )Trace (format string ,args ...interface{}){if _dg .LogLevel >=LogLevelTrace {_fd :="\u005b\u0054\u0052\u0041\u0043\u0045\u005d\u0020";_dg .output (_c .Stdout ,_fd ,format ,args ...);};};
 84 | 
 85 | // Notice does nothing for dummy logger.
 86 | func (DummyLogger )Notice (format string ,args ...interface{}){};
 87 | 
 88 | // Debug does nothing for dummy logger.
 89 | func (DummyLogger )Debug (format string ,args ...interface{}){};const Version ="\u0034\u002e\u0031.\u0030";const _feb =15;
 90 | 
 91 | // Warning logs warning message.
 92 | func (_fda WriterLogger )Warning (format string ,args ...interface{}){if _fda .LogLevel >=LogLevelWarning {_ged :="\u005b\u0057\u0041\u0052\u004e\u0049\u004e\u0047\u005d\u0020";_fda .logToWriter (_fda .Output ,_ged ,format ,args ...);};};
 93 | 
 94 | // Error logs error message.
 95 | func (_agc ConsoleLogger )Error (format string ,args ...interface{}){if _agc .LogLevel >=LogLevelError {_cfb :="\u005b\u0045\u0052\u0052\u004f\u0052\u005d\u0020";_agc .output (_c .Stdout ,_cfb ,format ,args ...);};};
 96 | 
 97 | // IsLogLevel returns true if log level is greater or equal than `level`.
 98 | // Can be used to avoid resource intensive calls to loggers.
 99 | func (_gb WriterLogger )IsLogLevel (level LogLevel )bool {return _gb .LogLevel >=level };
100 | 
101 | // NewWriterLogger creates new 'writer' logger.
102 | func NewWriterLogger (logLevel LogLevel ,writer _dd .Writer )*WriterLogger {_eb :=WriterLogger {Output :writer ,LogLevel :logLevel };return &_eb ;};const (LogLevelTrace LogLevel =5;LogLevelDebug LogLevel =4;LogLevelInfo LogLevel =3;LogLevelNotice LogLevel =2;
103 | LogLevelWarning LogLevel =1;LogLevelError LogLevel =0;);func _ee (_cce _dd .Writer ,_dgg string ,_gfc string ,_ef ...interface{}){_ ,_aga ,_be ,_ec :=_b .Caller (3);if !_ec {_aga ="\u003f\u003f\u003f";_be =0;}else {_aga =_d .Base (_aga );};_aag :=_e .Sprintf ("\u0025s\u0020\u0025\u0073\u003a\u0025\u0064 ",_dgg ,_aga ,_be )+_gfc +"\u000a";
104 | _e .Fprintf (_cce ,_aag ,_ef ...);};
105 | 
106 | // Warning does nothing for dummy logger.
107 | func (DummyLogger )Warning (format string ,args ...interface{}){};
108 | 
109 | // SetLogger sets 'logger' to be used by the unidoc unipdf library.
110 | func SetLogger (logger Logger ){Log =logger };


--------------------------------------------------------------------------------
/common/license/license.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | // Package license helps manage commercial licenses and check if they are valid for the version of unipdf used.
13 | package license ;import _c "github.com/unidoc/unipdf/v4/internal/license";const (LicenseTierUnlicensed =_c .LicenseTierUnlicensed ;LicenseTierCommunity =_c .LicenseTierCommunity ;LicenseTierIndividual =_c .LicenseTierIndividual ;LicenseTierBusiness =_c .LicenseTierBusiness ;
14 | );func SetMeteredKeyUsageLogVerboseMode (val bool ){_c .SetMeteredKeyUsageLogVerboseMode (val )};
15 | 
16 | // GetMeteredState checks the currently used metered document usage status,
17 | // documents used and credits available.
18 | func GetMeteredState ()(_c .MeteredStatus ,error ){return _c .GetMeteredState ()};
19 | 
20 | // MakeUnlicensedKey returns a default key.
21 | func MakeUnlicensedKey ()*LicenseKey {return _c .MakeUnlicensedKey ()};
22 | 
23 | // SetLicenseKey sets and validates the license key.
24 | func SetLicenseKey (content string ,customerName string )error {return _c .SetLicenseKey (content ,customerName );};
25 | 
26 | // SetMeteredKeyPersistentCache sets the metered License API Key persistent cache.
27 | // Default value 'true', set to `false` will report the usage immediately to license server,
28 | // this can be used when there's no access to persistent data storage.
29 | func SetMeteredKeyPersistentCache (val bool ){_c .SetMeteredKeyPersistentCache (val )};
30 | 
31 | // SetMeteredKey sets the metered API key required for SaaS operation.
32 | // Document usage is reported periodically for the product to function correctly.
33 | func SetMeteredKey (apiKey string )error {return _c .SetMeteredKey (apiKey )};
34 | 
35 | // GetLicenseKey returns the currently loaded license key.
36 | func GetLicenseKey ()*LicenseKey {return _c .GetLicenseKey ()};
37 | 
38 | // LicenseKey represents a loaded license key.
39 | type LicenseKey =_c .LicenseKey ;


--------------------------------------------------------------------------------
/core/security/crypt/crypt.go:
--------------------------------------------------------------------------------
  1 | //
  2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
  3 | //
  4 | // This is a commercial product and requires a license to operate.
  5 | // A trial license can be obtained at https://unidoc.io
  6 | //
  7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
  8 | //
  9 | // Use of this source code is governed by the UniDoc End User License Agreement
 10 | // terms that can be accessed at https://unidoc.io/eula/
 11 | 
 12 | package crypt ;import (_g "crypto/aes";_ac "crypto/cipher";_af "crypto/md5";_afe "crypto/rand";_de "crypto/rc4";_b "fmt";_bg "github.com/unidoc/unipdf/v4/common";_bf "github.com/unidoc/unipdf/v4/core/security";_d "io";);func init (){_agc ("\u0041\u0045\u0053V\u0032",_c )};
 13 | type filterAESV3 struct{filterAES };type filterV2 struct{_dce int };
 14 | 
 15 | // HandlerVersion implements Filter interface.
 16 | func (filterAESV2 )HandlerVersion ()(V ,R int ){V ,R =4,4;return ;};func _ae (_aee FilterDict )(Filter ,error ){if _aee .Length ==256{_bg .Log .Debug ("\u0041\u0045S\u0056\u0033\u0020c\u0072\u0079\u0070\u0074\u0020f\u0069\u006c\u0074\u0065\u0072 l\u0065\u006e\u0067\u0074\u0068\u0020\u0061\u0070\u0070\u0065\u0061\u0072\u0073\u0020\u0074\u006f\u0020\u0062e\u0020i\u006e\u0020\u0062\u0069\u0074\u0073 ra\u0074\u0068\u0065\u0072\u0020\u0074\u0068\u0061\u006e\u0020\u0062\u0079te\u0073 \u002d\u0020\u0061\u0073s\u0075m\u0069n\u0067\u0020b\u0069\u0074s \u0028\u0025\u0064\u0029",_aee .Length );
 17 | _aee .Length /=8;};if _aee .Length !=0&&_aee .Length !=32{return nil ,_b .Errorf ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0041\u0045\u0053\u0056\u0033\u0020\u0063\u0072\u0079\u0070\u0074\u0020\u0066\u0069\u006c\u0074e\u0072\u0020\u006c\u0065\u006eg\u0074\u0068 \u0028\u0025\u0064\u0029",_aee .Length );
 18 | };return filterAESV3 {},nil ;};func _df (_ddg FilterDict )(Filter ,error ){if _ddg .Length %8!=0{return nil ,_b .Errorf ("\u0063\u0072\u0079p\u0074\u0020\u0066\u0069\u006c\u0074\u0065\u0072\u0020\u006c\u0065\u006e\u0067\u0074\u0068\u0020\u006e\u006f\u0074\u0020\u006d\u0075\u006c\u0074\u0069\u0070\u006c\u0065\u0020o\u0066\u0020\u0038\u0020\u0028\u0025\u0064\u0029",_ddg .Length );
 19 | };if _ddg .Length < 5||_ddg .Length > 16{if _ddg .Length ==40||_ddg .Length ==64||_ddg .Length ==128{_bg .Log .Debug ("\u0053\u0054\u0041\u004e\u0044AR\u0044\u0020V\u0049\u004f\u004c\u0041\u0054\u0049\u004f\u004e\u003a\u0020\u0043\u0072\u0079\u0070\u0074\u0020\u004c\u0065\u006e\u0067\u0074\u0068\u0020\u0061\u0070\u0070\u0065\u0061\u0072s\u0020\u0074\u006f \u0062\u0065\u0020\u0069\u006e\u0020\u0062\u0069\u0074\u0073\u0020\u0072\u0061t\u0068\u0065\u0072\u0020\u0074h\u0061\u006e\u0020\u0062\u0079\u0074\u0065\u0073\u0020-\u0020\u0061s\u0073u\u006d\u0069\u006e\u0067\u0020\u0062\u0069t\u0073\u0020\u0028\u0025\u0064\u0029",_ddg .Length );
 20 | _ddg .Length /=8;}else {return nil ,_b .Errorf ("\u0063\u0072\u0079\u0070\u0074\u0020\u0066\u0069\u006c\u0074\u0065\u0072\u0020\u006c\u0065\u006e\u0067\u0074h\u0020\u006e\u006f\u0074\u0020\u0069\u006e \u0072\u0061\u006e\u0067\u0065\u0020\u0034\u0030\u0020\u002d\u00201\u0032\u0038\u0020\u0062\u0069\u0074\u0020\u0028\u0025\u0064\u0029",_ddg .Length );
 21 | };};return filterV2 {_dce :_ddg .Length },nil ;};
 22 | 
 23 | // MakeKey implements Filter interface.
 24 | func (filterAESV3 )MakeKey (_ ,_ uint32 ,ekey []byte )([]byte ,error ){return ekey ,nil };
 25 | 
 26 | // MakeKey implements Filter interface.
 27 | func (filterAESV2 )MakeKey (objNum ,genNum uint32 ,ekey []byte )([]byte ,error ){return _gcc (objNum ,genNum ,ekey ,true );};
 28 | 
 29 | // NewFilterAESV2 creates an AES-based filter with a 128 bit key (AESV2).
 30 | func NewFilterAESV2 ()Filter {_e ,_gc :=_c (FilterDict {});if _gc !=nil {_bg .Log .Error ("E\u0052\u0052\u004f\u0052\u003a\u0020\u0063\u006f\u0075l\u0064\u0020\u006e\u006f\u0074\u0020\u0063re\u0061\u0074\u0065\u0020A\u0045\u0053\u0020\u0056\u0032\u0020\u0063\u0072\u0079pt\u0020\u0066i\u006c\u0074\u0065\u0072\u003a\u0020\u0025\u0076",_gc );
 31 | return filterAESV2 {};};return _e ;};var _ Filter =filterV2 {};func init (){_agc ("\u0041\u0045\u0053V\u0033",_ae )};type filterAES struct{};
 32 | 
 33 | // NewFilterV2 creates a RC4-based filter with a specified key length (in bytes).
 34 | func NewFilterV2 (length int )Filter {_aef ,_gg :=_df (FilterDict {Length :length });if _gg !=nil {_bg .Log .Error ("E\u0052\u0052\u004f\u0052\u003a\u0020\u0063\u006f\u0075l\u0064\u0020\u006e\u006f\u0074\u0020\u0063re\u0061\u0074\u0065\u0020R\u0043\u0034\u0020\u0056\u0032\u0020\u0063\u0072\u0079pt\u0020\u0066i\u006c\u0074\u0065\u0072\u003a\u0020\u0025\u0076",_gg );
 35 | return filterV2 {_dce :length };};return _aef ;};
 36 | 
 37 | // Name implements Filter interface.
 38 | func (filterV2 )Name ()string {return "\u0056\u0032"};
 39 | 
 40 | // NewFilter creates CryptFilter from a corresponding dictionary.
 41 | func NewFilter (d FilterDict )(Filter ,error ){_dg ,_gf :=_efa (d .CFM );if _gf !=nil {return nil ,_gf ;};_bfd ,_gf :=_dg (d );if _gf !=nil {return nil ,_gf ;};return _bfd ,nil ;};
 42 | 
 43 | // PDFVersion implements Filter interface.
 44 | func (filterAESV3 )PDFVersion ()[2]int {return [2]int {2,0}};
 45 | 
 46 | // HandlerVersion implements Filter interface.
 47 | func (_gce filterV2 )HandlerVersion ()(V ,R int ){V ,R =2,3;return ;};
 48 | 
 49 | // HandlerVersion implements Filter interface.
 50 | func (filterAESV3 )HandlerVersion ()(V ,R int ){V ,R =5,6;return ;};func _efa (_eb string )(filterFunc ,error ){_beg :=_bca [_eb ];if _beg ==nil {return nil ,_b .Errorf ("\u0075\u006e\u0073\u0075p\u0070\u006f\u0072\u0074\u0065\u0064\u0020\u0063\u0072\u0079p\u0074 \u0066\u0069\u006c\u0074\u0065\u0072\u003a \u0025\u0071",_eb );
 51 | };return _beg ,nil ;};
 52 | 
 53 | // Name implements Filter interface.
 54 | func (filterAESV3 )Name ()string {return "\u0041\u0045\u0053V\u0033"};
 55 | 
 56 | // PDFVersion implements Filter interface.
 57 | func (_fde filterV2 )PDFVersion ()[2]int {return [2]int {}};
 58 | 
 59 | // EncryptBytes implements Filter interface.
 60 | func (filterV2 )EncryptBytes (buf []byte ,okey []byte )([]byte ,error ){_ea ,_gca :=_de .NewCipher (okey );if _gca !=nil {return nil ,_gca ;};_bg .Log .Trace ("\u0052\u00434\u0020\u0045\u006ec\u0072\u0079\u0070\u0074\u003a\u0020\u0025\u0020\u0078",buf );
 61 | _ea .XORKeyStream (buf ,buf );_bg .Log .Trace ("\u0074o\u003a\u0020\u0025\u0020\u0078",buf );return buf ,nil ;};
 62 | 
 63 | // FilterDict represents information from a CryptFilter dictionary.
 64 | type FilterDict struct{CFM string ;AuthEvent _bf .AuthEvent ;Length int ;};func init (){_agc ("\u0056\u0032",_df )};func (filterIdentity )KeyLength ()int {return 0};var (_bca =make (map[string ]filterFunc ););func _c (_ce FilterDict )(Filter ,error ){if _ce .Length ==128{_bg .Log .Debug ("\u0041\u0045S\u0056\u0032\u0020c\u0072\u0079\u0070\u0074\u0020f\u0069\u006c\u0074\u0065\u0072 l\u0065\u006e\u0067\u0074\u0068\u0020\u0061\u0070\u0070\u0065\u0061\u0072\u0073\u0020\u0074\u006f\u0020\u0062e\u0020i\u006e\u0020\u0062\u0069\u0074\u0073 ra\u0074\u0068\u0065\u0072\u0020\u0074\u0068\u0061\u006e\u0020\u0062\u0079te\u0073 \u002d\u0020\u0061\u0073s\u0075m\u0069n\u0067\u0020b\u0069\u0074s \u0028\u0025\u0064\u0029",_ce .Length );
 65 | _ce .Length /=8;};if _ce .Length !=0&&_ce .Length !=16{return nil ,_b .Errorf ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0041\u0045\u0053\u0056\u0032\u0020\u0063\u0072\u0079\u0070\u0074\u0020\u0066\u0069\u006c\u0074e\u0072\u0020\u006c\u0065\u006eg\u0074\u0068 \u0028\u0025\u0064\u0029",_ce .Length );
 66 | };return filterAESV2 {},nil ;};
 67 | 
 68 | // NewFilterAESV3 creates an AES-based filter with a 256 bit key (AESV3).
 69 | func NewFilterAESV3 ()Filter {_ced ,_f :=_ae (FilterDict {});if _f !=nil {_bg .Log .Error ("E\u0052\u0052\u004f\u0052\u003a\u0020\u0063\u006f\u0075l\u0064\u0020\u006e\u006f\u0074\u0020\u0063re\u0061\u0074\u0065\u0020A\u0045\u0053\u0020\u0056\u0033\u0020\u0063\u0072\u0079pt\u0020\u0066i\u006c\u0074\u0065\u0072\u003a\u0020\u0025\u0076",_f );
 70 | return filterAESV3 {};};return _ced ;};type filterIdentity struct{};
 71 | 
 72 | // DecryptBytes implements Filter interface.
 73 | func (filterV2 )DecryptBytes (buf []byte ,okey []byte )([]byte ,error ){_cbg ,_bfc :=_de .NewCipher (okey );if _bfc !=nil {return nil ,_bfc ;};_bg .Log .Trace ("\u0052\u00434\u0020\u0044\u0065c\u0072\u0079\u0070\u0074\u003a\u0020\u0025\u0020\u0078",buf );
 74 | _cbg .XORKeyStream (buf ,buf );_bg .Log .Trace ("\u0074o\u003a\u0020\u0025\u0020\u0078",buf );return buf ,nil ;};
 75 | 
 76 | // MakeKey implements Filter interface.
 77 | func (_fc filterV2 )MakeKey (objNum ,genNum uint32 ,ekey []byte )([]byte ,error ){return _gcc (objNum ,genNum ,ekey ,false );};
 78 | 
 79 | // KeyLength implements Filter interface.
 80 | func (filterAESV2 )KeyLength ()int {return 128/8};
 81 | 
 82 | // KeyLength implements Filter interface.
 83 | func (_feg filterV2 )KeyLength ()int {return _feg ._dce };func (filterIdentity )MakeKey (objNum ,genNum uint32 ,fkey []byte )([]byte ,error ){return fkey ,nil };
 84 | 
 85 | // PDFVersion implements Filter interface.
 86 | func (filterAESV2 )PDFVersion ()[2]int {return [2]int {1,5}};func (filterIdentity )Name ()string {return "\u0049\u0064\u0065\u006e\u0074\u0069\u0074\u0079"};
 87 | 
 88 | // Filter is a common interface for crypt filter methods.
 89 | type Filter interface{
 90 | 
 91 | // Name returns a name of the filter that should be used in CFM field of Encrypt dictionary.
 92 | Name ()string ;
 93 | 
 94 | // KeyLength returns a length of the encryption key in bytes.
 95 | KeyLength ()int ;
 96 | 
 97 | // PDFVersion reports the minimal version of PDF document that introduced this filter.
 98 | PDFVersion ()[2]int ;
 99 | 
100 | // HandlerVersion reports V and R parameters that should be used for this filter.
101 | HandlerVersion ()(V ,R int );
102 | 
103 | // MakeKey generates a object encryption key based on file encryption key and object numbers.
104 | // Used only for legacy filters - AESV3 doesn't change the key for each object.
105 | MakeKey (_cf ,_bad uint32 ,_bba []byte )([]byte ,error );
106 | 
107 | // EncryptBytes encrypts a buffer using object encryption key, as returned by MakeKey.
108 | // Implementation may reuse a buffer and encrypt data in-place.
109 | EncryptBytes (_be []byte ,_ab []byte )([]byte ,error );
110 | 
111 | // DecryptBytes decrypts a buffer using object encryption key, as returned by MakeKey.
112 | // Implementation may reuse a buffer and decrypt data in-place.
113 | DecryptBytes (_da []byte ,_cfc []byte )([]byte ,error );};func (filterIdentity )HandlerVersion ()(V ,R int ){return ;};
114 | 
115 | // KeyLength implements Filter interface.
116 | func (filterAESV3 )KeyLength ()int {return 256/8};func (filterAES )EncryptBytes (buf []byte ,okey []byte )([]byte ,error ){_afb ,_bb :=_g .NewCipher (okey );if _bb !=nil {return nil ,_bb ;};_bg .Log .Trace ("A\u0045\u0053\u0020\u0045nc\u0072y\u0070\u0074\u0020\u0028\u0025d\u0029\u003a\u0020\u0025\u0020\u0078",len (buf ),buf );
117 | const _fb =_g .BlockSize ;_dd :=_fb -len (buf )%_fb ;for _ba :=0;_ba < _dd ;_ba ++{buf =append (buf ,byte (_dd ));};_bg .Log .Trace ("\u0050a\u0064d\u0065\u0064\u0020\u0074\u006f \u0025\u0064 \u0062\u0079\u0074\u0065\u0073",len (buf ));_fd :=make ([]byte ,_fb +len (buf ));
118 | _db :=_fd [:_fb ];if _ ,_bfg :=_d .ReadFull (_afe .Reader ,_db );_bfg !=nil {return nil ,_bfg ;};_gba :=_ac .NewCBCEncrypter (_afb ,_db );_gba .CryptBlocks (_fd [_fb :],buf );buf =_fd ;_bg .Log .Trace ("\u0074\u006f\u0020(\u0025\u0064\u0029\u003a\u0020\u0025\u0020\u0078",len (buf ),buf );
119 | return buf ,nil ;};type filterFunc func (_ca FilterDict )(Filter ,error );func (filterIdentity )DecryptBytes (p []byte ,okey []byte )([]byte ,error ){return p ,nil };func (filterIdentity )PDFVersion ()[2]int {return [2]int {}};
120 | 
121 | // Name implements Filter interface.
122 | func (filterAESV2 )Name ()string {return "\u0041\u0045\u0053V\u0032"};var _ Filter =filterAESV2 {};func (filterIdentity )EncryptBytes (p []byte ,okey []byte )([]byte ,error ){return p ,nil };
123 | 
124 | // NewIdentity creates an identity filter that bypasses all data without changes.
125 | func NewIdentity ()Filter {return filterIdentity {}};func (filterAES )DecryptBytes (buf []byte ,okey []byte )([]byte ,error ){_bc ,_ag :=_g .NewCipher (okey );if _ag !=nil {return nil ,_ag ;};if len (buf )< 16{_bg .Log .Debug ("\u0045R\u0052\u004f\u0052\u0020\u0041\u0045\u0053\u0020\u0069\u006e\u0076a\u006c\u0069\u0064\u0020\u0062\u0075\u0066\u0020\u0025\u0073",buf );
126 | return buf ,_b .Errorf ("\u0041\u0045\u0053\u003a B\u0075\u0066\u0020\u006c\u0065\u006e\u0020\u003c\u0020\u0031\u0036\u0020\u0028\u0025d\u0029",len (buf ));};_gbb :=buf [:16];buf =buf [16:];if len (buf )%16!=0{_bg .Log .Debug ("\u0020\u0069\u0076\u0020\u0028\u0025\u0064\u0029\u003a\u0020\u0025\u0020\u0078",len (_gbb ),_gbb );
127 | _bg .Log .Debug ("\u0062\u0075\u0066\u0020\u0028\u0025\u0064\u0029\u003a\u0020\u0025\u0020\u0078",len (buf ),buf );return buf ,_b .Errorf ("\u0041\u0045\u0053\u0020\u0062\u0075\u0066\u0020\u006c\u0065\u006e\u0067\u0074\u0068\u0020\u006e\u006f\u0074\u0020\u006d\u0075\u006c\u0074\u0069p\u006c\u0065\u0020\u006f\u0066 \u0031\u0036 \u0028\u0025\u0064\u0029",len (buf ));
128 | };_bce :=_ac .NewCBCDecrypter (_bc ,_gbb );_bg .Log .Trace ("A\u0045\u0053\u0020\u0044ec\u0072y\u0070\u0074\u0020\u0028\u0025d\u0029\u003a\u0020\u0025\u0020\u0078",len (buf ),buf );_bg .Log .Trace ("\u0063\u0068\u006f\u0070\u0020\u0041\u0045\u0053\u0020\u0044\u0065c\u0072\u0079\u0070\u0074\u0020\u0028\u0025\u0064\u0029\u003a \u0025\u0020\u0078",len (buf ),buf );
129 | _bce .CryptBlocks (buf ,buf );_bg .Log .Trace ("\u0074\u006f\u0020(\u0025\u0064\u0029\u003a\u0020\u0025\u0020\u0078",len (buf ),buf );if len (buf )==0{_bg .Log .Trace ("\u0045\u006d\u0070\u0074\u0079\u0020b\u0075\u0066\u002c\u0020\u0072\u0065\u0074\u0075\u0072\u006e\u0069\u006e\u0067 \u0065\u006d\u0070\u0074\u0079\u0020\u0073t\u0072\u0069\u006e\u0067");
130 | return buf ,nil ;};_agd :=int (buf [len (buf )-1]);if _agd > len (buf ){_bg .Log .Debug ("\u0049\u006c\u006c\u0065g\u0061\u006c\u0020\u0070\u0061\u0064\u0020\u006c\u0065\u006eg\u0074h\u0020\u0028\u0025\u0064\u0020\u003e\u0020%\u0064\u0029",_agd ,len (buf ));
131 | return buf ,_b .Errorf ("\u0069n\u0076a\u006c\u0069\u0064\u0020\u0070a\u0064\u0020l\u0065\u006e\u0067\u0074\u0068");};buf =buf [:len (buf )-_agd ];return buf ,nil ;};type filterAESV2 struct{filterAES };func _agc (_fdg string ,_cgc filterFunc ){if _ ,_ccg :=_bca [_fdg ];
132 | _ccg {panic ("\u0061l\u0072e\u0061\u0064\u0079\u0020\u0072e\u0067\u0069s\u0074\u0065\u0072\u0065\u0064");};_bca [_fdg ]=_cgc ;};func _gcc (_ef ,_afg uint32 ,_ggd []byte ,_fe bool )([]byte ,error ){_dcg :=make ([]byte ,len (_ggd )+5);copy (_dcg ,_ggd );
133 | for _cb :=0;_cb < 3;_cb ++{_cc :=byte ((_ef >>uint32 (8*_cb ))&0xff);_dcg [_cb +len (_ggd )]=_cc ;};for _ge :=0;_ge < 2;_ge ++{_fba :=byte ((_afg >>uint32 (8*_ge ))&0xff);_dcg [_ge +len (_ggd )+3]=_fba ;};if _fe {_dcg =append (_dcg ,0x73);_dcg =append (_dcg ,0x41);
134 | _dcg =append (_dcg ,0x6C);_dcg =append (_dcg ,0x54);};_gcb :=_af .New ();_gcb .Write (_dcg );_ddb :=_gcb .Sum (nil );if len (_ggd )+5< 16{return _ddb [0:len (_ggd )+5],nil ;};return _ddb ,nil ;};var _ Filter =filterAESV3 {};


--------------------------------------------------------------------------------
/fjson/fjson.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | // Package fjson provides support for loading PDF form field data from JSON data/files.
13 | package fjson ;import (_g "encoding/json";_d "github.com/unidoc/unipdf/v4/common";_a "github.com/unidoc/unipdf/v4/core";_c "github.com/unidoc/unipdf/v4/model";_gc "io";_f "os";);
14 | 
15 | // LoadFromPDFFile loads form field data from a PDF file.
16 | func LoadFromPDFFile (filePath string )(*FieldData ,error ){_dfd ,_dca :=_f .Open (filePath );if _dca !=nil {return nil ,_dca ;};defer _dfd .Close ();return LoadFromPDF (_dfd );};
17 | 
18 | // LoadFromJSONFile loads form field data from a JSON file.
19 | func LoadFromJSONFile (filePath string )(*FieldData ,error ){_ef ,_cc :=_f .Open (filePath );if _cc !=nil {return nil ,_cc ;};defer _ef .Close ();return LoadFromJSON (_ef );};
20 | 
21 | // SetImageFromFile assign image file to a specific field identified by fieldName.
22 | func (_acf *FieldData )SetImageFromFile (fieldName string ,imagePath string ,opt []string )error {_fc ,_bg :=_f .Open (imagePath );if _bg !=nil {return _bg ;};defer _fc .Close ();_dff ,_bg :=_c .ImageHandling .Read (_fc );if _bg !=nil {_d .Log .Error ("\u0045\u0072\u0072or\u0020\u006c\u006f\u0061\u0064\u0069\u006e\u0067\u0020\u0069\u006d\u0061\u0067\u0065\u003a\u0020\u0025\u0073",_bg );
23 | return _bg ;};return _acf .SetImage (fieldName ,_dff ,opt );};
24 | 
25 | // FieldValues implements model.FieldValueProvider interface.
26 | func (_fea *FieldData )FieldValues ()(map[string ]_a .PdfObject ,error ){_aea :=make (map[string ]_a .PdfObject );for _ ,_cad :=range _fea ._ae {if len (_cad .Value )> 0{_aea [_cad .Name ]=_a .MakeString (_cad .Value );};};return _aea ,nil ;};
27 | 
28 | // LoadFromJSON loads JSON form data from `r`.
29 | func LoadFromJSON (r _gc .Reader )(*FieldData ,error ){var _b FieldData ;_dc :=_g .NewDecoder (r ).Decode (&_b ._ae );if _dc !=nil {return nil ,_dc ;};return &_b ,nil ;};
30 | 
31 | // FieldImageValues implements model.FieldImageProvider interface.
32 | func (_ce *FieldData )FieldImageValues ()(map[string ]*_c .Image ,error ){_aad :=make (map[string ]*_c .Image );for _ ,_eecb :=range _ce ._ae {if _eecb .ImageValue !=nil {_aad [_eecb .Name ]=_eecb .ImageValue ;};};return _aad ,nil ;};
33 | 
34 | // JSON returns the field data as a string in JSON format.
35 | func (_aca FieldData )JSON ()(string ,error ){_fef ,_gge :=_g .MarshalIndent (_aca ._ae ,"","\u0020\u0020\u0020\u0020");return string (_fef ),_gge ;};type fieldValue struct{Name string `json:"name"`;Value string `json:"value"`;ImageValue *_c .Image `json:"-"`;
36 | 
37 | 
38 | // Options lists allowed values if present.
39 | Options []string `json:"options,omitempty"`;};
40 | 
41 | // FieldData represents form field data loaded from JSON file.
42 | type FieldData struct{_ae []fieldValue };
43 | 
44 | // SetImage assign model.Image to a specific field identified by fieldName.
45 | func (_cb *FieldData )SetImage (fieldName string ,img *_c .Image ,opt []string )error {_ecc :=fieldValue {Name :fieldName ,ImageValue :img ,Options :opt };_cb ._ae =append (_cb ._ae ,_ecc );return nil ;};
46 | 
47 | // LoadFromPDF loads form field data from a PDF.
48 | func LoadFromPDF (rs _gc .ReadSeeker )(*FieldData ,error ){_dd ,_eb :=_c .NewPdfReader (rs );if _eb !=nil {return nil ,_eb ;};if _dd .AcroForm ==nil {return nil ,nil ;};var _aef []fieldValue ;_ge :=_dd .AcroForm .AllFields ();for _ ,_ac :=range _ge {var _aa []string ;
49 | _dcf :=make (map[string ]struct{});_ca ,_ag :=_ac .FullName ();if _ag !=nil {return nil ,_ag ;};if _acg ,_ed :=_ac .V .(*_a .PdfObjectString );_ed {_aef =append (_aef ,fieldValue {Name :_ca ,Value :_acg .Decoded ()});continue ;};var _bc string ;for _ ,_cg :=range _ac .Annotations {_ccb ,_gg :=_a .GetName (_cg .AS );
50 | if _gg {_bc =_ccb .String ();};_ga ,_cf :=_a .GetDict (_cg .AP );if !_cf {continue ;};_be ,_ :=_a .GetDict (_ga .Get ("\u004e"));for _ ,_fa :=range _be .Keys (){_ea :=_fa .String ();if _ ,_fe :=_dcf [_ea ];!_fe {_aa =append (_aa ,_ea );_dcf [_ea ]=struct{}{};
51 | };};_aaa ,_ :=_a .GetDict (_ga .Get ("\u0044"));for _ ,_ab :=range _aaa .Keys (){_db :=_ab .String ();if _ ,_dde :=_dcf [_db ];!_dde {_aa =append (_aa ,_db );_dcf [_db ]=struct{}{};};};};_ec :=fieldValue {Name :_ca ,Value :_bc ,Options :_aa };_aef =append (_aef ,_ec );
52 | };_eec :=FieldData {_ae :_aef };return &_eec ,nil ;};


--------------------------------------------------------------------------------
/go.mod:
--------------------------------------------------------------------------------
 1 | module github.com/unidoc/unipdf/v4
 2 | 
 3 | go 1.20
 4 | 
 5 | require (
 6 | 	github.com/adrg/sysfont v0.1.2
 7 | 	github.com/boombuler/barcode v1.0.2
 8 | 	github.com/gabriel-vasile/mimetype v1.4.8
 9 | 	github.com/gorilla/i18n v0.0.0-20150820051429-8b358169da46
10 | 	github.com/stretchr/testify v1.10.0
11 | 	github.com/trimmer-io/go-xmp v1.0.0
12 | 	github.com/unidoc/freetype v0.2.3
13 | 	github.com/unidoc/garabic v0.0.0-20220702200334-8c7cb25baa11
14 | 	github.com/unidoc/pkcs7 v0.2.0
15 | 	github.com/unidoc/timestamp v0.0.0-20200412005513-91597fd3793a
16 | 	github.com/unidoc/unichart v0.4.0
17 | 	github.com/unidoc/unitype v0.5.1
18 | 	golang.org/x/crypto v0.33.0
19 | 	golang.org/x/image v0.24.0
20 | 	golang.org/x/net v0.35.0
21 | 	golang.org/x/text v0.22.0
22 | 	golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da
23 | )
24 | 
25 | require (
26 | 	github.com/adrg/strutil v0.3.1 // indirect
27 | 	github.com/adrg/xdg v0.5.3 // indirect
28 | 	github.com/davecgh/go-spew v1.1.1 // indirect
29 | 	github.com/kr/text v0.2.0 // indirect
30 | 	github.com/pmezard/go-difflib v1.0.0 // indirect
31 | 	github.com/sirupsen/logrus v1.9.3 // indirect
32 | 	golang.org/x/sys v0.30.0 // indirect
33 | 	gopkg.in/yaml.v3 v3.0.1 // indirect
34 | )
35 | 


--------------------------------------------------------------------------------
/go.sum:
--------------------------------------------------------------------------------
 1 | github.com/adrg/strutil v0.2.2/go.mod h1:EF2fjOFlGTepljfI+FzgTG13oXthR7ZAil9/aginnNQ=
 2 | github.com/adrg/strutil v0.3.1 h1:OLvSS7CSJO8lBii4YmBt8jiK9QOtB9CzCzwl4Ic/Fz4=
 3 | github.com/adrg/strutil v0.3.1/go.mod h1:8h90y18QLrs11IBffcGX3NW/GFBXCMcNg4M7H6MspPA=
 4 | github.com/adrg/sysfont v0.1.2 h1:MSU3KREM4RhsQ+7QgH7wPEPTgAgBIz0Hw6Nd4u7QgjE=
 5 | github.com/adrg/sysfont v0.1.2/go.mod h1:6d3l7/BSjX9VaeXWJt9fcrftFaD/t7l11xgSywCPZGk=
 6 | github.com/adrg/xdg v0.3.0/go.mod h1:7I2hH/IT30IsupOpKZ5ue7/qNi3CoKzD6tL3HwpaRMQ=
 7 | github.com/adrg/xdg v0.5.3 h1:xRnxJXne7+oWDatRhR1JLnvuccuIeCoBu2rtuLqQB78=
 8 | github.com/adrg/xdg v0.5.3/go.mod h1:nlTsY+NNiCBGCK2tpm09vRqfVzrc2fLmXGpBLF0zlTQ=
 9 | github.com/boombuler/barcode v1.0.2 h1:79yrbttoZrLGkL/oOI8hBrUKucwOL0oOjUgEguGMcJ4=
10 | github.com/boombuler/barcode v1.0.2/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
11 | github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
12 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
13 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
14 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
15 | github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
16 | github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
17 | github.com/gorilla/i18n v0.0.0-20150820051429-8b358169da46 h1:N+R2A3fGIr5GucoRMu2xpqyQWQlfY31orbofBCdjMz8=
18 | github.com/gorilla/i18n v0.0.0-20150820051429-8b358169da46/go.mod h1:2Yoiy15Cf7Q3NFwfaJquh7Mk1uGI09ytcD7CUhn8j7s=
19 | github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
20 | github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
21 | github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
22 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
23 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
24 | github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
25 | github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
26 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
27 | github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
28 | github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
29 | github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
30 | github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
31 | github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
32 | github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
33 | github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
34 | github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
35 | github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
36 | github.com/trimmer-io/go-xmp v1.0.0 h1:zY8bolSga5kOjBAaHS6hrdxLgEoYuT875xTy0QDwZWs=
37 | github.com/trimmer-io/go-xmp v1.0.0/go.mod h1:Aaptr9sp1lLv7UnCAdQ+gSHZyY2miYaKmcNVj7HRBwA=
38 | github.com/unidoc/freetype v0.2.3 h1:uPqW+AY0vXN6K2tvtg8dMAtHTEvvHTN52b72XpZU+3I=
39 | github.com/unidoc/freetype v0.2.3/go.mod h1:mJ/Q7JnqEoWtajJVrV6S1InbRv0K/fJerPB5SQs32KI=
40 | github.com/unidoc/garabic v0.0.0-20220702200334-8c7cb25baa11 h1:kExUKrbi429KdVVuAc85z4P+W/Rk4bjGWB5KzZLl/l8=
41 | github.com/unidoc/garabic v0.0.0-20220702200334-8c7cb25baa11/go.mod h1:SX63w9Ww4+Z7E96B01OuG59SleQUb+m+dmapZ8o1Jac=
42 | github.com/unidoc/pkcs7 v0.0.0-20200411230602-d883fd70d1df/go.mod h1:UEzOZUEpJfDpywVJMUT8QiugqEZC29pDq7kdIZhWCr8=
43 | github.com/unidoc/pkcs7 v0.2.0 h1:0Y0RJR5Zu7OuD+/l7bODXARn6b8Ev2G4A8lI4rzy9kg=
44 | github.com/unidoc/pkcs7 v0.2.0/go.mod h1:UEzOZUEpJfDpywVJMUT8QiugqEZC29pDq7kdIZhWCr8=
45 | github.com/unidoc/timestamp v0.0.0-20200412005513-91597fd3793a h1:RLtvUhe4DsUDl66m7MJ8OqBjq8jpWBXPK6/RKtqeTkc=
46 | github.com/unidoc/timestamp v0.0.0-20200412005513-91597fd3793a/go.mod h1:j+qMWZVpZFTvDey3zxUkSgPJZEX33tDgU/QIA0IzCUw=
47 | github.com/unidoc/unichart v0.4.0 h1:uXk9ZjbqzKb8Lt2Qv2oM9D2ftNRXvezPevgxQhsTQys=
48 | github.com/unidoc/unichart v0.4.0/go.mod h1:9QsE8RbS0fE7ndHNroeCEFkRPqqk47Qsoj6QSAtcwN0=
49 | github.com/unidoc/unitype v0.5.1 h1:UwTX15K6bktwKocWVvLoijIeu4JAVEAIeFqMOjvxqQs=
50 | github.com/unidoc/unitype v0.5.1/go.mod h1:3dxbRL+f1otNqFQIRHho8fxdg3CcUKrqS8w1SXTsqcI=
51 | golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
52 | golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
53 | golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
54 | golang.org/x/image v0.24.0 h1:AN7zRgVsbvmTfNyqIbbOraYL8mSwcKncEj8ofjgzcMQ=
55 | golang.org/x/image v0.24.0/go.mod h1:4b/ITuLfqYq1hqZcjofwctIhi7sZh2WaCjvsBNjjya8=
56 | golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
57 | golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
58 | golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
59 | golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
60 | golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
61 | golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
62 | golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
63 | golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
64 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
65 | golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da h1:noIWHXmPHxILtqtCOPIhSt0ABwskkZKjD3bXGnZGpNY=
66 | golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=
67 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
68 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
69 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
70 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
71 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
72 | 


--------------------------------------------------------------------------------
/internal/bitwise/bitwise.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | package bitwise ;import (_c "encoding/binary";_aa "errors";_a "fmt";_d "github.com/unidoc/unipdf/v4/common";_e "github.com/unidoc/unipdf/v4/internal/jbig2/errors";_f "io";);func (_af *BufferedWriter )tryGrowByReslice (_cgea int )bool {if _bf :=len (_af ._fd );
13 | _cgea <=cap (_af ._fd )-_bf {_af ._fd =_af ._fd [:_bf +_cgea ];return true ;};return false ;};func (_gdf *Reader )ConsumeRemainingBits ()(uint64 ,error ){if _gdf ._gag !=0{return _gdf .ReadBits (_gdf ._gag );};return 0,nil ;};func (_gdg *Writer )UseMSB ()bool {return _gdg ._dgc };
14 | func (_bbbg *Writer )byteCapacity ()int {_dae :=len (_bbbg ._gggg )-_bbbg ._debf ;if _bbbg ._ffba !=0{_dae --;};return _dae ;};func (_dgd *Writer )WriteByte (c byte )error {return _dgd .writeByte (c )};func (_gef *BufferedWriter )WriteBits (bits uint64 ,number int )(_gfc int ,_deb error ){const _fe ="\u0042u\u0066\u0066\u0065\u0072e\u0064\u0057\u0072\u0069\u0074e\u0072.\u0057r\u0069\u0074\u0065\u0072\u0042\u0069\u0074s";
15 | if number < 0||number > 64{return 0,_e .Errorf (_fe ,"\u0062i\u0074\u0073 \u006e\u0075\u006db\u0065\u0072\u0020\u006d\u0075\u0073\u0074 \u0062\u0065\u0020\u0069\u006e\u0020r\u0061\u006e\u0067\u0065\u0020\u003c\u0030\u002c\u0036\u0034\u003e,\u0020\u0069\u0073\u003a\u0020\u0027\u0025\u0064\u0027",number );
16 | };_cf :=number /8;if _cf > 0{_fbe :=number -_cf *8;for _eg :=_cf -1;_eg >=0;_eg --{_fbb :=byte ((bits >>uint (_eg *8+_fbe ))&0xff);if _deb =_gef .WriteByte (_fbb );_deb !=nil {return _gfc ,_e .Wrapf (_deb ,_fe ,"\u0062\u0079\u0074\u0065\u003a\u0020\u0027\u0025\u0064\u0027",_cf -_eg +1);
17 | };};number -=_cf *8;if number ==0{return _cf ,nil ;};};var _ce int ;for _gge :=0;_gge < number ;_gge ++{if _gef ._fg {_ce =int ((bits >>uint (number -1-_gge ))&0x1);}else {_ce =int (bits &0x1);bits >>=1;};if _deb =_gef .WriteBit (_ce );_deb !=nil {return _gfc ,_e .Wrapf (_deb ,_fe ,"\u0062i\u0074\u003a\u0020\u0025\u0064",_gge );
18 | };};return _cf ,nil ;};var _ _f .Writer =&BufferedWriter {};func (_ee *BufferedWriter )Write (d []byte )(int ,error ){_ee .expandIfNeeded (len (d ));if _ee ._ag ==0{return _ee .writeFullBytes (d ),nil ;};return _ee .writeShiftedBytes (d ),nil ;};func (_gad *Reader )AbsoluteLength ()uint64 {return uint64 (len (_gad ._cdb ._ffc ))};
19 | func (_db *BufferedWriter )ResetBitIndex (){_db ._ag =0};func (_ggb *Reader )Align ()(_cgc byte ){_cgc =_ggb ._gag ;_ggb ._gag =0;return _cgc };func (_eae *Reader )ReadByte ()(byte ,error ){if _eae ._gag ==0{return _eae .readBufferByte ();};return _eae .readUnalignedByte ();
20 | };type readerSource struct{_ffc []byte ;_ffe int ;_ba int ;};func (_gf *BufferedWriter )Len ()int {return _gf .byteCapacity ()};func (_aga *BufferedWriter )writeByte (_gdc byte ){switch {case _aga ._ag ==0:_aga ._fd [_aga ._ad ]=_gdc ;_aga ._ad ++;case _aga ._fg :_aga ._fd [_aga ._ad ]|=_gdc >>_aga ._ag ;
21 | _aga ._ad ++;_aga ._fd [_aga ._ad ]=byte (uint16 (_gdc )<<(8-_aga ._ag )&0xff);default:_aga ._fd [_aga ._ad ]|=byte (uint16 (_gdc )<<_aga ._ag &0xff);_aga ._ad ++;_aga ._fd [_aga ._ad ]=_gdc >>(8-_aga ._ag );};};func (_ccg *Reader )Mark (){_ccg ._cc =_ccg ._ef ;
22 | _ccg ._bgcd =_ccg ._gag ;_ccg ._da =_ccg ._dba ;_ccg ._acd =_ccg ._ac ;};func NewWriter (data []byte )*Writer {return &Writer {_gggg :data }};func (_fgc *BufferedWriter )fullOffset ()int {_fa :=_fgc ._ad ;if _fgc ._ag !=0{_fa ++;};return _fa ;};func (_adc *BufferedWriter )Reset (){_adc ._fd =_adc ._fd [:0];
23 | _adc ._ad =0;_adc ._ag =0};func (_dc *Reader )Read (p []byte )(_dfd int ,_gddc error ){if _dc ._gag ==0{return _dc .read (p );};for ;_dfd < len (p );_dfd ++{if p [_dfd ],_gddc =_dc .readUnalignedByte ();_gddc !=nil {return 0,_gddc ;};};return _dfd ,nil ;
24 | };type BinaryWriter interface{BitWriter ;_f .Writer ;_f .ByteWriter ;Data ()[]byte ;};func (_aff *Reader )RelativePosition ()int64 {return _aff ._ef };func (_fc *BufferedWriter )WriteByte (bt byte )error {if _fc ._ad > len (_fc ._fd )-1||(_fc ._ad ==len (_fc ._fd )-1&&_fc ._ag !=0){_fc .expandIfNeeded (1);
25 | };_fc .writeByte (bt );return nil ;};func (_gade *Writer )writeByte (_cdg byte )error {if _gade ._debf > len (_gade ._gggg )-1{return _f .EOF ;};if _gade ._debf ==len (_gade ._gggg )-1&&_gade ._ffba !=0{return _f .EOF ;};if _gade ._ffba ==0{_gade ._gggg [_gade ._debf ]=_cdg ;
26 | _gade ._debf ++;return nil ;};if _gade ._dgc {_gade ._gggg [_gade ._debf ]|=_cdg >>_gade ._ffba ;_gade ._debf ++;_gade ._gggg [_gade ._debf ]=byte (uint16 (_cdg )<<(8-_gade ._ffba )&0xff);}else {_gade ._gggg [_gade ._debf ]|=byte (uint16 (_cdg )<<_gade ._ffba &0xff);
27 | _gade ._debf ++;_gade ._gggg [_gade ._debf ]=_cdg >>(8-_gade ._ffba );};return nil ;};func (_eef *Writer )Write (p []byte )(int ,error ){if len (p )> _eef .byteCapacity (){return 0,_f .EOF ;};for _ ,_cba :=range p {if _cff :=_eef .writeByte (_cba );_cff !=nil {return 0,_cff ;
28 | };};return len (p ),nil ;};func (_abc *Writer )Data ()[]byte {return _abc ._gggg };func (_dca *Writer )FinishByte (){if _dca ._ffba ==0{return ;};_dca ._ffba =0;_dca ._debf ++;};func (_bb *Reader )ReadUint32 ()(uint32 ,error ){_bbb :=make ([]byte ,4);_ ,_fcf :=_bb .Read (_bbb );
29 | if _fcf !=nil {return 0,_fcf ;};return _c .BigEndian .Uint32 (_bbb ),nil ;};func (_bdb *Writer )WriteBit (bit int )error {switch bit {case 0,1:return _bdb .writeBit (uint8 (bit ));};return _e .Error ("\u0057\u0072\u0069\u0074\u0065\u0042\u0069\u0074","\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0062\u0069\u0074\u0020v\u0061\u006c\u0075\u0065");
30 | };func (_agf *Reader )BitPosition ()int {return int (_agf ._gag )};func (_gg *BufferedWriter )SkipBits (skip int )error {if skip ==0{return nil ;};_bg :=int (_gg ._ag )+skip ;if _bg >=0&&_bg < 8{_gg ._ag =uint8 (_bg );return nil ;};_bg =int (_gg ._ag )+_gg ._ad *8+skip ;
31 | if _bg < 0{return _e .Errorf ("\u0057r\u0069t\u0065\u0072\u002e\u0053\u006b\u0069\u0070\u0042\u0069\u0074\u0073","\u0069n\u0064e\u0078\u0020\u006f\u0075\u0074 \u006f\u0066 \u0072\u0061\u006e\u0067\u0065");};_gb :=_bg /8;_be :=_bg %8;_gg ._ag =uint8 (_be );
32 | if _ga :=_gb -_gg ._ad ;_ga > 0&&len (_gg ._fd )-1< _gb {if _gg ._ag !=0{_ga ++;};_gg .expandIfNeeded (_ga );};_gg ._ad =_gb ;return nil ;};func NewWriterMSB (data []byte )*Writer {return &Writer {_gggg :data ,_dgc :true }};func (_gff *Reader )ReadBits (n byte )(_bgd uint64 ,_abe error ){if n < _gff ._gag {_dd :=_gff ._gag -n ;
33 | _bgd =uint64 (_gff ._dba >>_dd );_gff ._dba &=1<<_dd -1;_gff ._gag =_dd ;return _bgd ,nil ;};if n > _gff ._gag {if _gff ._gag > 0{_bgd =uint64 (_gff ._dba );n -=_gff ._gag ;};for n >=8{_bec ,_ebf :=_gff .readBufferByte ();if _ebf !=nil {return 0,_ebf ;
34 | };_bgd =_bgd <<8+uint64 (_bec );n -=8;};if n > 0{if _gff ._dba ,_abe =_gff .readBufferByte ();_abe !=nil {return 0,_abe ;};_fdg :=8-n ;_bgd =_bgd <<n +uint64 (_gff ._dba >>_fdg );_gff ._dba &=1<<_fdg -1;_gff ._gag =_fdg ;}else {_gff ._gag =0;};return _bgd ,nil ;
35 | };_gff ._gag =0;return uint64 (_gff ._dba ),nil ;};func (_ebc *Reader )read (_ed []byte )(int ,error ){if _ebc ._ef >=int64 (_ebc ._cdb ._ba ){return 0,_f .EOF ;};_ebc ._gc =-1;_dbac :=copy (_ed ,_ebc ._cdb ._ffc [(int64 (_ebc ._cdb ._ffe )+_ebc ._ef ):(_ebc ._cdb ._ffe +_ebc ._cdb ._ba )]);
36 | _ebc ._ef +=int64 (_dbac );return _dbac ,nil ;};func (_bbc *Writer )ResetBit (){_bbc ._ffba =0};type BufferedWriter struct{_fd []byte ;_ag uint8 ;_ad int ;_fg bool ;};var _ BinaryWriter =&BufferedWriter {};type Writer struct{_gggg []byte ;_ffba uint8 ;
37 | _debf int ;_dgc bool ;};func BufferedMSB ()*BufferedWriter {return &BufferedWriter {_fg :true }};var _ _f .ByteWriter =&BufferedWriter {};func (_cdf *Reader )Seek (offset int64 ,whence int )(int64 ,error ){_cdf ._gc =-1;_cdf ._gag =0;_cdf ._dba =0;_cdf ._ac =0;
38 | var _bc int64 ;switch whence {case _f .SeekStart :_bc =offset ;case _f .SeekCurrent :_bc =_cdf ._ef +offset ;case _f .SeekEnd :_bc =int64 (_cdf ._cdb ._ba )+offset ;default:return 0,_aa .New ("\u0072\u0065\u0061de\u0072\u002e\u0052\u0065\u0061\u0064\u0065\u0072\u002eS\u0065e\u006b:\u0020i\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0077\u0068\u0065\u006e\u0063\u0065");
39 | };if _bc < 0{return 0,_aa .New ("\u0072\u0065a\u0064\u0065\u0072\u002eR\u0065\u0061d\u0065\u0072\u002e\u0053\u0065\u0065\u006b\u003a \u006e\u0065\u0067\u0061\u0074\u0069\u0076\u0065\u0020\u0070\u006f\u0073i\u0074\u0069\u006f\u006e");};_cdf ._ef =_bc ;_cdf ._gag =0;
40 | return _bc ,nil ;};func (_cd *BufferedWriter )byteCapacity ()int {_cge :=len (_cd ._fd )-_cd ._ad ;if _cd ._ag !=0{_cge --;};return _cge ;};func (_ca *BufferedWriter )WriteBit (bit int )error {if bit !=1&&bit !=0{return _e .Errorf ("\u0042\u0075\u0066fe\u0072\u0065\u0064\u0057\u0072\u0069\u0074\u0065\u0072\u002e\u0057\u0072\u0069\u0074\u0065\u0042\u0069\u0074","\u0062\u0069\u0074\u0020\u0076\u0061\u006cu\u0065\u0020\u006du\u0073\u0074\u0020\u0062e\u0020\u0069\u006e\u0020\u0072\u0061\u006e\u0067\u0065\u0020\u007b\u0030\u002c\u0031\u007d\u0020\u0062\u0075\u0074\u0020\u0069\u0073\u003a\u0020\u0025\u0064",bit );
41 | };if len (_ca ._fd )-1< _ca ._ad {_ca .expandIfNeeded (1);};_ea :=_ca ._ag ;if _ca ._fg {_ea =7-_ca ._ag ;};_ca ._fd [_ca ._ad ]|=byte (uint16 (bit <<_ea )&0xff);_ca ._ag ++;if _ca ._ag ==8{_ca ._ad ++;_ca ._ag =0;};return nil ;};func (_b *BufferedWriter )Data ()[]byte {return _b ._fd };
42 | func (_cb *BufferedWriter )FinishByte (){if _cb ._ag ==0{return ;};_cb ._ag =0;_cb ._ad ++;};func (_fca *Reader )ReadBool ()(bool ,error ){return _fca .readBool ()};func (_eaa *Reader )ReadBit ()(_aba int ,_beee error ){_fee ,_beee :=_eaa .readBool ();
43 | if _beee !=nil {return 0,_beee ;};if _fee {_aba =1;};return _aba ,nil ;};func (_bd *Writer )SkipBits (skip int )error {const _gcf ="\u0057r\u0069t\u0065\u0072\u002e\u0053\u006b\u0069\u0070\u0042\u0069\u0074\u0073";if skip ==0{return nil ;};_ebe :=int (_bd ._ffba )+skip ;
44 | if _ebe >=0&&_ebe < 8{_bd ._ffba =uint8 (_ebe );return nil ;};_ebe =int (_bd ._ffba )+_bd ._debf *8+skip ;if _ebe < 0{return _e .Errorf (_gcf ,"\u0069n\u0064e\u0078\u0020\u006f\u0075\u0074 \u006f\u0066 \u0072\u0061\u006e\u0067\u0065");};_gadd :=_ebe /8;
45 | _cfe :=_ebe %8;_d .Log .Trace ("\u0053\u006b\u0069\u0070\u0042\u0069\u0074\u0073");_d .Log .Trace ("\u0042\u0069\u0074\u0049\u006e\u0064\u0065\u0078\u003a\u0020\u0027\u0025\u0064\u0027\u0020\u0042\u0079\u0074\u0065\u0049n\u0064\u0065\u0078\u003a\u0020\u0027\u0025\u0064\u0027\u002c\u0020\u0046\u0075\u006c\u006c\u0042\u0069\u0074\u0073\u003a\u0020'\u0025\u0064\u0027\u002c\u0020\u004c\u0065\u006e\u003a\u0020\u0027\u0025\u0064\u0027,\u0020\u0043\u0061p\u003a\u0020\u0027\u0025\u0064\u0027",_bd ._ffba ,_bd ._debf ,int (_bd ._ffba )+(_bd ._debf )*8,len (_bd ._gggg ),cap (_bd ._gggg ));
46 | _d .Log .Trace ("S\u006b\u0069\u0070\u003a\u0020\u0027%\u0064\u0027\u002c\u0020\u0064\u003a \u0027\u0025\u0064\u0027\u002c\u0020\u0062i\u0074\u0049\u006e\u0064\u0065\u0078\u003a\u0020\u0027\u0025d\u0027",skip ,_ebe ,_cfe );_bd ._ffba =uint8 (_cfe );if _gde :=_gadd -_bd ._debf ;
47 | _gde > 0&&len (_bd ._gggg )-1< _gadd {_d .Log .Trace ("\u0042\u0079\u0074e\u0044\u0069\u0066\u0066\u003a\u0020\u0025\u0064",_gde );return _e .Errorf (_gcf ,"\u0069n\u0064e\u0078\u0020\u006f\u0075\u0074 \u006f\u0066 \u0072\u0061\u006e\u0067\u0065");};_bd ._debf =_gadd ;
48 | _d .Log .Trace ("\u0042\u0069\u0074I\u006e\u0064\u0065\u0078:\u0020\u0027\u0025\u0064\u0027\u002c\u0020B\u0079\u0074\u0065\u0049\u006e\u0064\u0065\u0078\u003a\u0020\u0027\u0025\u0064\u0027",_bd ._ffba ,_bd ._debf );return nil ;};func (_bbd *Reader )readUnalignedByte ()(_ffb byte ,_edb error ){_face :=_bbd ._gag ;
49 | _ffb =_bbd ._dba <<(8-_face );_bbd ._dba ,_edb =_bbd .readBufferByte ();if _edb !=nil {return 0,_edb ;};_ffb |=_bbd ._dba >>_face ;_bbd ._dba &=1<<_face -1;return _ffb ,nil ;};func (_gbc *Reader )readBool ()(_bab bool ,_dea error ){if _gbc ._gag ==0{_gbc ._dba ,_dea =_gbc .readBufferByte ();
50 | if _dea !=nil {return false ,_dea ;};_bab =(_gbc ._dba &0x80)!=0;_gbc ._dba ,_gbc ._gag =_gbc ._dba &0x7f,7;return _bab ,nil ;};_gbc ._gag --;_bab =(_gbc ._dba &(1<<_gbc ._gag ))!=0;_gbc ._dba &=1<<_gbc ._gag -1;return _bab ,nil ;};func (_cdbb *Writer )writeBit (_dfda uint8 )error {if len (_cdbb ._gggg )-1< _cdbb ._debf {return _f .EOF ;
51 | };_ged :=_cdbb ._ffba ;if _cdbb ._dgc {_ged =7-_cdbb ._ffba ;};_cdbb ._gggg [_cdbb ._debf ]|=byte (uint16 (_dfda <<_ged )&0xff);_cdbb ._ffba ++;if _cdbb ._ffba ==8{_cdbb ._debf ++;_cdbb ._ffba =0;};return nil ;};type BitWriter interface{WriteBit (_fac int )error ;
52 | WriteBits (_ff uint64 ,_eb int )(_afc int ,_bgc error );FinishByte ();SkipBits (_afb int )error ;};func (_dfa *Reader )NewPartialReader (offset ,length int ,relative bool )(*Reader ,error ){if offset < 0{return nil ,_aa .New ("p\u0061\u0072\u0074\u0069\u0061\u006c\u0020\u0072\u0065\u0061\u0064\u0065\u0072\u0020\u006f\u0066\u0066\u0073e\u0074\u0020\u0063\u0061\u006e\u006e\u006f\u0074\u0020\u0062e \u006e\u0065\u0067a\u0074i\u0076\u0065");
53 | };if relative {offset =_dfa ._cdb ._ffe +offset ;};if length > 0{_ccf :=len (_dfa ._cdb ._ffc );if relative {_ccf =_dfa ._cdb ._ba ;};if offset +length > _ccf {return nil ,_a .Errorf ("\u0070\u0061r\u0074\u0069\u0061l\u0020\u0072\u0065\u0061\u0064e\u0072\u0020\u006f\u0066\u0066se\u0074\u0028\u0025\u0064\u0029\u002b\u006c\u0065\u006e\u0067\u0074\u0068\u0028\u0025\u0064\u0029\u003d\u0025d\u0020i\u0073\u0020\u0067\u0072\u0065\u0061ter\u0020\u0074\u0068\u0061\u006e\u0020\u0074\u0068\u0065\u0020\u006f\u0072ig\u0069n\u0061\u006c\u0020\u0072e\u0061d\u0065r\u0020\u006ce\u006e\u0067th\u003a\u0020\u0025\u0064",offset ,length ,offset +length ,_dfa ._cdb ._ba );
54 | };};if length < 0{_cgf :=len (_dfa ._cdb ._ffc );if relative {_cgf =_dfa ._cdb ._ba ;};length =_cgf -offset ;};return &Reader {_cdb :readerSource {_ffc :_dfa ._cdb ._ffc ,_ba :length ,_ffe :offset }},nil ;};func (_dga *Writer )WriteBits (bits uint64 ,number int )(_gcda int ,_caf error ){const _dfc ="\u0057\u0072\u0069\u0074\u0065\u0072\u002e\u0057\u0072\u0069\u0074\u0065r\u0042\u0069\u0074\u0073";
55 | if number < 0||number > 64{return 0,_e .Errorf (_dfc ,"\u0062i\u0074\u0073 \u006e\u0075\u006db\u0065\u0072\u0020\u006d\u0075\u0073\u0074 \u0062\u0065\u0020\u0069\u006e\u0020r\u0061\u006e\u0067\u0065\u0020\u003c\u0030\u002c\u0036\u0034\u003e,\u0020\u0069\u0073\u003a\u0020\u0027\u0025\u0064\u0027",number );
56 | };if number ==0{return 0,nil ;};_cfc :=number /8;if _cfc > 0{_beed :=number -_cfc *8;for _fdab :=_cfc -1;_fdab >=0;_fdab --{_adce :=byte ((bits >>uint (_fdab *8+_beed ))&0xff);if _caf =_dga .WriteByte (_adce );_caf !=nil {return _gcda ,_e .Wrapf (_caf ,_dfc ,"\u0062\u0079\u0074\u0065\u003a\u0020\u0027\u0025\u0064\u0027",_cfc -_fdab +1);
57 | };};number -=_cfc *8;if number ==0{return _cfc ,nil ;};};var _agg int ;for _baf :=0;_baf < number ;_baf ++{if _dga ._dgc {_agg =int ((bits >>uint (number -1-_baf ))&0x1);}else {_agg =int (bits &0x1);bits >>=1;};if _caf =_dga .WriteBit (_agg );_caf !=nil {return _gcda ,_e .Wrapf (_caf ,_dfc ,"\u0062i\u0074\u003a\u0020\u0025\u0064",_baf );
58 | };};return _cfc ,nil ;};func (_fdge *Reader )AbsolutePosition ()int64 {return _fdge ._ef +int64 (_fdge ._cdb ._ffe )};func (_dg *BufferedWriter )writeShiftedBytes (_bee []byte )int {for _ ,_gdcb :=range _bee {_dg .writeByte (_gdcb );};return len (_bee );
59 | };func (_dff *BufferedWriter )writeFullBytes (_bgb []byte )int {_fda :=copy (_dff ._fd [_dff .fullOffset ():],_bgb );_dff ._ad +=_fda ;return _fda ;};type Reader struct{_cdb readerSource ;_dba byte ;_gag byte ;_ef int64 ;_ac int ;_gc int ;_cc int64 ;_bgcd byte ;
60 | _da byte ;_acd int ;};type StreamReader interface{_f .Reader ;_f .ByteReader ;_f .Seeker ;Align ()byte ;BitPosition ()int ;Mark ();Length ()uint64 ;ReadBit ()(int ,error );ReadBits (_fgb byte )(uint64 ,error );ReadBool ()(bool ,error );ReadUint32 ()(uint32 ,error );
61 | Reset ();AbsolutePosition ()int64 ;};func (_ege *BufferedWriter )grow (_gbe int ){if _ege ._fd ==nil &&_gbe < _ab {_ege ._fd =make ([]byte ,_gbe ,_ab );return ;};_gd :=len (_ege ._fd );if _ege ._ag !=0{_gd ++;};_gdd :=cap (_ege ._fd );switch {case _gbe <=_gdd /2-_gd :_d .Log .Trace ("\u005b\u0042\u0075\u0066\u0066\u0065r\u0065\u0064\u0057\u0072\u0069t\u0065\u0072\u005d\u0020\u0067\u0072o\u0077\u0020\u002d\u0020\u0072e\u0073\u006c\u0069\u0063\u0065\u0020\u006f\u006e\u006c\u0079\u002e\u0020L\u0065\u006e\u003a\u0020\u0027\u0025\u0064\u0027\u002c\u0020\u0043\u0061\u0070\u003a\u0020'\u0025\u0064\u0027\u002c\u0020\u006e\u003a\u0020'\u0025\u0064\u0027",len (_ege ._fd ),cap (_ege ._fd ),_gbe );
62 | _d .Log .Trace ("\u0020\u006e\u0020\u003c\u003d\u0020\u0063\u0020\u002f\u0020\u0032\u0020\u002d\u006d\u002e \u0043:\u0020\u0027\u0025\u0064\u0027\u002c\u0020\u006d\u003a\u0020\u0027\u0025\u0064\u0027",_gdd ,_gd );copy (_ege ._fd ,_ege ._fd [_ege .fullOffset ():]);
63 | case _gdd > _ge -_gdd -_gbe :_d .Log .Error ("\u0042\u0055F\u0046\u0045\u0052 \u0074\u006f\u006f\u0020\u006c\u0061\u0072\u0067\u0065");return ;default:_df :=make ([]byte ,2*_gdd +_gbe );copy (_df ,_ege ._fd );_ege ._fd =_df ;};_ege ._fd =_ege ._fd [:_gd +_gbe ];
64 | };var (_ _f .Reader =&Reader {};_ _f .ByteReader =&Reader {};_ _f .Seeker =&Reader {};_ StreamReader =&Reader {};);func (_gfe *Reader )Length ()uint64 {return uint64 (_gfe ._cdb ._ba )};const (_ab =64;_ge =int (^uint (0)>>1););func (_cbd *Reader )readBufferByte ()(byte ,error ){if _cbd ._ef >=int64 (_cbd ._cdb ._ba ){return 0,_f .EOF ;
65 | };_cbd ._gc =-1;_ffa :=_cbd ._cdb ._ffc [int64 (_cbd ._cdb ._ffe )+_cbd ._ef ];_cbd ._ef ++;_cbd ._ac =int (_ffa );return _ffa ,nil ;};func (_faf *Reader )Reset (){_faf ._ef =_faf ._cc ;_faf ._gag =_faf ._bgcd ;_faf ._dba =_faf ._da ;_faf ._ac =_faf ._acd ;
66 | };func (_ec *BufferedWriter )expandIfNeeded (_gbb int ){if !_ec .tryGrowByReslice (_gbb ){_ec .grow (_gbb );};};func NewReader (data []byte )*Reader {return &Reader {_cdb :readerSource {_ffc :data ,_ba :len (data ),_ffe :0}};};var _ BinaryWriter =&Writer {};
67 | 


--------------------------------------------------------------------------------
/internal/endian/endian.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | package endian ;import (_c "encoding/binary";_f "unsafe";);var (ByteOrder _c .ByteOrder ;_a bool ;);func init (){const _g =int (_f .Sizeof (0));_ad :=1;_af :=(*[_g ]byte )(_f .Pointer (&_ad ));if _af [0]==0{_a =true ;ByteOrder =_c .BigEndian ;}else {ByteOrder =_c .LittleEndian ;
13 | };};func IsLittle ()bool {return !_a };func IsBig ()bool {return _a };


--------------------------------------------------------------------------------
/internal/integrations/unichart/unichart.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | package unichart ;import (_a "bytes";_b "fmt";_g "github.com/unidoc/unichart/render";_e "github.com/unidoc/unipdf/v4/common";_bd "github.com/unidoc/unipdf/v4/contentstream";_ad "github.com/unidoc/unipdf/v4/contentstream/draw";_gf "github.com/unidoc/unipdf/v4/core";
13 | _db "github.com/unidoc/unipdf/v4/model";_fc "image/color";_de "io";_f "math";);func (_ge *Renderer )Circle (radius float64 ,x ,y int ){_gfe :=radius ;if _ag :=_ge ._af ;_ag !=0{_gfe -=_ag /2;};_cbb :=_gfe *0.551784;_gg :=_ad .CubicBezierPath {Curves :[]_ad .CubicBezierCurve {_ad .NewCubicBezierCurve (-_gfe ,0,-_gfe ,_cbb ,-_cbb ,_gfe ,0,_gfe ),_ad .NewCubicBezierCurve (0,_gfe ,_cbb ,_gfe ,_gfe ,_cbb ,_gfe ,0),_ad .NewCubicBezierCurve (_gfe ,0,_gfe ,-_cbb ,_cbb ,-_gfe ,0,-_gfe ),_ad .NewCubicBezierCurve (0,-_gfe ,-_cbb ,-_gfe ,-_gfe ,-_cbb ,-_gfe ,0)}};
14 | if _cea :=_ge ._af ;_cea !=0{_gg =_gg .Offset (_cea /2,_cea /2);};_gg =_gg .Offset (float64 (x ),float64 (y ));_ad .DrawBezierPathWithCreator (_gg ,_ge ._bc );};func _ec (_egf _fc .Color )(float64 ,float64 ,float64 ,float64 ){_afg ,_cag ,_eac ,_bacg :=_cd (_egf );
15 | return float64 (_afg )/255,float64 (_cag )/255,float64 (_eac )/255,float64 (_bacg )/255;};func (_ada *Renderer )Save (w _de .Writer )error {if w ==nil {return nil ;};_ ,_fbc :=_de .Copy (w ,_a .NewBuffer (_ada ._bc .Bytes ()));return _fbc ;};func NewRenderer (cc *_bd .ContentCreator ,res *_db .PdfPageResources )func (int ,int )(_g .Renderer ,error ){return func (_dbf ,_cg int )(_g .Renderer ,error ){_ac :=&Renderer {_c :_dbf ,_ce :_cg ,_ae :72,_bc :cc ,_ab :res ,_adc :map[*_db .PdfFont ]_gf .PdfObjectName {}};
16 | _ac .ResetStyle ();return _ac ,nil ;};};func (_ee *Renderer )ArcTo (cx ,cy int ,rx ,ry ,startAngle ,deltaAngle float64 ){startAngle =_ccad (2.0*_f .Pi -startAngle );deltaAngle =_ccad (-deltaAngle );_bbe ,_acd :=deltaAngle ,1;if _f .Abs (deltaAngle )> 90.0{_acd =int (_f .Ceil (_f .Abs (deltaAngle )/90.0));
17 | _bbe =deltaAngle /float64 (_acd );};var (_fcf =_efa (_bbe /2);_bad =_f .Abs (4.0/3.0*(1.0-_f .Cos (_fcf ))/_f .Sin (_fcf ));_fb =float64 (cx );_gbd =float64 (cy ););for _cc :=0;_cc < _acd ;_cc ++{_ea :=_efa (startAngle +float64 (_cc )*_bbe );_ca :=_efa (startAngle +float64 (_cc +1)*_bbe );
18 | _gbda :=_f .Cos (_ea );_deg :=_f .Cos (_ca );_daa :=_f .Sin (_ea );_bcb :=_f .Sin (_ca );var _dba []float64 ;if _bbe > 0{_dba =[]float64 {_fb +rx *_gbda ,_gbd -ry *_daa ,_fb +rx *(_gbda -_bad *_daa ),_gbd -ry *(_daa +_bad *_gbda ),_fb +rx *(_deg +_bad *_bcb ),_gbd -ry *(_bcb -_bad *_deg ),_fb +rx *_deg ,_gbd -ry *_bcb };
19 | }else {_dba =[]float64 {_fb +rx *_gbda ,_gbd -ry *_daa ,_fb +rx *(_gbda +_bad *_daa ),_gbd -ry *(_daa -_bad *_gbda ),_fb +rx *(_deg -_bad *_bcb ),_gbd -ry *(_bcb +_bad *_deg ),_fb +rx *_deg ,_gbd -ry *_bcb };};if _cc ==0{_ee ._bc .Add_l (_dba [0],_dba [1]);
20 | };_ee ._bc .Add_c (_dba [2],_dba [3],_dba [4],_dba [5],_dba [6],_dba [7]);};};func _efa (_efc float64 )float64 {return _efc *_f .Pi /180.0};func (_fca *Renderer )GetDPI ()float64 {return _fca ._ae };func (_bb *Renderer )SetDPI (dpi float64 ){_bb ._ae =dpi };
21 | func (_cca *Renderer )getTextWidth (_adbg string )float64 {var _cbf float64 ;for _ ,_gga :=range _adbg {_gae ,_bee :=_cca ._df .GetRuneMetrics (_gga );if !_bee {_e .Log .Debug ("\u0045\u0052\u0052OR\u003a\u0020\u0075\u006e\u0073\u0075\u0070\u0070\u006fr\u0074e\u0064 \u0072u\u006e\u0065\u0020\u0025\u0076\u0020\u0069\u006e\u0020\u0066\u006f\u006e\u0074",_gga );
22 | };_cbf +=_gae .Wx ;};return _cca ._fa *_cbf /1000.0;};func (_agd *Renderer )wrapText (_fgf string )[]string {var (_eg []string ;_aaf []rune ;);for _ ,_aga :=range _fgf {if _aga =='\n'{_eg =append (_eg ,string (_aaf ));_aaf =[]rune {};continue ;};_aaf =append (_aaf ,_aga );
23 | };if len (_aaf )> 0{_eg =append (_eg ,string (_aaf ));};return _eg ;};func (_adb *Renderer )FillStroke (){_adb ._bc .Add_B ()};func (_bcbb *Renderer )SetFontColor (color _fc .Color ){_bcbb ._add =color };func (_dff *Renderer )Fill (){_dff ._bc .Add_f ()};
24 | func (_dcf *Renderer )MeasureText (text string )_g .Box {_be :=_dcf ._fa ;_dbc ,_efb :=_dcf ._df .GetFontDescriptor ();if _efb !=nil {_e .Log .Debug ("W\u0041\u0052\u004e\u003a\u0020\u0055n\u0061\u0062\u006c\u0065\u0020\u0074o\u0020\u0067\u0065\u0074\u0020\u0066\u006fn\u0074\u0020\u0064\u0065\u0073\u0063\u0072\u0069\u0070\u0074o\u0072");
25 | }else {_feeg ,_ffd :=_dbc .GetCapHeight ();if _ffd !=nil {_e .Log .Debug ("\u0057\u0041\u0052\u004e\u003a\u0020\u0055\u006e\u0061\u0062\u006c\u0065\u0020t\u006f\u0020\u0067\u0065\u0074\u0020f\u006f\u006e\u0074\u0020\u0063\u0061\u0070\u0020\u0068\u0065\u0069\u0067\u0068t\u003a\u0020\u0025\u0076",_ffd );
26 | }else {_be =_feeg /1000.0*_dcf ._fa ;};};var (_gde =0.0;_fbe =_dcf .wrapText (text ););for _ ,_dgc :=range _fbe {if _bade :=_dcf .getTextWidth (_dgc );_bade > _gde {_gde =_bade ;};};_bef :=_g .NewBox (0,0,int (_gde ),int (_be ));if _dec :=_dcf ._abe ;_dec !=0{_bef =_bef .Corners ().Rotate (_dec ).Box ();
27 | };return _bef ;};func (_aa *Renderer )LineTo (x ,y int ){_aa ._bc .Add_l (float64 (x ),float64 (y ))};func (_dbb *Renderer )ResetStyle (){_dbb .SetFillColor (_fc .Black );_dbb .SetStrokeColor (_fc .Transparent );_dbb .SetStrokeWidth (0);_dbb .SetFont (_db .DefaultFont ());
28 | _dbb .SetFontColor (_fc .Black );_dbb .SetFontSize (12);_dbb .SetTextRotation (0);};func (_fd *Renderer )SetTextRotation (radians float64 ){_fd ._abe =_ccad (-radians )};func (_ccb *Renderer )SetFont (font _g .Font ){_bg ,_dd :=font .(*_db .PdfFont );if !_dd {_e .Log .Debug ("\u0045R\u0052\u004f\u0052\u003a\u0020\u0069\u006e\u0076\u0061\u006c\u0069d\u0020\u0066\u006f\u006e\u0074\u0020\u0074\u0079\u0070\u0065");
29 | return ;};_bcd ,_dd :=_ccb ._adc [_bg ];if !_dd {_bcd =_cdf ("\u0046\u006f\u006e\u0074",1,_ccb ._ab .HasFontByName );if _fgb :=_ccb ._ab .SetFontByName (_bcd ,_bg .ToPdfObject ());_fgb !=nil {_e .Log .Debug ("\u0045\u0052\u0052\u004f\u0052:\u0020\u0063\u006f\u0075\u006c\u0064\u0020\u006e\u006f\u0074\u0020\u0061\u0064d\u0020\u0066\u006f\u006e\u0074\u0020\u0025\u0076\u0020\u0074\u006f\u0020\u0072\u0065\u0073\u006f\u0075\u0072\u0063\u0065\u0073",_bg );
30 | };_ccb ._adc [_bg ]=_bcd ;};_ccb ._bc .Add_Tf (_bcd ,_ccb ._fa );_ccb ._df =_bg ;};func _cdf (_cdg string ,_dbcg int ,_agf func (_gf .PdfObjectName )bool )_gf .PdfObjectName {_aba :=_gf .PdfObjectName (_b .Sprintf ("\u0025\u0073\u0025\u0064",_cdg ,_dbcg ));
31 | for _dfb :=_dbcg ;_agf (_aba );{_dfb ++;_aba =_gf .PdfObjectName (_b .Sprintf ("\u0025\u0073\u0025\u0064",_cdg ,_dfb ));};return _aba ;};func (_gd *Renderer )SetStrokeDashArray (dashArray []float64 ){_ga :=make ([]int64 ,len (dashArray ));for _afb ,_ef :=range dashArray {_ga [_afb ]=int64 (_ef );
32 | };_gd ._bc .Add_d (_ga ,0);};func _cd (_ggc _fc .Color )(uint8 ,uint8 ,uint8 ,uint8 ){_cec ,_gbdg ,_efg ,_ddc :=_ggc .RGBA ();return uint8 (_cec >>8),uint8 (_gbdg >>8),uint8 (_efg >>8),uint8 (_ddc >>8);};func (_aab *Renderer )Stroke (){_aab ._bc .Add_S ()};
33 | func (_fcg *Renderer )QuadCurveTo (cx ,cy ,x ,y int ){_fcg ._bc .Add_v (float64 (x ),float64 (y ),float64 (cx ),float64 (cy ));};func (_fee *Renderer )SetFillColor (color _fc .Color ){_fee ._ed =color ;_afe ,_dg ,_bac ,_ :=_ec (color );_fee ._bc .Add_rg (_afe ,_dg ,_bac );
34 | };func (_bbc *Renderer )MoveTo (x ,y int ){_bbc ._bc .Add_m (float64 (x ),float64 (y ))};func (_cce *Renderer )SetFontSize (size float64 ){_cce ._fa =size };func _ccad (_gcg float64 )float64 {return _gcg *180/_f .Pi };func (_fe *Renderer )SetClassName (name string ){};
35 | func (_fcb *Renderer )SetStrokeWidth (width float64 ){_fcb ._af =width ;_fcb ._bc .Add_w (width )};func (_gc *Renderer )SetStrokeColor (color _fc .Color ){_gc ._gb =color ;_fg ,_ba ,_ff ,_ :=_ec (color );_gc ._bc .Add_RG (_fg ,_ba ,_ff );};func (_cb *Renderer )Close (){_cb ._bc .Add_h ()};
36 | func (_ded *Renderer )Text (text string ,x ,y int ){_ded ._bc .Add_q ();_ded .SetFont (_ded ._df );_bag ,_bga ,_dc ,_ :=_ec (_ded ._add );_ded ._bc .Add_rg (_bag ,_bga ,_dc );_ded ._bc .Translate (float64 (x ),float64 (y )).Scale (1,-1);if _ccc :=_ded ._abe ;
37 | _ccc !=0{_ded ._bc .RotateDeg (_ccc );};_ded ._bc .Add_BT ().Add_TL (_ded ._fa );var (_dcg =_ded ._df .Encoder ();_dbd =_ded .wrapText (text );_cbd =len (_dbd ););for _gag ,_acc :=range _dbd {_ded ._bc .Add_TJ (_gf .MakeStringFromBytes (_dcg .Encode (_acc )));
38 | if _gag !=_cbd -1{_ded ._bc .Add_Tstar ();};};_ded ._bc .Add_ET ();_ded ._bc .Add_Q ();};func (_eed *Renderer )ClearTextRotation (){_eed ._abe =0};type Renderer struct{_c int ;_ce int ;_ae float64 ;_bc *_bd .ContentCreator ;_ab *_db .PdfPageResources ;
39 | _ed _fc .Color ;_gb _fc .Color ;_af float64 ;_df *_db .PdfFont ;_fa float64 ;_add _fc .Color ;_abe float64 ;_adc map[*_db .PdfFont ]_gf .PdfObjectName ;};


--------------------------------------------------------------------------------
/internal/jbig2/basic/basic.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | package basic ;import _g "github.com/unidoc/unipdf/v4/internal/jbig2/errors";type IntSlice []int ;type IntsMap map[uint64 ][]int ;func (_fb IntsMap )Get (key uint64 )(int ,bool ){_gg ,_fc :=_fb [key ];if !_fc {return 0,false ;};if len (_gg )==0{return 0,false ;
13 | };return _gg [0],true ;};func (_ea *IntSlice )Copy ()*IntSlice {_bd :=IntSlice (make ([]int ,len (*_ea )));copy (_bd ,*_ea );return &_bd ;};type Stack struct{Data []interface{};Aux *Stack ;};func (_d *NumSlice )Add (v float32 ){*_d =append (*_d ,v )};func (_ef IntSlice )Size ()int {return len (_ef )};
14 | func Min (x ,y int )int {if x < y {return x ;};return y ;};func (_fe IntsMap )Add (key uint64 ,value int ){_fe [key ]=append (_fe [key ],value )};func (_a NumSlice )Get (i int )(float32 ,error ){if i < 0||i > len (_a )-1{return 0,_g .Errorf ("\u004e\u0075\u006dS\u006c\u0069\u0063\u0065\u002e\u0047\u0065\u0074","\u0069n\u0064\u0065\u0078\u003a\u0020\u0027\u0025\u0064\u0027\u0020\u006fu\u0074\u0020\u006f\u0066\u0020\u0072\u0061\u006e\u0067\u0065",i );
15 | };return _a [i ],nil ;};func NewIntSlice (i int )*IntSlice {_c :=IntSlice (make ([]int ,i ));return &_c };func (_b IntsMap )GetSlice (key uint64 )([]int ,bool ){_e ,_ee :=_b [key ];if !_ee {return nil ,false ;};return _e ,true ;};func NewNumSlice (i int )*NumSlice {_ff :=NumSlice (make ([]float32 ,i ));
16 | return &_ff };func Ceil (numerator ,denominator int )int {if numerator %denominator ==0{return numerator /denominator ;};return (numerator /denominator )+1;};func (_efb NumSlice )GetInt (i int )(int ,error ){const _db ="\u0047\u0065\u0074\u0049\u006e\u0074";
17 | if i < 0||i > len (_efb )-1{return 0,_g .Errorf (_db ,"\u0069n\u0064\u0065\u0078\u003a\u0020\u0027\u0025\u0064\u0027\u0020\u006fu\u0074\u0020\u006f\u0066\u0020\u0072\u0061\u006e\u0067\u0065",i );};_gef :=_efb [i ];return int (_gef +Sign (_gef )*0.5),nil ;
18 | };type NumSlice []float32 ;func (_eg *Stack )Peek ()(_fbg interface{},_ac bool ){return _eg .peek ()};func (_dd *NumSlice )AddInt (v int ){*_dd =append (*_dd ,float32 (v ))};func (_ec *Stack )Pop ()(_cf interface{},_gea bool ){_cf ,_gea =_ec .peek ();if !_gea {return nil ,_gea ;
19 | };_ec .Data =_ec .Data [:_ec .top ()];return _cf ,true ;};func (_eeg IntsMap )Delete (key uint64 ){delete (_eeg ,key )};func (_fgf *Stack )Push (v interface{}){_fgf .Data =append (_fgf .Data ,v )};func (_ggd *Stack )top ()int {return len (_ggd .Data )-1};
20 | func Max (x ,y int )int {if x > y {return x ;};return y ;};func Sign (v float32 )float32 {if v >=0.0{return 1.0;};return -1.0;};func Abs (v int )int {if v > 0{return v ;};return -v ;};func (_ge *IntSlice )Add (v int )error {if _ge ==nil {return _g .Error ("\u0049\u006e\u0074S\u006c\u0069\u0063\u0065\u002e\u0041\u0064\u0064","\u0073\u006c\u0069\u0063\u0065\u0020\u006e\u006f\u0074\u0020\u0064\u0065f\u0069\u006e\u0065\u0064");
21 | };*_ge =append (*_ge ,v );return nil ;};func (_ggc *Stack )Len ()int {return len (_ggc .Data )};func (_eb IntSlice )Get (index int )(int ,error ){if index > len (_eb )-1{return 0,_g .Errorf ("\u0049\u006e\u0074S\u006c\u0069\u0063\u0065\u002e\u0047\u0065\u0074","\u0069\u006e\u0064\u0065x:\u0020\u0025\u0064\u0020\u006f\u0075\u0074\u0020\u006f\u0066\u0020\u0072\u0061\u006eg\u0065",index );
22 | };return _eb [index ],nil ;};func (_ecf *Stack )peek ()(interface{},bool ){_fd :=_ecf .top ();if _fd ==-1{return nil ,false ;};return _ecf .Data [_fd ],true ;};func (_fg NumSlice )GetIntSlice ()[]int {_ce :=make ([]int ,len (_fg ));for _bdc ,_aa :=range _fg {_ce [_bdc ]=int (_aa );
23 | };return _ce ;};


--------------------------------------------------------------------------------
/internal/jbig2/bench/bench.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | package bench ;


--------------------------------------------------------------------------------
/internal/jbig2/decoder/arithmetic/arithmetic.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | package arithmetic ;import (_e "fmt";_g "github.com/unidoc/unipdf/v4/common";_f "github.com/unidoc/unipdf/v4/internal/bitwise";_fc "github.com/unidoc/unipdf/v4/internal/jbig2/internal";_b "io";_cg "strings";);func (_af *Decoder )DecodeInt (stats *DecoderStats )(int32 ,error ){var (_fa ,_aaa int32 ;
13 | _cbb ,_cbe ,_cc int ;_gdf error ;);if stats ==nil {stats =NewStats (512,1);};_af ._bbd =1;_cbe ,_gdf =_af .decodeIntBit (stats );if _gdf !=nil {return 0,_gdf ;};_cbb ,_gdf =_af .decodeIntBit (stats );if _gdf !=nil {return 0,_gdf ;};if _cbb ==1{_cbb ,_gdf =_af .decodeIntBit (stats );
14 | if _gdf !=nil {return 0,_gdf ;};if _cbb ==1{_cbb ,_gdf =_af .decodeIntBit (stats );if _gdf !=nil {return 0,_gdf ;};if _cbb ==1{_cbb ,_gdf =_af .decodeIntBit (stats );if _gdf !=nil {return 0,_gdf ;};if _cbb ==1{_cbb ,_gdf =_af .decodeIntBit (stats );if _gdf !=nil {return 0,_gdf ;
15 | };if _cbb ==1{_cc =32;_aaa =4436;}else {_cc =12;_aaa =340;};}else {_cc =8;_aaa =84;};}else {_cc =6;_aaa =20;};}else {_cc =4;_aaa =4;};}else {_cc =2;_aaa =0;};for _ag :=0;_ag < _cc ;_ag ++{_cbb ,_gdf =_af .decodeIntBit (stats );if _gdf !=nil {return 0,_gdf ;
16 | };_fa =(_fa <<1)|int32 (_cbb );};_fa +=_aaa ;if _cbe ==0{return _fa ,nil ;}else if _cbe ==1&&_fa > 0{return -_fa ,nil ;};return 0,_fc .ErrOOB ;};type Decoder struct{ContextSize []uint32 ;ReferedToContextSize []uint32 ;_bb *_f .Reader ;_fd uint8 ;_gd uint64 ;
17 | _d uint32 ;_bbd int64 ;_ce int32 ;_gb int32 ;_bf int64 ;};func (_bce *Decoder )renormalize ()error {for {if _bce ._ce ==0{if _ca :=_bce .readByte ();_ca !=nil {return _ca ;};};_bce ._d <<=1;_bce ._gd <<=1;_bce ._ce --;if (_bce ._d &0x8000)!=0{break ;};
18 | };_bce ._gd &=0xffffffff;return nil ;};var (_fca =[][4]uint32 {{0x5601,1,1,1},{0x3401,2,6,0},{0x1801,3,9,0},{0x0AC1,4,12,0},{0x0521,5,29,0},{0x0221,38,33,0},{0x5601,7,6,1},{0x5401,8,14,0},{0x4801,9,14,0},{0x3801,10,14,0},{0x3001,11,17,0},{0x2401,12,18,0},{0x1C01,13,20,0},{0x1601,29,21,0},{0x5601,15,14,1},{0x5401,16,14,0},{0x5101,17,15,0},{0x4801,18,16,0},{0x3801,19,17,0},{0x3401,20,18,0},{0x3001,21,19,0},{0x2801,22,19,0},{0x2401,23,20,0},{0x2201,24,21,0},{0x1C01,25,22,0},{0x1801,26,23,0},{0x1601,27,24,0},{0x1401,28,25,0},{0x1201,29,26,0},{0x1101,30,27,0},{0x0AC1,31,28,0},{0x09C1,32,29,0},{0x08A1,33,30,0},{0x0521,34,31,0},{0x0441,35,32,0},{0x02A1,36,33,0},{0x0221,37,34,0},{0x0141,38,35,0},{0x0111,39,36,0},{0x0085,40,37,0},{0x0049,41,38,0},{0x0025,42,39,0},{0x0015,43,40,0},{0x0009,44,41,0},{0x0005,45,42,0},{0x0001,45,43,0},{0x5601,46,46,0}};
19 | );func (_dc *Decoder )DecodeBit (stats *DecoderStats )(int ,error ){var (_ee int ;_bd =_fca [stats .cx ()][0];_aa =int32 (stats .cx ()););defer func (){_dc ._gb ++}();_dc ._d -=_bd ;if (_dc ._gd >>16)< uint64 (_bd ){_ee =_dc .lpsExchange (stats ,_aa ,_bd );
20 | if _ba :=_dc .renormalize ();_ba !=nil {return 0,_ba ;};}else {_dc ._gd -=uint64 (_bd )<<16;if (_dc ._d &0x8000)==0{_ee =_dc .mpsExchange (stats ,_aa );if _cb :=_dc .renormalize ();_cb !=nil {return 0,_cb ;};}else {_ee =int (stats .getMps ());};};return _ee ,nil ;
21 | };type DecoderStats struct{_gcf int32 ;_cgg int32 ;_cd []byte ;_efc []byte ;};func (_gec *Decoder )init ()error {_gec ._bf =_gec ._bb .AbsolutePosition ();_fbb ,_db :=_gec ._bb .ReadByte ();if _db !=nil {_g .Log .Debug ("B\u0075\u0066\u0066\u0065\u0072\u0030 \u0072\u0065\u0061\u0064\u0042\u0079\u0074\u0065\u0020f\u0061\u0069\u006ce\u0064.\u0020\u0025\u0076",_db );
22 | return _db ;};_gec ._fd =_fbb ;_gec ._gd =uint64 (_fbb )<<16;if _db =_gec .readByte ();_db !=nil {return _db ;};_gec ._gd <<=7;_gec ._ce -=7;_gec ._d =0x8000;_gec ._gb ++;return nil ;};func (_ege *Decoder )lpsExchange (_bcc *DecoderStats ,_efa int32 ,_gcd uint32 )int {_gda :=_bcc .getMps ();
23 | if _ege ._d < _gcd {_bcc .setEntry (int (_fca [_efa ][1]));_ege ._d =_gcd ;return int (_gda );};if _fca [_efa ][3]==1{_bcc .toggleMps ();};_bcc .setEntry (int (_fca [_efa ][2]));_ege ._d =_gcd ;return int (1-_gda );};func New (r *_f .Reader )(*Decoder ,error ){_a :=&Decoder {_bb :r ,ContextSize :[]uint32 {16,13,10,10},ReferedToContextSize :[]uint32 {13,10}};
24 | if _gdb :=_a .init ();_gdb !=nil {return nil ,_gdb ;};return _a ,nil ;};func (_eedc *DecoderStats )setEntry (_fff int ){_bfc :=byte (_fff &0x7f);_eedc ._cd [_eedc ._gcf ]=_bfc ;};func (_fe *DecoderStats )cx ()byte {return _fe ._cd [_fe ._gcf ]};func (_fad *Decoder )mpsExchange (_bde *DecoderStats ,_eg int32 )int {_bg :=_bde ._efc [_bde ._gcf ];
25 | if _fad ._d < _fca [_eg ][0]{if _fca [_eg ][3]==1{_bde .toggleMps ();};_bde .setEntry (int (_fca [_eg ][2]));return int (1-_bg );};_bde .setEntry (int (_fca [_eg ][1]));return int (_bg );};func (_ad *Decoder )DecodeIAID (codeLen uint64 ,stats *DecoderStats )(int64 ,error ){_ad ._bbd =1;
26 | var _ge uint64 ;for _ge =0;_ge < codeLen ;_ge ++{stats .SetIndex (int32 (_ad ._bbd ));_fb ,_gc :=_ad .DecodeBit (stats );if _gc !=nil {return 0,_gc ;};_ad ._bbd =(_ad ._bbd <<1)|int64 (_fb );};_ccf :=_ad ._bbd -(1<<codeLen );return _ccf ,nil ;};func (_gbe *DecoderStats )Reset (){for _eed :=0;
27 | _eed < len (_gbe ._cd );_eed ++{_gbe ._cd [_eed ]=0;_gbe ._efc [_eed ]=0;};};func (_ff *Decoder )readByte ()error {if _ff ._bb .AbsolutePosition ()> _ff ._bf {if _ ,_ef :=_ff ._bb .Seek (-1,_b .SeekCurrent );_ef !=nil {return _ef ;};};_gbf ,_ac :=_ff ._bb .ReadByte ();
28 | if _ac !=nil {return _ac ;};_ff ._fd =_gbf ;if _ff ._fd ==0xFF{_ab ,_cgc :=_ff ._bb .ReadByte ();if _cgc !=nil {return _cgc ;};if _ab > 0x8F{_ff ._gd +=0xFF00;_ff ._ce =8;if _ ,_df :=_ff ._bb .Seek (-2,_b .SeekCurrent );_df !=nil {return _df ;};}else {_ff ._gd +=uint64 (_ab )<<9;
29 | _ff ._ce =7;};}else {_gbf ,_ac =_ff ._bb .ReadByte ();if _ac !=nil {return _ac ;};_ff ._fd =_gbf ;_ff ._gd +=uint64 (_ff ._fd )<<8;_ff ._ce =8;};_ff ._gd &=0xFFFFFFFFFF;return nil ;};func (_afa *DecoderStats )SetIndex (index int32 ){_afa ._gcf =index };
30 | func (_cgf *DecoderStats )Overwrite (dNew *DecoderStats ){for _cee :=0;_cee < len (_cgf ._cd );_cee ++{_cgf ._cd [_cee ]=dNew ._cd [_cee ];_cgf ._efc [_cee ]=dNew ._efc [_cee ];};};func NewStats (contextSize int32 ,index int32 )*DecoderStats {return &DecoderStats {_gcf :index ,_cgg :contextSize ,_cd :make ([]byte ,contextSize ),_efc :make ([]byte ,contextSize )};
31 | };func (_fdc *DecoderStats )getMps ()byte {return _fdc ._efc [_fdc ._gcf ]};func (_gdbc *DecoderStats )String ()string {_cdf :=&_cg .Builder {};_cdf .WriteString (_e .Sprintf ("S\u0074\u0061\u0074\u0073\u003a\u0020\u0020\u0025\u0064\u000a",len (_gdbc ._cd )));
32 | for _aag ,_dba :=range _gdbc ._cd {if _dba !=0{_cdf .WriteString (_e .Sprintf ("N\u006f\u0074\u0020\u007aer\u006f \u0061\u0074\u003a\u0020\u0025d\u0020\u002d\u0020\u0025\u0064\u000a",_aag ,_dba ));};};return _cdf .String ();};func (_ed *Decoder )decodeIntBit (_afd *DecoderStats )(int ,error ){_afd .SetIndex (int32 (_ed ._bbd ));
33 | _gdfd ,_gcg :=_ed .DecodeBit (_afd );if _gcg !=nil {_g .Log .Debug ("\u0041\u0072\u0069\u0074\u0068\u006d\u0065t\u0069\u0063\u0044e\u0063\u006f\u0064e\u0072\u0020'\u0064\u0065\u0063\u006f\u0064\u0065I\u006etB\u0069\u0074\u0027\u002d\u003e\u0020\u0044\u0065\u0063\u006f\u0064\u0065\u0042\u0069\u0074\u0020\u0066\u0061\u0069\u006c\u0065\u0064\u002e\u0020\u0025\u0076",_gcg );
34 | return _gdfd ,_gcg ;};if _ed ._bbd < 256{_ed ._bbd =((_ed ._bbd <<uint64 (1))|int64 (_gdfd ))&0x1ff;}else {_ed ._bbd =(((_ed ._bbd <<uint64 (1)|int64 (_gdfd ))&511)|256)&0x1ff;};return _gdfd ,nil ;};func (_acb *DecoderStats )Copy ()*DecoderStats {_cgb :=&DecoderStats {_cgg :_acb ._cgg ,_cd :make ([]byte ,_acb ._cgg )};
35 | copy (_cgb ._cd ,_acb ._cd );return _cgb ;};func (_eee *DecoderStats )toggleMps (){_eee ._efc [_eee ._gcf ]^=1};


--------------------------------------------------------------------------------
/internal/jbig2/decoder/decoder.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | package decoder ;import (_g "github.com/unidoc/unipdf/v4/internal/bitwise";_ga "github.com/unidoc/unipdf/v4/internal/jbig2/bitmap";_ge "github.com/unidoc/unipdf/v4/internal/jbig2/document";_d "github.com/unidoc/unipdf/v4/internal/jbig2/errors";_b "image";
13 | );func (_ag *Decoder )DecodePageImage (pageNumber int )(_b .Image ,error ){const _geg ="\u0064\u0065\u0063od\u0065\u0072\u002e\u0044\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";_gg ,_fg :=_ag .decodePageImage (pageNumber );
14 | if _fg !=nil {return nil ,_d .Wrap (_fg ,_geg ,"");};return _gg ,nil ;};func (_be *Decoder )PageNumber ()(int ,error ){const _gb ="\u0044e\u0063o\u0064\u0065\u0072\u002e\u0050a\u0067\u0065N\u0075\u006d\u0062\u0065\u0072";if _be ._bf ==nil {return 0,_d .Error (_gb ,"d\u0065\u0063\u006f\u0064\u0065\u0072 \u006e\u006f\u0074\u0020\u0069\u006e\u0069\u0074\u0069a\u006c\u0069\u007ae\u0064 \u0079\u0065\u0074");
15 | };return int (_be ._bf .NumberOfPages ),nil ;};type Parameters struct{UnpaddedData bool ;Color _ga .Color ;};func (_gd *Decoder )decodePage (_ef int )([]byte ,error ){const _cg ="\u0064\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065";if _ef < 0{return nil ,_d .Errorf (_cg ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_ef );
16 | };if _ef > int (_gd ._bf .NumberOfPages ){return nil ,_d .Errorf (_cg ,"p\u0061\u0067\u0065\u003a\u0020\u0027%\u0064\u0027\u0020\u006e\u006f\u0074 \u0066\u006f\u0075\u006e\u0064\u0020\u0069n\u0020\u0074\u0068\u0065\u0020\u0064\u0065\u0063\u006f\u0064e\u0072",_ef );
17 | };_beg ,_dd :=_gd ._bf .GetPage (_ef );if _dd !=nil {return nil ,_d .Wrap (_dd ,_cg ,"");};_cc ,_dd :=_beg .GetBitmap ();if _dd !=nil {return nil ,_d .Wrap (_dd ,_cg ,"");};_cc .InverseData ();if !_gd ._c .UnpaddedData {return _cc .Data ,nil ;};return _cc .GetUnpaddedData ();
18 | };type Decoder struct{_f *_g .Reader ;_bf *_ge .Document ;_e int ;_c Parameters ;};func (_gf *Decoder )DecodeNextPage ()([]byte ,error ){_gf ._e ++;_gag :=_gf ._e ;return _gf .decodePage (_gag );};func Decode (input []byte ,parameters Parameters ,globals *_ge .Globals )(*Decoder ,error ){_fgg :=_g .NewReader (input );
19 | _bdd ,_dc :=_ge .DecodeDocument (_fgg ,globals );if _dc !=nil {return nil ,_dc ;};return &Decoder {_f :_fgg ,_bf :_bdd ,_c :parameters },nil ;};func (_eb *Decoder )DecodePage (pageNumber int )([]byte ,error ){return _eb .decodePage (pageNumber )};func (_ebb *Decoder )decodePageImage (_bd int )(_b .Image ,error ){const _ff ="\u0064e\u0063o\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";
20 | if _bd < 0{return nil ,_d .Errorf (_ff ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_bd );};if _bd > int (_ebb ._bf .NumberOfPages ){return nil ,_d .Errorf (_ff ,"p\u0061\u0067\u0065\u003a\u0020\u0027%\u0064\u0027\u0020\u006e\u006f\u0074 \u0066\u006f\u0075\u006e\u0064\u0020\u0069n\u0020\u0074\u0068\u0065\u0020\u0064\u0065\u0063\u006f\u0064e\u0072",_bd );
21 | };_fgd ,_ffb :=_ebb ._bf .GetPage (_bd );if _ffb !=nil {return nil ,_d .Wrap (_ffb ,_ff ,"");};_fb ,_ffb :=_fgd .GetBitmap ();if _ffb !=nil {return nil ,_d .Wrap (_ffb ,_ff ,"");};_fb .InverseData ();return _fb .ToImage (),nil ;};


--------------------------------------------------------------------------------
/internal/jbig2/decoder/huffman/huffman.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | package huffman ;import (_e "errors";_ccb "fmt";_c "github.com/unidoc/unipdf/v4/internal/bitwise";_cc "github.com/unidoc/unipdf/v4/internal/jbig2/internal";_cca "math";_d "strings";);func (_gea *InternalNode )Decode (r *_c .Reader )(int64 ,error ){_gbg ,_gf :=r .ReadBit ();
13 | if _gf !=nil {return 0,_gf ;};if _gbg ==0{return _gea ._ceb .Decode (r );};return _gea ._gc .Decode (r );};type InternalNode struct{_eg int32 ;_ceb Node ;_gc Node ;};func (_dfg *StandardTable )Decode (r *_c .Reader )(int64 ,error ){return _dfg ._cde .Decode (r )};
14 | func GetStandardTable (number int )(Tabler ,error ){if number <=0||number > len (_ebc ){return nil ,_e .New ("\u0049n\u0064e\u0078\u0020\u006f\u0075\u0074 \u006f\u0066 \u0072\u0061\u006e\u0067\u0065");};_dcf :=_ebc [number -1];if _dcf ==nil {var _acb error ;
15 | _dcf ,_acb =_ffge (_eaf [number -1]);if _acb !=nil {return nil ,_acb ;};_ebc [number -1]=_dcf ;};return _dcf ,nil ;};func _eed (_eadc *Code )*OutOfBandNode {return &OutOfBandNode {}};func (_be *EncodedTable )parseTable ()error {var (_ge []*Code ;_ba ,_ag ,_gd int32 ;
16 | _ga uint64 ;_f error ;);_ea :=_be .StreamReader ();_gag :=_be .HtLow ();for _gag < _be .HtHigh (){_ga ,_f =_ea .ReadBits (byte (_be .HtPS ()));if _f !=nil {return _f ;};_ba =int32 (_ga );_ga ,_f =_ea .ReadBits (byte (_be .HtRS ()));if _f !=nil {return _f ;
17 | };_ag =int32 (_ga );_ge =append (_ge ,NewCode (_ba ,_ag ,_gd ,false ));_gag +=1<<uint (_ag );};_ga ,_f =_ea .ReadBits (byte (_be .HtPS ()));if _f !=nil {return _f ;};_ba =int32 (_ga );_ag =32;_gd =_be .HtLow ()-1;_ge =append (_ge ,NewCode (_ba ,_ag ,_gd ,true ));
18 | _ga ,_f =_ea .ReadBits (byte (_be .HtPS ()));if _f !=nil {return _f ;};_ba =int32 (_ga );_ag =32;_gd =_be .HtHigh ();_ge =append (_ge ,NewCode (_ba ,_ag ,_gd ,false ));if _be .HtOOB ()==1{_ga ,_f =_ea .ReadBits (byte (_be .HtPS ()));if _f !=nil {return _f ;
19 | };_ba =int32 (_ga );_ge =append (_ge ,NewCode (_ba ,-1,-1,false ));};if _f =_be .InitTree (_ge );_f !=nil {return _f ;};return nil ;};type ValueNode struct{_ce int32 ;_ccad int32 ;_fe bool ;};func (_g *EncodedTable )InitTree (codeTable []*Code )error {_ccbb (codeTable );
20 | for _ ,_df :=range codeTable {if _gg :=_g ._bf .append (_df );_gg !=nil {return _gg ;};};return nil ;};func (_gbe *FixedSizeTable )RootNode ()*InternalNode {return _gbe ._dc };type StandardTable struct{_cde *InternalNode };type OutOfBandNode struct{};var _eaf =[][][]int32 {{{1,4,0},{2,8,16},{3,16,272},{3,32,65808}},{{1,0,0},{2,0,1},{3,0,2},{4,3,3},{5,6,11},{6,32,75},{6,-1,0}},{{8,8,-256},{1,0,0},{2,0,1},{3,0,2},{4,3,3},{5,6,11},{8,32,-257,999},{7,32,75},{6,-1,0}},{{1,0,1},{2,0,2},{3,0,3},{4,3,4},{5,6,12},{5,32,76}},{{7,8,-255},{1,0,1},{2,0,2},{3,0,3},{4,3,4},{5,6,12},{7,32,-256,999},{6,32,76}},{{5,10,-2048},{4,9,-1024},{4,8,-512},{4,7,-256},{5,6,-128},{5,5,-64},{4,5,-32},{2,7,0},{3,7,128},{3,8,256},{4,9,512},{4,10,1024},{6,32,-2049,999},{6,32,2048}},{{4,9,-1024},{3,8,-512},{4,7,-256},{5,6,-128},{5,5,-64},{4,5,-32},{4,5,0},{5,5,32},{5,6,64},{4,7,128},{3,8,256},{3,9,512},{3,10,1024},{5,32,-1025,999},{5,32,2048}},{{8,3,-15},{9,1,-7},{8,1,-5},{9,0,-3},{7,0,-2},{4,0,-1},{2,1,0},{5,0,2},{6,0,3},{3,4,4},{6,1,20},{4,4,22},{4,5,38},{5,6,70},{5,7,134},{6,7,262},{7,8,390},{6,10,646},{9,32,-16,999},{9,32,1670},{2,-1,0}},{{8,4,-31},{9,2,-15},{8,2,-11},{9,1,-7},{7,1,-5},{4,1,-3},{3,1,-1},{3,1,1},{5,1,3},{6,1,5},{3,5,7},{6,2,39},{4,5,43},{4,6,75},{5,7,139},{5,8,267},{6,8,523},{7,9,779},{6,11,1291},{9,32,-32,999},{9,32,3339},{2,-1,0}},{{7,4,-21},{8,0,-5},{7,0,-4},{5,0,-3},{2,2,-2},{5,0,2},{6,0,3},{7,0,4},{8,0,5},{2,6,6},{5,5,70},{6,5,102},{6,6,134},{6,7,198},{6,8,326},{6,9,582},{6,10,1094},{7,11,2118},{8,32,-22,999},{8,32,4166},{2,-1,0}},{{1,0,1},{2,1,2},{4,0,4},{4,1,5},{5,1,7},{5,2,9},{6,2,13},{7,2,17},{7,3,21},{7,4,29},{7,5,45},{7,6,77},{7,32,141}},{{1,0,1},{2,0,2},{3,1,3},{5,0,5},{5,1,6},{6,1,8},{7,0,10},{7,1,11},{7,2,13},{7,3,17},{7,4,25},{8,5,41},{8,32,73}},{{1,0,1},{3,0,2},{4,0,3},{5,0,4},{4,1,5},{3,3,7},{6,1,15},{6,2,17},{6,3,21},{6,4,29},{6,5,45},{7,6,77},{7,32,141}},{{3,0,-2},{3,0,-1},{1,0,0},{3,0,1},{3,0,2}},{{7,4,-24},{6,2,-8},{5,1,-4},{4,0,-2},{3,0,-1},{1,0,0},{3,0,1},{4,0,2},{5,1,3},{6,2,5},{7,4,9},{7,32,-25,999},{7,32,25}}};
21 | func (_geb *ValueNode )String ()string {return _ccb .Sprintf ("\u0025\u0064\u002f%\u0064",_geb ._ce ,_geb ._ccad );};func _accg (_ecec ,_bae int32 )int32 {if _ecec > _bae {return _ecec ;};return _bae ;};func (_gb *EncodedTable )String ()string {return _gb ._bf .String ()+"\u000a"};
22 | func NewEncodedTable (table BasicTabler )(*EncodedTable ,error ){_ac :=&EncodedTable {_bf :&InternalNode {},BasicTabler :table };if _ee :=_ac .parseTable ();_ee !=nil {return nil ,_ee ;};return _ac ,nil ;};var _ Tabler =&EncodedTable {};func (_cd *ValueNode )Decode (r *_c .Reader )(int64 ,error ){_ca ,_eeg :=r .ReadBits (byte (_cd ._ce ));
23 | if _eeg !=nil {return 0,_eeg ;};if _cd ._fe {_ca =-_ca ;};return int64 (_cd ._ccad )+int64 (_ca ),nil ;};func NewFixedSizeTable (codeTable []*Code )(*FixedSizeTable ,error ){_agf :=&FixedSizeTable {_dc :&InternalNode {}};if _af :=_agf .InitTree (codeTable );
24 | _af !=nil {return nil ,_af ;};return _agf ,nil ;};func (_bb *EncodedTable )Decode (r *_c .Reader )(int64 ,error ){return _bb ._bf .Decode (r )};func _db (_bbd *Code )*ValueNode {return &ValueNode {_ce :_bbd ._cag ,_ccad :_bbd ._aa ,_fe :_bbd ._gff }};func (_ec *FixedSizeTable )Decode (r *_c .Reader )(int64 ,error ){return _ec ._dc .Decode (r )};
25 | func (_da *InternalNode )String ()string {_fee :=&_d .Builder {};_fee .WriteString ("\u000a");_da .pad (_fee );_fee .WriteString ("\u0030\u003a\u0020");_fee .WriteString (_da ._ceb .String ()+"\u000a");_da .pad (_fee );_fee .WriteString ("\u0031\u003a\u0020");
26 | _fee .WriteString (_da ._gc .String ()+"\u000a");return _fee .String ();};func (_gge *InternalNode )append (_ad *Code )(_fc error ){if _ad ._cbe ==0{return nil ;};_ffg :=_ad ._cbe -1-_gge ._eg ;if _ffg < 0{return _e .New ("\u004e\u0065\u0067\u0061\u0074\u0069\u0076\u0065\u0020\u0073\u0068\u0069\u0066\u0074\u0069n\u0067 \u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u006c\u006c\u006f\u0077\u0065\u0064");
27 | };_ccc :=(_ad ._gcb >>uint (_ffg ))&0x1;if _ffg ==0{if _ad ._cag ==-1{if _ccc ==1{if _gge ._gc !=nil {return _ccb .Errorf ("O\u004f\u0042\u0020\u0061\u006c\u0072e\u0061\u0064\u0079\u0020\u0073\u0065\u0074\u0020\u0066o\u0072\u0020\u0063o\u0064e\u0020\u0025\u0073",_ad );
28 | };_gge ._gc =_eed (_ad );}else {if _gge ._ceb !=nil {return _ccb .Errorf ("O\u004f\u0042\u0020\u0061\u006c\u0072e\u0061\u0064\u0079\u0020\u0073\u0065\u0074\u0020\u0066o\u0072\u0020\u0063o\u0064e\u0020\u0025\u0073",_ad );};_gge ._ceb =_eed (_ad );};}else {if _ccc ==1{if _gge ._gc !=nil {return _ccb .Errorf ("\u0056\u0061\u006cue\u0020\u004e\u006f\u0064\u0065\u0020\u0061\u006c\u0072e\u0061d\u0079 \u0073e\u0074\u0020\u0066\u006f\u0072\u0020\u0063\u006f\u0064\u0065\u0020\u0025\u0073",_ad );
29 | };_gge ._gc =_db (_ad );}else {if _gge ._ceb !=nil {return _ccb .Errorf ("\u0056\u0061\u006cue\u0020\u004e\u006f\u0064\u0065\u0020\u0061\u006c\u0072e\u0061d\u0079 \u0073e\u0074\u0020\u0066\u006f\u0072\u0020\u0063\u006f\u0064\u0065\u0020\u0025\u0073",_ad );
30 | };_gge ._ceb =_db (_ad );};};}else {if _ccc ==1{if _gge ._gc ==nil {_gge ._gc =_bfd (_gge ._eg +1);};if _fc =_gge ._gc .(*InternalNode ).append (_ad );_fc !=nil {return _fc ;};}else {if _gge ._ceb ==nil {_gge ._ceb =_bfd (_gge ._eg +1);};if _fc =_gge ._ceb .(*InternalNode ).append (_ad );
31 | _fc !=nil {return _fc ;};};};return nil ;};func _acc (_bc ,_acg int32 )string {var _bfe int32 ;_agg :=make ([]rune ,_acg );for _aba :=int32 (1);_aba <=_acg ;_aba ++{_bfe =_bc >>uint (_acg -_aba )&1;if _bfe !=0{_agg [_aba -1]='1';}else {_agg [_aba -1]='0';
32 | };};return string (_agg );};func (_ccd *StandardTable )String ()string {return _ccd ._cde .String ()+"\u000a"};func (_cf *FixedSizeTable )String ()string {return _cf ._dc .String ()+"\u000a"};type Tabler interface{Decode (_dgf *_c .Reader )(int64 ,error );
33 | InitTree (_ggeg []*Code )error ;String ()string ;RootNode ()*InternalNode ;};func (_cg *OutOfBandNode )Decode (r *_c .Reader )(int64 ,error ){return 0,_cc .ErrOOB };func (_efec *OutOfBandNode )String ()string {return _ccb .Sprintf ("\u0025\u0030\u00364\u0062",int64 (_cca .MaxInt64 ));
34 | };type FixedSizeTable struct{_dc *InternalNode };type Node interface{Decode (_ff *_c .Reader )(int64 ,error );String ()string ;};var _ Node =&OutOfBandNode {};func (_fb *StandardTable )RootNode ()*InternalNode {return _fb ._cde };type EncodedTable struct{BasicTabler ;
35 | _bf *InternalNode ;};type Code struct{_cbe int32 ;_cag int32 ;_aa int32 ;_gff bool ;_gcb int32 ;};type BasicTabler interface{HtHigh ()int32 ;HtLow ()int32 ;StreamReader ()*_c .Reader ;HtPS ()int32 ;HtRS ()int32 ;HtOOB ()int32 ;};var _ Node =&InternalNode {};
36 | var _ebc =make ([]Tabler ,len (_eaf ));func (_daf *StandardTable )InitTree (codeTable []*Code )error {_ccbb (codeTable );for _ ,_gfc :=range codeTable {if _dg :=_daf ._cde .append (_gfc );_dg !=nil {return _dg ;};};return nil ;};func (_ab *InternalNode )pad (_ece *_d .Builder ){for _bbg :=int32 (0);
37 | _bbg < _ab ._eg ;_bbg ++{_ece .WriteString ("\u0020\u0020\u0020");};};func _ccbb (_gcg []*Code ){var _ggf int32 ;for _ ,_cac :=range _gcg {_ggf =_accg (_ggf ,_cac ._cbe );};_ecg :=make ([]int32 ,_ggf +1);for _ ,_bbf :=range _gcg {_ecg [_bbf ._cbe ]++;};
38 | var _cdea int32 ;_dca :=make ([]int32 ,len (_ecg )+1);_ecg [0]=0;for _bfeg :=int32 (1);_bfeg <=int32 (len (_ecg ));_bfeg ++{_dca [_bfeg ]=(_dca [_bfeg -1]+(_ecg [_bfeg -1]))<<1;_cdea =_dca [_bfeg ];for _ ,_agc :=range _gcg {if _agc ._cbe ==_bfeg {_agc ._gcb =_cdea ;
39 | _cdea ++;};};};};func (_ccag *Code )String ()string {var _gcdg string ;if _ccag ._gcb !=-1{_gcdg =_acc (_ccag ._gcb ,_ccag ._cbe );}else {_gcdg ="\u003f";};return _ccb .Sprintf ("%\u0073\u002f\u0025\u0064\u002f\u0025\u0064\u002f\u0025\u0064",_gcdg ,_ccag ._cbe ,_ccag ._cag ,_ccag ._aa );
40 | };func _bfd (_afeb int32 )*InternalNode {return &InternalNode {_eg :_afeb }};func (_efe *EncodedTable )RootNode ()*InternalNode {return _efe ._bf };var _ Node =&ValueNode {};func _ffge (_bg [][]int32 )(*StandardTable ,error ){var _gcd []*Code ;for _bad :=0;
41 | _bad < len (_bg );_bad ++{_ggeb :=_bg [_bad ][0];_fae :=_bg [_bad ][1];_cce :=_bg [_bad ][2];var _aca bool ;if len (_bg [_bad ])> 3{_aca =true ;};_gcd =append (_gcd ,NewCode (_ggeb ,_fae ,_cce ,_aca ));};_abb :=&StandardTable {_cde :_bfd (0)};if _de :=_abb .InitTree (_gcd );
42 | _de !=nil {return nil ,_de ;};return _abb ,nil ;};func (_gda *FixedSizeTable )InitTree (codeTable []*Code )error {_ccbb (codeTable );for _ ,_ead :=range codeTable {_afe :=_gda ._dc .append (_ead );if _afe !=nil {return _afe ;};};return nil ;};func NewCode (prefixLength ,rangeLength ,rangeLow int32 ,isLowerRange bool )*Code {return &Code {_cbe :prefixLength ,_cag :rangeLength ,_aa :rangeLow ,_gff :isLowerRange ,_gcb :-1};
43 | };


--------------------------------------------------------------------------------
/internal/jbig2/decoder/mmr/mmr.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | package mmr ;import (_g "errors";_e "fmt";_f "github.com/unidoc/unipdf/v4/common";_a "github.com/unidoc/unipdf/v4/internal/bitwise";_eg "github.com/unidoc/unipdf/v4/internal/jbig2/bitmap";_ef "io";);func (_fg *Decoder )UncompressMMR ()(_bd *_eg .Bitmap ,_fccf error ){_bd =_eg .New (_fg ._gbf ,_fg ._gc );
13 | _bdd :=make ([]int ,_bd .Width +5);_eeac :=make ([]int ,_bd .Width +5);_eeac [0]=_bd .Width ;_fge :=1;var _cag int ;for _cba :=0;_cba < _bd .Height ;_cba ++{_cag ,_fccf =_fg .uncompress2d (_fg ._aca ,_eeac ,_fge ,_bdd ,_bd .Width );if _fccf !=nil {return nil ,_fccf ;
14 | };if _cag ==EOF {break ;};if _cag > 0{_fccf =_fg .fillBitmap (_bd ,_cba ,_bdd ,_cag );if _fccf !=nil {return nil ,_fccf ;};};_eeac ,_bdd =_bdd ,_eeac ;_fge =_cag ;};if _fccf =_fg .detectAndSkipEOL ();_fccf !=nil {return nil ,_fccf ;};_fg ._aca .align ();
15 | return _bd ,nil ;};func _eda (_be [3]int )*code {return &code {_bb :_be [0],_fb :_be [1],_c :_be [2]}};func (_ga *Decoder )detectAndSkipEOL ()error {for {_dc ,_fcf :=_ga ._aca .uncompressGetCode (_ga ._eeg );if _fcf !=nil {return _fcf ;};if _dc !=nil &&_dc ._c ==EOL {_ga ._aca ._aba +=_dc ._bb ;
16 | }else {return nil ;};};};func (_dggc *runData )uncompressGetCode (_fed []*code )(*code ,error ){return _dggc .uncompressGetCodeLittleEndian (_fed );};func _bc (_eed ,_eb int )int {if _eed < _eb {return _eb ;};return _eed ;};func (_gdf *Decoder )initTables ()(_cbb error ){if _gdf ._fab ==nil {_gdf ._fab ,_cbb =_gdf .createLittleEndianTable (_af );
17 | if _cbb !=nil {return ;};_gdf ._gce ,_cbb =_gdf .createLittleEndianTable (_dg );if _cbb !=nil {return ;};_gdf ._eeg ,_cbb =_gdf .createLittleEndianTable (_ebd );if _cbb !=nil {return ;};};return nil ;};func _bac (_dea *_a .Reader )(*runData ,error ){_afb :=&runData {_adgd :_dea ,_aba :0,_cgf :1};
18 | _fcd :=_fe (_bc (_bba ,int (_dea .Length ())),_bff );_afb ._daa =make ([]byte ,_fcd );if _eeae :=_afb .fillBuffer (0);_eeae !=nil {if _eeae ==_ef .EOF {_afb ._daa =make ([]byte ,10);_f .Log .Debug ("F\u0069\u006c\u006c\u0042uf\u0066e\u0072\u0020\u0066\u0061\u0069l\u0065\u0064\u003a\u0020\u0025\u0076",_eeae );
19 | }else {return nil ,_eeae ;};};return _afb ,nil ;};func (_eff *runData )uncompressGetCodeLittleEndian (_afa []*code )(*code ,error ){_abe ,_afac :=_eff .uncompressGetNextCodeLittleEndian ();if _afac !=nil {_f .Log .Debug ("\u0055n\u0063\u006fm\u0070\u0072\u0065\u0073s\u0047\u0065\u0074N\u0065\u0078\u0074\u0043\u006f\u0064\u0065\u004c\u0069tt\u006c\u0065\u0045n\u0064\u0069a\u006e\u0020\u0066\u0061\u0069\u006ce\u0064\u003a \u0025\u0076",_afac );
20 | return nil ,_afac ;};_abe &=0xffffff;_dfd :=_abe >>(_dga -_ebc );_dggf :=_afa [_dfd ];if _dggf !=nil &&_dggf ._ed {_dfd =(_abe >>(_dga -_ebc -_ad ))&_gb ;_dggf =_dggf ._ee [_dfd ];};return _dggf ,nil ;};type code struct{_bb int ;_fb int ;_c int ;_ee []*code ;
21 | _ed bool ;};func _fe (_cb ,_gg int )int {if _cb > _gg {return _gg ;};return _cb ;};func (_ege *Decoder )uncompress1d (_gfc *runData ,_dad []int ,_ecg int )(int ,error ){var (_ea =true ;_dab int ;_dee *code ;_fcg int ;_ffa error ;);_ffg :for _dab < _ecg {_gcc :for {if _ea {_dee ,_ffa =_gfc .uncompressGetCode (_ege ._fab );
22 | if _ffa !=nil {return 0,_ffa ;};}else {_dee ,_ffa =_gfc .uncompressGetCode (_ege ._gce );if _ffa !=nil {return 0,_ffa ;};};_gfc ._aba +=_dee ._bb ;if _dee ._c < 0{break _ffg ;};_dab +=_dee ._c ;if _dee ._c < 64{_ea =!_ea ;_dad [_fcg ]=_dab ;_fcg ++;break _gcc ;
23 | };};};if _dad [_fcg ]!=_ecg {_dad [_fcg ]=_ecg ;};_ecf :=EOL ;if _dee !=nil &&_dee ._c !=EOL {_ecf =_fcg ;};return _ecf ,nil ;};func (_eeb *code )String ()string {return _e .Sprintf ("\u0025\u0064\u002f\u0025\u0064\u002f\u0025\u0064",_eeb ._bb ,_eeb ._fb ,_eeb ._c );
24 | };func (_gfcd *runData )align (){_gfcd ._aba =((_gfcd ._aba +7)>>3)<<3};func New (r *_a .Reader ,width ,height int ,dataOffset ,dataLength int64 )(*Decoder ,error ){_ff :=&Decoder {_gbf :width ,_gc :height };_ffe ,_fcc :=r .NewPartialReader (int (dataOffset ),int (dataLength ),false );
25 | if _fcc !=nil {return nil ,_fcc ;};_eea ,_fcc :=_bac (_ffe );if _fcc !=nil {return nil ,_fcc ;};_ ,_fcc =r .Seek (_ffe .RelativePosition (),_ef .SeekCurrent );if _fcc !=nil {return nil ,_fcc ;};_ff ._aca =_eea ;if _ab :=_ff .initTables ();_ab !=nil {return nil ,_ab ;
26 | };return _ff ,nil ;};const (_bff int =1024<<7;_bba int =3;_dga uint =24;);func (_ffeb *Decoder )uncompress2d (_bf *runData ,_dbe []int ,_cbe int ,_cff []int ,_ccc int )(int ,error ){var (_gab int ;_eab int ;_fd int ;_fad =true ;_gfca error ;_edb *code ;
27 | );_dbe [_cbe ]=_ccc ;_dbe [_cbe +1]=_ccc ;_dbe [_cbe +2]=_ccc +1;_dbe [_cbe +3]=_ccc +1;_edf :for _fd < _ccc {_edb ,_gfca =_bf .uncompressGetCode (_ffeb ._eeg );if _gfca !=nil {return EOL ,nil ;};if _edb ==nil {_bf ._aba ++;break _edf ;};_bf ._aba +=_edb ._bb ;
28 | switch mmrCode (_edb ._c ){case _fc :_fd =_dbe [_gab ];case _ec :_fd =_dbe [_gab ]+1;case _ggg :_fd =_dbe [_gab ]-1;case _ag :for {var _eeba []*code ;if _fad {_eeba =_ffeb ._fab ;}else {_eeba =_ffeb ._gce ;};_edb ,_gfca =_bf .uncompressGetCode (_eeba );
29 | if _gfca !=nil {return 0,_gfca ;};if _edb ==nil {break _edf ;};_bf ._aba +=_edb ._bb ;if _edb ._c < 64{if _edb ._c < 0{_cff [_eab ]=_fd ;_eab ++;_edb =nil ;break _edf ;};_fd +=_edb ._c ;_cff [_eab ]=_fd ;_eab ++;break ;};_fd +=_edb ._c ;};_efe :=_fd ;_df :for {var _gea []*code ;
30 | if !_fad {_gea =_ffeb ._fab ;}else {_gea =_ffeb ._gce ;};_edb ,_gfca =_bf .uncompressGetCode (_gea );if _gfca !=nil {return 0,_gfca ;};if _edb ==nil {break _edf ;};_bf ._aba +=_edb ._bb ;if _edb ._c < 64{if _edb ._c < 0{_cff [_eab ]=_fd ;_eab ++;break _edf ;
31 | };_fd +=_edb ._c ;if _fd < _ccc ||_fd !=_efe {_cff [_eab ]=_fd ;_eab ++;};break _df ;};_fd +=_edb ._c ;};for _fd < _ccc &&_dbe [_gab ]<=_fd {_gab +=2;};continue _edf ;case _ac :_gab ++;_fd =_dbe [_gab ];_gab ++;continue _edf ;case _ca :_fd =_dbe [_gab ]+2;
32 | case _bg :_fd =_dbe [_gab ]-2;case _bcf :_fd =_dbe [_gab ]+3;case _cc :_fd =_dbe [_gab ]-3;default:if _bf ._aba ==12&&_edb ._c ==EOL {_bf ._aba =0;if _ ,_gfca =_ffeb .uncompress1d (_bf ,_dbe ,_ccc );_gfca !=nil {return 0,_gfca ;};_bf ._aba ++;if _ ,_gfca =_ffeb .uncompress1d (_bf ,_cff ,_ccc );
33 | _gfca !=nil {return 0,_gfca ;};_ccb ,_cg :=_ffeb .uncompress1d (_bf ,_dbe ,_ccc );if _cg !=nil {return EOF ,_cg ;};_bf ._aba ++;return _ccb ,nil ;};_fd =_ccc ;continue _edf ;};if _fd <=_ccc {_fad =!_fad ;_cff [_eab ]=_fd ;_eab ++;if _gab > 0{_gab --;}else {_gab ++;
34 | };for _fd < _ccc &&_dbe [_gab ]<=_fd {_gab +=2;};};};if _cff [_eab ]!=_ccc {_cff [_eab ]=_ccc ;};if _edb ==nil {return EOL ,nil ;};return _eab ,nil ;};func (_agb *runData )uncompressGetNextCodeLittleEndian ()(int ,error ){_baa :=_agb ._aba -_agb ._cgf ;
35 | if _baa < 0||_baa > 24{_cge :=(_agb ._aba >>3)-_agb ._acabd ;if _cge >=_agb ._dgg {_cge +=_agb ._acabd ;if _caa :=_agb .fillBuffer (_cge );_caa !=nil {return 0,_caa ;};_cge -=_agb ._acabd ;};_cfg :=(uint32 (_agb ._daa [_cge ]&0xFF)<<16)|(uint32 (_agb ._daa [_cge +1]&0xFF)<<8)|(uint32 (_agb ._daa [_cge +2]&0xFF));
36 | _dfc :=uint32 (_agb ._aba &7);_cfg <<=_dfc ;_agb ._ba =int (_cfg );}else {_fbf :=_agb ._cgf &7;_ada :=7-_fbf ;if _baa <=_ada {_agb ._ba <<=uint (_baa );}else {_deg :=(_agb ._cgf >>3)+3-_agb ._acabd ;if _deg >=_agb ._dgg {_deg +=_agb ._acabd ;if _baae :=_agb .fillBuffer (_deg );
37 | _baae !=nil {return 0,_baae ;};_deg -=_agb ._acabd ;};_fbf =8-_fbf ;for {_agb ._ba <<=uint (_fbf );_agb ._ba |=int (uint (_agb ._daa [_deg ])&0xFF);_baa -=_fbf ;_deg ++;_fbf =8;if !(_baa >=8){break ;};};_agb ._ba <<=uint (_baa );};};_agb ._cgf =_agb ._aba ;
38 | return _agb ._ba ,nil ;};type runData struct{_adgd *_a .Reader ;_aba int ;_cgf int ;_ba int ;_daa []byte ;_acabd int ;_dgg int ;};const (EOF =-3;_fa =-2;EOL =-1;_ebc =8;_egg =(1<<_ebc )-1;_ad =5;_gb =(1<<_ad )-1;);func (_ccee *runData )fillBuffer (_cgfd int )error {_ccee ._acabd =_cgfd ;
39 | _ ,_fbfa :=_ccee ._adgd .Seek (int64 (_cgfd ),_ef .SeekStart );if _fbfa !=nil {if _fbfa ==_ef .EOF {_f .Log .Debug ("\u0053\u0065\u0061\u006b\u0020\u0045\u004f\u0046");_ccee ._dgg =-1;}else {return _fbfa ;};};if _fbfa ==nil {_ccee ._dgg ,_fbfa =_ccee ._adgd .Read (_ccee ._daa );
40 | if _fbfa !=nil {if _fbfa ==_ef .EOF {_f .Log .Trace ("\u0052\u0065\u0061\u0064\u0020\u0045\u004f\u0046");_ccee ._dgg =-1;}else {return _fbfa ;};};};if _ccee ._dgg > -1&&_ccee ._dgg < 3{for _ccee ._dgg < 3{_eabb ,_gceg :=_ccee ._adgd .ReadByte ();if _gceg !=nil {if _gceg ==_ef .EOF {_ccee ._daa [_ccee ._dgg ]=0;
41 | }else {return _gceg ;};}else {_ccee ._daa [_ccee ._dgg ]=_eabb &0xFF;};_ccee ._dgg ++;};};_ccee ._dgg -=3;if _ccee ._dgg < 0{_ccee ._daa =make ([]byte ,len (_ccee ._daa ));_ccee ._dgg =len (_ccee ._daa )-3;};return nil ;};func (_abd *Decoder )createLittleEndianTable (_gcg [][3]int )([]*code ,error ){_gcd :=make ([]*code ,_egg +1);
42 | for _cf :=0;_cf < len (_gcg );_cf ++{_eef :=_eda (_gcg [_cf ]);if _eef ._bb <=_ebc {_bcd :=_ebc -_eef ._bb ;_dd :=_eef ._fb <<uint (_bcd );for _gd :=(1<<uint (_bcd ))-1;_gd >=0;_gd --{_da :=_dd |_gd ;_gcd [_da ]=_eef ;};}else {_acab :=_eef ._fb >>uint (_eef ._bb -_ebc );
43 | if _gcd [_acab ]==nil {var _de =_eda ([3]int {});_de ._ee =make ([]*code ,_gb +1);_gcd [_acab ]=_de ;};if _eef ._bb <=_ebc +_ad {_cce :=_ebc +_ad -_eef ._bb ;_eead :=(_eef ._fb <<uint (_cce ))&_gb ;_gcd [_acab ]._ed =true ;for _gba :=(1<<uint (_cce ))-1;
44 | _gba >=0;_gba --{_gcd [_acab ]._ee [_eead |_gba ]=_eef ;};}else {return nil ,_g .New ("\u0043\u006f\u0064\u0065\u0020\u0074a\u0062\u006c\u0065\u0020\u006f\u0076\u0065\u0072\u0066\u006c\u006f\u0077\u0020i\u006e\u0020\u004d\u004d\u0052\u0044\u0065c\u006f\u0064\u0065\u0072");
45 | };};};return _gcd ,nil ;};type mmrCode int ;var (_ebd =[][3]int {{4,0x1,int (_ac )},{3,0x1,int (_ag )},{1,0x1,int (_fc )},{3,0x3,int (_ec )},{6,0x3,int (_ca )},{7,0x3,int (_bcf )},{3,0x2,int (_ggg )},{6,0x2,int (_bg )},{7,0x2,int (_cc )},{10,0xf,int (_d )},{12,0xf,int (_feg )},{12,0x1,int (EOL )}};
46 | _af =[][3]int {{4,0x07,2},{4,0x08,3},{4,0x0B,4},{4,0x0C,5},{4,0x0E,6},{4,0x0F,7},{5,0x12,128},{5,0x13,8},{5,0x14,9},{5,0x1B,64},{5,0x07,10},{5,0x08,11},{6,0x17,192},{6,0x18,1664},{6,0x2A,16},{6,0x2B,17},{6,0x03,13},{6,0x34,14},{6,0x35,15},{6,0x07,1},{6,0x08,12},{7,0x13,26},{7,0x17,21},{7,0x18,28},{7,0x24,27},{7,0x27,18},{7,0x28,24},{7,0x2B,25},{7,0x03,22},{7,0x37,256},{7,0x04,23},{7,0x08,20},{7,0xC,19},{8,0x12,33},{8,0x13,34},{8,0x14,35},{8,0x15,36},{8,0x16,37},{8,0x17,38},{8,0x1A,31},{8,0x1B,32},{8,0x02,29},{8,0x24,53},{8,0x25,54},{8,0x28,39},{8,0x29,40},{8,0x2A,41},{8,0x2B,42},{8,0x2C,43},{8,0x2D,44},{8,0x03,30},{8,0x32,61},{8,0x33,62},{8,0x34,63},{8,0x35,0},{8,0x36,320},{8,0x37,384},{8,0x04,45},{8,0x4A,59},{8,0x4B,60},{8,0x5,46},{8,0x52,49},{8,0x53,50},{8,0x54,51},{8,0x55,52},{8,0x58,55},{8,0x59,56},{8,0x5A,57},{8,0x5B,58},{8,0x64,448},{8,0x65,512},{8,0x67,640},{8,0x68,576},{8,0x0A,47},{8,0x0B,48},{9,0x01,_fa },{9,0x98,1472},{9,0x99,1536},{9,0x9A,1600},{9,0x9B,1728},{9,0xCC,704},{9,0xCD,768},{9,0xD2,832},{9,0xD3,896},{9,0xD4,960},{9,0xD5,1024},{9,0xD6,1088},{9,0xD7,1152},{9,0xD8,1216},{9,0xD9,1280},{9,0xDA,1344},{9,0xDB,1408},{10,0x01,_fa },{11,0x01,_fa },{11,0x08,1792},{11,0x0C,1856},{11,0x0D,1920},{12,0x00,EOF },{12,0x01,EOL },{12,0x12,1984},{12,0x13,2048},{12,0x14,2112},{12,0x15,2176},{12,0x16,2240},{12,0x17,2304},{12,0x1C,2368},{12,0x1D,2432},{12,0x1E,2496},{12,0x1F,2560}};
47 | _dg =[][3]int {{2,0x02,3},{2,0x03,2},{3,0x02,1},{3,0x03,4},{4,0x02,6},{4,0x03,5},{5,0x03,7},{6,0x04,9},{6,0x05,8},{7,0x04,10},{7,0x05,11},{7,0x07,12},{8,0x04,13},{8,0x07,14},{9,0x01,_fa },{9,0x18,15},{10,0x01,_fa },{10,0x17,16},{10,0x18,17},{10,0x37,0},{10,0x08,18},{10,0x0F,64},{11,0x01,_fa },{11,0x17,24},{11,0x18,25},{11,0x28,23},{11,0x37,22},{11,0x67,19},{11,0x68,20},{11,0x6C,21},{11,0x08,1792},{11,0x0C,1856},{11,0x0D,1920},{12,0x00,EOF },{12,0x01,EOL },{12,0x12,1984},{12,0x13,2048},{12,0x14,2112},{12,0x15,2176},{12,0x16,2240},{12,0x17,2304},{12,0x1C,2368},{12,0x1D,2432},{12,0x1E,2496},{12,0x1F,2560},{12,0x24,52},{12,0x27,55},{12,0x28,56},{12,0x2B,59},{12,0x2C,60},{12,0x33,320},{12,0x34,384},{12,0x35,448},{12,0x37,53},{12,0x38,54},{12,0x52,50},{12,0x53,51},{12,0x54,44},{12,0x55,45},{12,0x56,46},{12,0x57,47},{12,0x58,57},{12,0x59,58},{12,0x5A,61},{12,0x5B,256},{12,0x64,48},{12,0x65,49},{12,0x66,62},{12,0x67,63},{12,0x68,30},{12,0x69,31},{12,0x6A,32},{12,0x6B,33},{12,0x6C,40},{12,0x6D,41},{12,0xC8,128},{12,0xC9,192},{12,0xCA,26},{12,0xCB,27},{12,0xCC,28},{12,0xCD,29},{12,0xD2,34},{12,0xD3,35},{12,0xD4,36},{12,0xD5,37},{12,0xD6,38},{12,0xD7,39},{12,0xDA,42},{12,0xDB,43},{13,0x4A,640},{13,0x4B,704},{13,0x4C,768},{13,0x4D,832},{13,0x52,1280},{13,0x53,1344},{13,0x54,1408},{13,0x55,1472},{13,0x5A,1536},{13,0x5B,1600},{13,0x64,1664},{13,0x65,1728},{13,0x6C,512},{13,0x6D,576},{13,0x72,896},{13,0x73,960},{13,0x74,1024},{13,0x75,1088},{13,0x76,1152},{13,0x77,1216}};
48 | );const (_ac mmrCode =iota ;_ag ;_fc ;_ec ;_ca ;_bcf ;_ggg ;_bg ;_cc ;_d ;_feg ;);type Decoder struct{_gbf ,_gc int ;_aca *runData ;_fab []*code ;_gce []*code ;_eeg []*code ;};func (_ece *Decoder )fillBitmap (_faa *_eg .Bitmap ,_aa int ,_adg []int ,_dge int )error {var _eedb byte ;
49 | _daf :=0;_aab :=_faa .GetByteIndex (_daf ,_aa );for _ge :=0;_ge < _dge ;_ge ++{_cfc :=byte (1);_dcb :=_adg [_ge ];if (_ge &1)==0{_cfc =0;};for _daf < _dcb {_eedb =(_eedb <<1)|_cfc ;_daf ++;if (_daf &7)==0{if _efa :=_faa .SetByte (_aab ,_eedb );_efa !=nil {return _efa ;
50 | };_aab ++;_eedb =0;};};};if (_daf &7)!=0{_eedb <<=uint (8-(_daf &7));if _gf :=_faa .SetByte (_aab ,_eedb );_gf !=nil {return _gf ;};};return nil ;};


--------------------------------------------------------------------------------
/internal/jbig2/encoder/arithmetic/arithmetic.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | package arithmetic ;import (_f "bytes";_e "github.com/unidoc/unipdf/v4/common";_a "github.com/unidoc/unipdf/v4/internal/jbig2/bitmap";_c "github.com/unidoc/unipdf/v4/internal/jbig2/errors";_d "io";);func (_dcb *Encoder )EncodeInteger (proc Class ,value int )(_cc error ){_e .Log .Trace ("\u0045\u006eco\u0064\u0065\u0020I\u006e\u0074\u0065\u0067er:\u0027%d\u0027\u0020\u0077\u0069\u0074\u0068\u0020Cl\u0061\u0073\u0073\u003a\u0020\u0027\u0025s\u0027",value ,proc );
13 | if _cc =_dcb .encodeInteger (proc ,value );_cc !=nil {return _c .Wrap (_cc ,"\u0045\u006e\u0063\u006f\u0064\u0065\u0049\u006e\u0074\u0065\u0067\u0065\u0072","");};return nil ;};func (_cgae *Encoder )rBlock (){if _cgae ._dcg >=0{_cgae .emit ();};_cgae ._dcg ++;
14 | _cgae ._abd =uint8 (_cgae ._aae >>20);_cgae ._aae &=0xfffff;_cgae ._ca =7;};func (_gcc *Encoder )dataSize ()int {return _faf *len (_gcc ._bf )+_gcc ._gac };func (_aa Class )String ()string {switch _aa {case IAAI :return "\u0049\u0041\u0041\u0049";case IADH :return "\u0049\u0041\u0044\u0048";
15 | case IADS :return "\u0049\u0041\u0044\u0053";case IADT :return "\u0049\u0041\u0044\u0054";case IADW :return "\u0049\u0041\u0044\u0057";case IAEX :return "\u0049\u0041\u0045\u0058";case IAFS :return "\u0049\u0041\u0046\u0053";case IAIT :return "\u0049\u0041\u0049\u0054";
16 | case IARDH :return "\u0049\u0041\u0052D\u0048";case IARDW :return "\u0049\u0041\u0052D\u0057";case IARDX :return "\u0049\u0041\u0052D\u0058";case IARDY :return "\u0049\u0041\u0052D\u0059";case IARI :return "\u0049\u0041\u0052\u0049";default:return "\u0055N\u004b\u004e\u004f\u0057\u004e";
17 | };};func (_ffd *Encoder )Reset (){_ffd ._dc =0x8000;_ffd ._aae =0;_ffd ._ca =12;_ffd ._dcg =-1;_ffd ._abd =0;_ffd ._cdb =nil ;_ffd ._ad =_df (_fbea );};type Encoder struct{_aae uint32 ;_dc uint16 ;_ca ,_abd uint8 ;_dcg int ;_af int ;_bf [][]byte ;_aaa []byte ;
18 | _gac int ;_ad *codingContext ;_ac [13]*codingContext ;_cdb *codingContext ;};func (_fdb *Encoder )encodeBit (_deae *codingContext ,_dfb uint32 ,_fgd uint8 )error {const _fdc ="\u0045\u006e\u0063\u006f\u0064\u0065\u0072\u002e\u0065\u006e\u0063\u006fd\u0065\u0042\u0069\u0074";
19 | _fdb ._af ++;if _dfb >=uint32 (len (_deae ._ed )){return _c .Errorf (_fdc ,"\u0061r\u0069\u0074h\u006d\u0065\u0074i\u0063\u0020\u0065\u006e\u0063\u006f\u0064e\u0072\u0020\u002d\u0020\u0069\u006ev\u0061\u006c\u0069\u0064\u0020\u0063\u0074\u0078\u0020\u006e\u0075m\u0062\u0065\u0072\u003a\u0020\u0027\u0025\u0064\u0027",_dfb );
20 | };_ebg :=_deae ._ed [_dfb ];_fgdb :=_deae .mps (_dfb );_cbfa :=_cgdb [_ebg ]._aaef ;_e .Log .Trace ("\u0045\u0043\u003a\u0020\u0025d\u0009\u0020D\u003a\u0020\u0025d\u0009\u0020\u0049\u003a\u0020\u0025d\u0009\u0020\u004dPS\u003a \u0025\u0064\u0009\u0020\u0051\u0045\u003a \u0025\u0030\u0034\u0058\u0009\u0020\u0020\u0041\u003a\u0020\u0025\u0030\u0034\u0058\u0009\u0020\u0043\u003a %\u0030\u0038\u0058\u0009\u0020\u0043\u0054\u003a\u0020\u0025\u0064\u0009\u0020\u0042\u003a\u0020\u0025\u0030\u0032\u0058\u0009\u0020\u0042\u0050\u003a\u0020\u0025\u0064",_fdb ._af ,_fgd ,_ebg ,_fgdb ,_cbfa ,_fdb ._dc ,_fdb ._aae ,_fdb ._ca ,_fdb ._abd ,_fdb ._dcg );
21 | if _fgd ==0{_fdb .code0 (_deae ,_dfb ,_cbfa ,_ebg );}else {_fdb .code1 (_deae ,_dfb ,_cbfa ,_ebg );};return nil ;};func (_dd *codingContext )mps (_abc uint32 )int {return int (_dd ._ab [_abc ])};func (_caa *Encoder )Flush (){_caa ._gac =0;_caa ._bf =nil ;
22 | _caa ._dcg =-1};func _df (_ga int )*codingContext {return &codingContext {_ed :make ([]byte ,_ga ),_ab :make ([]byte ,_ga )};};func (_aag *Encoder )byteOut (){if _aag ._abd ==0xff{_aag .rBlock ();return ;};if _aag ._aae < 0x8000000{_aag .lBlock ();return ;
23 | };_aag ._abd ++;if _aag ._abd !=0xff{_aag .lBlock ();return ;};_aag ._aae &=0x7ffffff;_aag .rBlock ();};func (_ecd *Encoder )encodeOOB (_ggb Class )error {_bdc :=_ecd ._ac [_ggb ];_fec :=_ecd .encodeBit (_bdc ,1,1);if _fec !=nil {return _fec ;};_fec =_ecd .encodeBit (_bdc ,3,0);
24 | if _fec !=nil {return _fec ;};_fec =_ecd .encodeBit (_bdc ,6,0);if _fec !=nil {return _fec ;};_fec =_ecd .encodeBit (_bdc ,12,0);if _fec !=nil {return _fec ;};return nil ;};const _ce =0x9b25;const (_fbea =65536;_faf =20*1024;);func (_cfd *Encoder )codeLPS (_fee *codingContext ,_eg uint32 ,_ced uint16 ,_cga byte ){_cfd ._dc -=_ced ;
25 | if _cfd ._dc < _ced {_cfd ._aae +=uint32 (_ced );}else {_cfd ._dc =_ced ;};if _cgdb [_cga ]._fga ==1{_fee .flipMps (_eg );};_fee ._ed [_eg ]=_cgdb [_cga ]._acf ;_cfd .renormalize ();};func (_cae *Encoder )lBlock (){if _cae ._dcg >=0{_cae .emit ();};_cae ._dcg ++;
26 | _cae ._abd =uint8 (_cae ._aae >>19);_cae ._aae &=0x7ffff;_cae ._ca =8;};func (_efe *Encoder )encodeInteger (_cce Class ,_dcd int )error {const _bac ="E\u006e\u0063\u006f\u0064er\u002ee\u006e\u0063\u006f\u0064\u0065I\u006e\u0074\u0065\u0067\u0065\u0072";
27 | if _dcd > 2000000000||_dcd < -2000000000{return _c .Errorf (_bac ,"\u0061\u0072\u0069\u0074\u0068\u006d\u0065\u0074i\u0063\u0020\u0065nc\u006f\u0064\u0065\u0072\u0020\u002d \u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0069\u006e\u0074\u0065\u0067\u0065\u0072 \u0076\u0061\u006c\u0075\u0065\u003a\u0020\u0027%\u0064\u0027",_dcd );
28 | };_bbc :=_efe ._ac [_cce ];_fbe :=uint32 (1);var _fed int ;for ;;_fed ++{if _ff [_fed ]._fd <=_dcd &&_ff [_fed ]._ee >=_dcd {break ;};};if _dcd < 0{_dcd =-_dcd ;};_dcd -=int (_ff [_fed ]._b );_fdfc :=_ff [_fed ]._eeg ;for _eea :=uint8 (0);_eea < _ff [_fed ]._dg ;
29 | _eea ++{_da :=_fdfc &1;if _ddd :=_efe .encodeBit (_bbc ,_fbe ,_da );_ddd !=nil {return _c .Wrap (_ddd ,_bac ,"");};_fdfc >>=1;if _fbe &0x100> 0{_fbe =(((_fbe <<1)|uint32 (_da ))&0x1ff)|0x100;}else {_fbe =(_fbe <<1)|uint32 (_da );};};_dcd <<=32-_ff [_fed ]._cb ;
30 | for _eae :=uint8 (0);_eae < _ff [_fed ]._cb ;_eae ++{_gcba :=uint8 ((uint32 (_dcd )&0x80000000)>>31);if _fdgd :=_efe .encodeBit (_bbc ,_fbe ,_gcba );_fdgd !=nil {return _c .Wrap (_fdgd ,_bac ,"\u006d\u006f\u0076\u0065 \u0064\u0061\u0074\u0061\u0020\u0074\u006f\u0020\u0074\u0068e\u0020t\u006f\u0070\u0020\u006f\u0066\u0020\u0077o\u0072\u0064");
31 | };_dcd <<=1;if _fbe &0x100!=0{_fbe =(((_fbe <<1)|uint32 (_gcba ))&0x1ff)|0x100;}else {_fbe =(_fbe <<1)|uint32 (_gcba );};};return nil ;};const (IAAI Class =iota ;IADH ;IADS ;IADT ;IADW ;IAEX ;IAFS ;IAIT ;IARDH ;IARDW ;IARDX ;IARDY ;IARI ;);func (_cab *Encoder )renormalize (){for {_cab ._dc <<=1;
32 | _cab ._aae <<=1;_cab ._ca --;if _cab ._ca ==0{_cab .byteOut ();};if (_cab ._dc &0x8000)!=0{break ;};};};func (_ageb *Encoder )flush (){_ageb .setBits ();_ageb ._aae <<=_ageb ._ca ;_ageb .byteOut ();_ageb ._aae <<=_ageb ._ca ;_ageb .byteOut ();_ageb .emit ();
33 | if _ageb ._abd !=0xff{_ageb ._dcg ++;_ageb ._abd =0xff;_ageb .emit ();};_ageb ._dcg ++;_ageb ._abd =0xac;_ageb ._dcg ++;_ageb .emit ();};func (_fe *codingContext )flipMps (_cd uint32 ){_fe ._ab [_cd ]=1-_fe ._ab [_cd ]};func (_aad *Encoder )codeMPS (_ddg *codingContext ,_bb uint32 ,_aff uint16 ,_ba byte ){_aad ._dc -=_aff ;
34 | if _aad ._dc &0x8000!=0{_aad ._aae +=uint32 (_aff );return ;};if _aad ._dc < _aff {_aad ._dc =_aff ;}else {_aad ._aae +=uint32 (_aff );};_ddg ._ed [_bb ]=_cgdb [_ba ]._ace ;_aad .renormalize ();};func (_dca *Encoder )EncodeBitmap (bm *_a .Bitmap ,duplicateLineRemoval bool )error {_e .Log .Trace ("\u0045n\u0063\u006f\u0064\u0065 \u0042\u0069\u0074\u006d\u0061p\u0020[\u0025d\u0078\u0025\u0064\u005d\u002c\u0020\u0025s",bm .Width ,bm .Height ,bm );
35 | var (_aaf ,_eb uint8 ;_ef ,_bc ,_gab uint16 ;_afc ,_edc ,_fb byte ;_db ,_dgg ,_bcf int ;_bcb ,_fc []byte ;);for _gg :=0;_gg < bm .Height ;_gg ++{_afc ,_edc =0,0;if _gg >=2{_afc =bm .Data [(_gg -2)*bm .RowStride ];};if _gg >=1{_edc =bm .Data [(_gg -1)*bm .RowStride ];
36 | if duplicateLineRemoval {_dgg =_gg *bm .RowStride ;_bcb =bm .Data [_dgg :_dgg +bm .RowStride ];_bcf =(_gg -1)*bm .RowStride ;_fc =bm .Data [_bcf :_bcf +bm .RowStride ];if _f .Equal (_bcb ,_fc ){_eb =_aaf ^1;_aaf =1;}else {_eb =_aaf ;_aaf =0;};};};if duplicateLineRemoval {if _ggc :=_dca .encodeBit (_dca ._ad ,_ce ,_eb );
37 | _ggc !=nil {return _ggc ;};if _aaf !=0{continue ;};};_fb =bm .Data [_gg *bm .RowStride ];_ef =uint16 (_afc >>5);_bc =uint16 (_edc >>4);_afc <<=3;_edc <<=4;_gab =0;for _db =0;_db < bm .Width ;_db ++{_ggcb :=uint32 (_ef <<11|_bc <<4|_gab );_bd :=(_fb &0x80)>>7;
38 | _de :=_dca .encodeBit (_dca ._ad ,_ggcb ,_bd );if _de !=nil {return _de ;};_ef <<=1;_bc <<=1;_gab <<=1;_ef |=uint16 ((_afc &0x80)>>7);_bc |=uint16 ((_edc &0x80)>>7);_gab |=uint16 (_bd );_dea :=_db %8;_eff :=_db /8+1;if _dea ==4&&_gg >=2{_afc =0;if _eff < bm .RowStride {_afc =bm .Data [(_gg -2)*bm .RowStride +_eff ];
39 | };}else {_afc <<=1;};if _dea ==3&&_gg >=1{_edc =0;if _eff < bm .RowStride {_edc =bm .Data [(_gg -1)*bm .RowStride +_eff ];};}else {_edc <<=1;};if _dea ==7{_fb =0;if _eff < bm .RowStride {_fb =bm .Data [_gg *bm .RowStride +_eff ];};}else {_fb <<=1;};_ef &=31;
40 | _bc &=127;_gab &=15;};};return nil ;};var _ff =[]intEncRangeS {{0,3,0,2,0,2},{-1,-1,9,4,0,0},{-3,-2,5,3,2,1},{4,19,2,3,4,4},{-19,-4,3,3,4,4},{20,83,6,4,20,6},{-83,-20,7,4,20,6},{84,339,14,5,84,8},{-339,-84,15,5,84,8},{340,4435,30,6,340,12},{-4435,-340,31,6,340,12},{4436,2000000000,62,6,4436,32},{-2000000000,-4436,63,6,4436,32}};
41 | func (_gd *Encoder )Refine (iTemp ,iTarget *_a .Bitmap ,ox ,oy int )error {for _dce :=0;_dce < iTarget .Height ;_dce ++{var _gge int ;_ge :=_dce +oy ;var (_acg ,_ea ,_deaf ,_gca ,_def uint16 ;_fdf ,_cbb ,_acc ,_fdg ,_gdb byte ;);if _ge >=1&&(_ge -1)< iTemp .Height {_fdf =iTemp .Data [(_ge -1)*iTemp .RowStride ];
42 | };if _ge >=0&&_ge < iTemp .Height {_cbb =iTemp .Data [_ge *iTemp .RowStride ];};if _ge >=-1&&_ge +1< iTemp .Height {_acc =iTemp .Data [(_ge +1)*iTemp .RowStride ];};if _dce >=1{_fdg =iTarget .Data [(_dce -1)*iTarget .RowStride ];};_gdb =iTarget .Data [_dce *iTarget .RowStride ];
43 | _gb :=uint (6+ox );_acg =uint16 (_fdf >>_gb );_ea =uint16 (_cbb >>_gb );_deaf =uint16 (_acc >>_gb );_gca =uint16 (_fdg >>6);_afg :=uint (2-ox );_fdf <<=_afg ;_cbb <<=_afg ;_acc <<=_afg ;_fdg <<=2;for _gge =0;_gge < iTarget .Width ;_gge ++{_aaeg :=(_acg <<10)|(_ea <<7)|(_deaf <<4)|(_gca <<1)|_def ;
44 | _cg :=_gdb >>7;_cgd :=_gd .encodeBit (_gd ._ad ,uint32 (_aaeg ),_cg );if _cgd !=nil {return _cgd ;};_acg <<=1;_ea <<=1;_deaf <<=1;_gca <<=1;_acg |=uint16 (_fdf >>7);_ea |=uint16 (_cbb >>7);_deaf |=uint16 (_acc >>7);_gca |=uint16 (_fdg >>7);_def =uint16 (_cg );
45 | _gce :=_gge %8;_edd :=_gge /8+1;if _gce ==5+ox {_fdf ,_cbb ,_acc =0,0,0;if _edd < iTemp .RowStride &&_ge >=1&&(_ge -1)< iTemp .Height {_fdf =iTemp .Data [(_ge -1)*iTemp .RowStride +_edd ];};if _edd < iTemp .RowStride &&_ge >=0&&_ge < iTemp .Height {_cbb =iTemp .Data [_ge *iTemp .RowStride +_edd ];
46 | };if _edd < iTemp .RowStride &&_ge >=-1&&(_ge +1)< iTemp .Height {_acc =iTemp .Data [(_ge +1)*iTemp .RowStride +_edd ];};}else {_fdf <<=1;_cbb <<=1;_acc <<=1;};if _gce ==5&&_dce >=1{_fdg =0;if _edd < iTarget .RowStride {_fdg =iTarget .Data [(_dce -1)*iTarget .RowStride +_edd ];
47 | };}else {_fdg <<=1;};if _gce ==7{_gdb =0;if _edd < iTarget .RowStride {_gdb =iTarget .Data [_dce *iTarget .RowStride +_edd ];};}else {_gdb <<=1;};_acg &=7;_ea &=7;_deaf &=7;_gca &=7;};};return nil ;};func (_dcc *Encoder )setBits (){_eag :=_dcc ._aae +uint32 (_dcc ._dc );
48 | _dcc ._aae |=0xffff;if _dcc ._aae >=_eag {_dcc ._aae -=0x8000;};};func (_fdd *Encoder )DataSize ()int {return _fdd .dataSize ()};func (_fgc *Encoder )code0 (_fa *codingContext ,_cdd uint32 ,_ebe uint16 ,_ag byte ){if _fa .mps (_cdd )==0{_fgc .codeMPS (_fa ,_cdd ,_ebe ,_ag );
49 | }else {_fgc .codeLPS (_fa ,_cdd ,_ebe ,_ag );};};var _cgdb =[]state {{0x5601,1,1,1},{0x3401,2,6,0},{0x1801,3,9,0},{0x0AC1,4,12,0},{0x0521,5,29,0},{0x0221,38,33,0},{0x5601,7,6,1},{0x5401,8,14,0},{0x4801,9,14,0},{0x3801,10,14,0},{0x3001,11,17,0},{0x2401,12,18,0},{0x1C01,13,20,0},{0x1601,29,21,0},{0x5601,15,14,1},{0x5401,16,14,0},{0x5101,17,15,0},{0x4801,18,16,0},{0x3801,19,17,0},{0x3401,20,18,0},{0x3001,21,19,0},{0x2801,22,19,0},{0x2401,23,20,0},{0x2201,24,21,0},{0x1C01,25,22,0},{0x1801,26,23,0},{0x1601,27,24,0},{0x1401,28,25,0},{0x1201,29,26,0},{0x1101,30,27,0},{0x0AC1,31,28,0},{0x09C1,32,29,0},{0x08A1,33,30,0},{0x0521,34,31,0},{0x0441,35,32,0},{0x02A1,36,33,0},{0x0221,37,34,0},{0x0141,38,35,0},{0x0111,39,36,0},{0x0085,40,37,0},{0x0049,41,38,0},{0x0025,42,39,0},{0x0015,43,40,0},{0x0009,44,41,0},{0x0005,45,42,0},{0x0001,45,43,0},{0x5601,46,46,0}};
50 | type intEncRangeS struct{_fd ,_ee int ;_eeg ,_dg uint8 ;_b uint16 ;_cb uint8 ;};func (_ceg *Encoder )encodeIAID (_fbf ,_adb int )error {if _ceg ._cdb ==nil {_ceg ._cdb =_df (1<<uint (_fbf ));};_cedg :=uint32 (1<<uint32 (_fbf +1))-1;_adb <<=uint (32-_fbf );
51 | _gba :=uint32 (1);for _fae :=0;_fae < _fbf ;_fae ++{_dffb :=_gba &_cedg ;_baa :=uint8 ((uint32 (_adb )&0x80000000)>>31);if _eddd :=_ceg .encodeBit (_ceg ._cdb ,_dffb ,_baa );_eddd !=nil {return _eddd ;};_gba =(_gba <<1)|uint32 (_baa );_adb <<=1;};return nil ;
52 | };type codingContext struct{_ed []byte ;_ab []byte ;};func (_dfa *Encoder )Init (){_dfa ._ad =_df (_fbea );_dfa ._dc =0x8000;_dfa ._aae =0;_dfa ._ca =12;_dfa ._dcg =-1;_dfa ._abd =0;_dfa ._gac =0;_dfa ._aaa =make ([]byte ,_faf );for _dff :=0;_dff < len (_dfa ._ac );
53 | _dff ++{_dfa ._ac [_dff ]=_df (512);};_dfa ._cdb =nil ;};func New ()*Encoder {_dgd :=&Encoder {};_dgd .Init ();return _dgd };func (_fef *Encoder )emit (){if _fef ._gac ==_faf {_fef ._bf =append (_fef ._bf ,_fef ._aaa );_fef ._aaa =make ([]byte ,_faf );
54 | _fef ._gac =0;};_fef ._aaa [_fef ._gac ]=_fef ._abd ;_fef ._gac ++;};type state struct{_aaef uint16 ;_ace ,_acf uint8 ;_fga uint8 ;};type Class int ;func (_cee *Encoder )EncodeIAID (symbolCodeLength ,value int )(_gc error ){_e .Log .Trace ("\u0045\u006e\u0063\u006f\u0064\u0065\u0020\u0049A\u0049\u0044\u002e S\u0079\u006d\u0062\u006f\u006c\u0043o\u0064\u0065\u004c\u0065\u006e\u0067\u0074\u0068\u003a\u0020\u0027\u0025\u0064\u0027\u002c \u0056\u0061\u006c\u0075\u0065\u003a\u0020\u0027%\u0064\u0027",symbolCodeLength ,value );
55 | if _gc =_cee .encodeIAID (symbolCodeLength ,value );_gc !=nil {return _c .Wrap (_gc ,"\u0045\u006e\u0063\u006f\u0064\u0065\u0049\u0041\u0049\u0044","");};return nil ;};func (_fg *Encoder )EncodeOOB (proc Class )(_afd error ){_e .Log .Trace ("E\u006e\u0063\u006f\u0064\u0065\u0020O\u004f\u0042\u0020\u0077\u0069\u0074\u0068\u0020\u0043l\u0061\u0073\u0073:\u0020'\u0025\u0073\u0027",proc );
56 | if _afd =_fg .encodeOOB (proc );_afd !=nil {return _c .Wrap (_afd ,"\u0045n\u0063\u006f\u0064\u0065\u004f\u004fB","");};return nil ;};func (_gf *Encoder )WriteTo (w _d .Writer )(int64 ,error ){const _dcf ="\u0045n\u0063o\u0064\u0065\u0072\u002e\u0057\u0072\u0069\u0074\u0065\u0054\u006f";
57 | var _eaf int64 ;for _edb ,_eed :=range _gf ._bf {_cbf ,_gcb :=w .Write (_eed );if _gcb !=nil {return 0,_c .Wrapf (_gcb ,_dcf ,"\u0066\u0061\u0069\u006c\u0065\u0064\u0020\u0061\u0074\u0020\u0069'\u0074\u0068\u003a\u0020\u0027\u0025\u0064\u0027\u0020\u0063h\u0075\u006e\u006b",_edb );
58 | };_eaf +=int64 (_cbf );};_gf ._aaa =_gf ._aaa [:_gf ._gac ];_ec ,_ggg :=w .Write (_gf ._aaa );if _ggg !=nil {return 0,_c .Wrap (_ggg ,_dcf ,"\u0062u\u0066f\u0065\u0072\u0065\u0064\u0020\u0063\u0068\u0075\u006e\u006b\u0073");};_eaf +=int64 (_ec );return _eaf ,nil ;
59 | };func (_deb *Encoder )Final (){_deb .flush ()};var _ _d .WriterTo =&Encoder {};func (_edg *Encoder )code1 (_cbd *codingContext ,_cf uint32 ,_age uint16 ,_bfd byte ){if _cbd .mps (_cf )==1{_edg .codeMPS (_cbd ,_cf ,_age ,_bfd );}else {_edg .codeLPS (_cbd ,_cf ,_age ,_bfd );
60 | };};


--------------------------------------------------------------------------------
/internal/jbig2/errors/errors.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | package errors ;import (_g "fmt";_eg "golang.org/x/xerrors";);func Error (processName ,message string )error {return _bf (message ,processName )};type processError struct{_ea string ;_f string ;_b string ;_ee error ;};func Wrap (err error ,processName ,message string )error {if _a ,_eeg :=err .(*processError );
13 | _eeg {_a ._ea ="";};_eab :=_bf (message ,processName );_eab ._ee =err ;return _eab ;};func Errorf (processName ,message string ,arguments ...interface{})error {return _bf (_g .Sprintf (message ,arguments ...),processName );};func _bf (_bb ,_da string )*processError {return &processError {_ea :"\u005b\u0055\u006e\u0069\u0050\u0044\u0046\u005d",_b :_bb ,_f :_da };
14 | };func Wrapf (err error ,processName ,message string ,arguments ...interface{})error {if _ag ,_ed :=err .(*processError );_ed {_ag ._ea ="";};_be :=_bf (_g .Sprintf (message ,arguments ...),processName );_be ._ee =err ;return _be ;};func (_bd *processError )Error ()string {var _dc string ;
15 | if _bd ._ea !=""{_dc =_bd ._ea ;};_dc +="\u0050r\u006f\u0063\u0065\u0073\u0073\u003a "+_bd ._f ;if _bd ._b !=""{_dc +="\u0020\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u003a\u0020"+_bd ._b ;};if _bd ._ee !=nil {_dc +="\u002e\u0020"+_bd ._ee .Error ();};
16 | return _dc ;};var _ _eg .Wrapper =(*processError )(nil );func (_d *processError )Unwrap ()error {return _d ._ee };


--------------------------------------------------------------------------------
/internal/jbig2/internal/internal.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | package internal ;import _f "errors";var ErrOOB =_f .New ("o\u0075\u0074\u0020\u006f\u0066\u0020\u0062\u0061\u006e\u0064");


--------------------------------------------------------------------------------
/internal/jbig2/jbig2.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | package jbig2 ;import (_db "github.com/unidoc/unipdf/v4/internal/bitwise";_g "github.com/unidoc/unipdf/v4/internal/jbig2/decoder";_b "github.com/unidoc/unipdf/v4/internal/jbig2/document";_f "github.com/unidoc/unipdf/v4/internal/jbig2/document/segments";
13 | _a "github.com/unidoc/unipdf/v4/internal/jbig2/errors";_dbb "sort";);func DecodeBytes (encoded []byte ,parameters _g .Parameters ,globals ...Globals )([]byte ,error ){var _e Globals ;if len (globals )> 0{_e =globals [0];};_c ,_df :=_g .Decode (encoded ,parameters ,_e .ToDocumentGlobals ());
14 | if _df !=nil {return nil ,_df ;};return _c .DecodeNextPage ();};type Globals map[int ]*_f .Header ;func (_dg Globals )ToDocumentGlobals ()*_b .Globals {if _dg ==nil {return nil ;};_cg :=[]*_f .Header {};for _ ,_fge :=range _dg {_cg =append (_cg ,_fge );
15 | };_dbb .Slice (_cg ,func (_ga ,_dff int )bool {return _cg [_ga ].SegmentNumber < _cg [_dff ].SegmentNumber });return &_b .Globals {Segments :_cg };};func DecodeGlobals (encoded []byte )(Globals ,error ){const _ab ="\u0044\u0065\u0063\u006f\u0064\u0065\u0047\u006c\u006f\u0062\u0061\u006c\u0073";
16 | _ec :=_db .NewReader (encoded );_bd ,_fg :=_b .DecodeDocument (_ec ,nil );if _fg !=nil {return nil ,_a .Wrap (_fg ,_ab ,"");};if _bd .GlobalSegments ==nil ||(_bd .GlobalSegments .Segments ==nil ){return nil ,_a .Error (_ab ,"\u006eo\u0020\u0067\u006c\u006f\u0062\u0061\u006c\u0020\u0073\u0065\u0067m\u0065\u006e\u0074\u0073\u0020\u0066\u006f\u0075\u006e\u0064");
17 | };_fe :=Globals {};for _ ,_gd :=range _bd .GlobalSegments .Segments {_fe [int (_gd .SegmentNumber )]=_gd ;};return _fe ,nil ;};


--------------------------------------------------------------------------------
/internal/precision/precision.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | package precision ;import _e "math";func RoundFloat (value float64 ,precision int )float64 {_gf :=_e .Pow (10,float64 (precision ));return _e .Round (value *_gf )/_gf ;};func RoundDefault (value float64 )float64 {return RoundFloat (value ,DefaultPrecision )};
13 | const (DefaultPrecision =4;);


--------------------------------------------------------------------------------
/internal/sampling/sampling.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | package sampling ;import (_g "github.com/unidoc/unipdf/v4/internal/bitwise";_ee "github.com/unidoc/unipdf/v4/internal/imageutil";_a "io";);func (_bdb *Writer )WriteSample (sample uint32 )error {if _ ,_fgf :=_bdb ._ebb .WriteBits (uint64 (sample ),_bdb ._ebd .BitsPerComponent );
13 | _fgf !=nil {return _fgf ;};_bdb ._fge --;if _bdb ._fge ==0{_bdb ._fge =_bdb ._ebd .ColorComponents ;_bdb ._fc ++;};if _bdb ._fc ==_bdb ._ebd .Width {if _bdb ._fac {_bdb ._ebb .FinishByte ();};_bdb ._fc =0;};return nil ;};type Writer struct{_ebd _ee .ImageBase ;
14 | _ebb *_g .Writer ;_fc ,_fge int ;_fac bool ;};func (_cdd *Writer )WriteSamples (samples []uint32 )error {for _add :=0;_add < len (samples );_add ++{if _fde :=_cdd .WriteSample (samples [_add ]);_fde !=nil {return _fde ;};};return nil ;};func ResampleBytes (data []byte ,bitsPerSample int )[]uint32 {var _gf []uint32 ;
15 | _bg :=bitsPerSample ;var _bf uint32 ;var _gd byte ;_adb :=0;_ce :=0;_f :=0;for _f < len (data ){if _adb > 0{_bbe :=_adb ;if _bg < _bbe {_bbe =_bg ;};_bf =(_bf <<uint (_bbe ))|uint32 (_gd >>uint (8-_bbe ));_adb -=_bbe ;if _adb > 0{_gd =_gd <<uint (_bbe );
16 | }else {_gd =0;};_bg -=_bbe ;if _bg ==0{_gf =append (_gf ,_bf );_bg =bitsPerSample ;_bf =0;_ce ++;};}else {_fe :=data [_f ];_f ++;_bd :=8;if _bg < _bd {_bd =_bg ;};_adb =8-_bd ;_bf =(_bf <<uint (_bd ))|uint32 (_fe >>uint (_adb ));if _bd < 8{_gd =_fe <<uint (_bd );
17 | };_bg -=_bd ;if _bg ==0{_gf =append (_gf ,_bf );_bg =bitsPerSample ;_bf =0;_ce ++;};};};for _adb >=bitsPerSample {_eaf :=_adb ;if _bg < _eaf {_eaf =_bg ;};_bf =(_bf <<uint (_eaf ))|uint32 (_gd >>uint (8-_eaf ));_adb -=_eaf ;if _adb > 0{_gd =_gd <<uint (_eaf );
18 | }else {_gd =0;};_bg -=_eaf ;if _bg ==0{_gf =append (_gf ,_bf );_bg =bitsPerSample ;_bf =0;_ce ++;};};return _gf ;};func (_bb *Reader )ReadSample ()(uint32 ,error ){if _bb ._eb ==_bb ._ea .Height {return 0,_a .EOF ;};_c ,_ag :=_bb ._gg .ReadBits (byte (_bb ._ea .BitsPerComponent ));
19 | if _ag !=nil {return 0,_ag ;};_bb ._af --;if _bb ._af ==0{_bb ._af =_bb ._ea .ColorComponents ;_bb ._ad ++;};if _bb ._ad ==_bb ._ea .Width {if _bb ._b {_bb ._gg .ConsumeRemainingBits ();};_bb ._ad =0;_bb ._eb ++;};return uint32 (_c ),nil ;};func ResampleUint32 (data []uint32 ,bitsPerInputSample int ,bitsPerOutputSample int )[]uint32 {var _ge []uint32 ;
20 | _bfe :=bitsPerOutputSample ;var _ca uint32 ;var _fd uint32 ;_d :=0;_cd :=0;_ab :=0;for _ab < len (data ){if _d > 0{_fg :=_d ;if _bfe < _fg {_fg =_bfe ;};_ca =(_ca <<uint (_fg ))|(_fd >>uint (bitsPerInputSample -_fg ));_d -=_fg ;if _d > 0{_fd =_fd <<uint (_fg );
21 | }else {_fd =0;};_bfe -=_fg ;if _bfe ==0{_ge =append (_ge ,_ca );_bfe =bitsPerOutputSample ;_ca =0;_cd ++;};}else {_bfc :=data [_ab ];_ab ++;_fa :=bitsPerInputSample ;if _bfe < _fa {_fa =_bfe ;};_d =bitsPerInputSample -_fa ;_ca =(_ca <<uint (_fa ))|(_bfc >>uint (_d ));
22 | if _fa < bitsPerInputSample {_fd =_bfc <<uint (_fa );};_bfe -=_fa ;if _bfe ==0{_ge =append (_ge ,_ca );_bfe =bitsPerOutputSample ;_ca =0;_cd ++;};};};for _d >=bitsPerOutputSample {_dd :=_d ;if _bfe < _dd {_dd =_bfe ;};_ca =(_ca <<uint (_dd ))|(_fd >>uint (bitsPerInputSample -_dd ));
23 | _d -=_dd ;if _d > 0{_fd =_fd <<uint (_dd );}else {_fd =0;};_bfe -=_dd ;if _bfe ==0{_ge =append (_ge ,_ca );_bfe =bitsPerOutputSample ;_ca =0;_cd ++;};};if _bfe > 0&&_bfe < bitsPerOutputSample {_ca <<=uint (_bfe );_ge =append (_ge ,_ca );};return _ge ;};
24 | func NewWriter (img _ee .ImageBase )*Writer {return &Writer {_ebb :_g .NewWriterMSB (img .Data ),_ebd :img ,_fge :img .ColorComponents ,_fac :img .BytesPerLine *8!=img .ColorComponents *img .BitsPerComponent *img .Width };};type SampleReader interface{ReadSample ()(uint32 ,error );
25 | ReadSamples (_ef []uint32 )error ;};type SampleWriter interface{WriteSample (_afc uint32 )error ;WriteSamples (_cg []uint32 )error ;};type Reader struct{_ea _ee .ImageBase ;_gg *_g .Reader ;_ad ,_eb ,_af int ;_b bool ;};func NewReader (img _ee .ImageBase )*Reader {return &Reader {_gg :_g .NewReader (img .Data ),_ea :img ,_af :img .ColorComponents ,_b :img .BytesPerLine *8!=img .ColorComponents *img .BitsPerComponent *img .Width };
26 | };func (_bbb *Reader )ReadSamples (samples []uint32 )(_gc error ){for _ggc :=0;_ggc < len (samples );_ggc ++{samples [_ggc ],_gc =_bbb .ReadSample ();if _gc !=nil {return _gc ;};};return nil ;};


--------------------------------------------------------------------------------
/internal/strutils/strutils.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | package strutils ;import (_g "bytes";_f "github.com/unidoc/unipdf/v4/common";_b "unicode/utf16";);var _fe map[rune ]byte ;func init (){_fe =map[rune ]byte {};for _a ,_fec :=range _ee {_fe [_fec ]=_a ;};};func StringToUTF16 (s string )string {_ag :=_b .Encode ([]rune (s ));
13 | var _gb _g .Buffer ;for _ ,_gg :=range _ag {_gb .WriteByte (byte ((_gg >>8)&0xff));_gb .WriteByte (byte (_gg &0xff));};return _gb .String ();};func StringToPDFDocEncoding (s string )[]byte {var _cga _g .Buffer ;for _ ,_dbc :=range s {_ad ,_ea :=_fe [_dbc ];
14 | if !_ea {_f .Log .Debug ("\u0045\u0052\u0052\u004f\u0052\u003a\u0020\u0050\u0044\u0046\u0044\u006f\u0063\u0045\u006e\u0063\u006f\u0064\u0069\u006eg\u0020\u0072\u0075\u006e\u0065\u0020\u006d\u0061\u0070\u0070\u0069\u006e\u0067\u0020\u006d\u0069\u0073\u0073\u0069\u006e\u0067\u0020\u0025\u0063\u002f\u0025\u0058\u0020\u002d\u0020s\u006b\u0069\u0070\u0070\u0069n\u0067",_dbc ,_dbc );
15 | continue ;};_cga .WriteByte (_ad );};return _cga .Bytes ();};var _ee =map[byte ]rune {0x01:'\u0001',0x02:'\u0002',0x03:'\u0003',0x04:'\u0004',0x05:'\u0005',0x06:'\u0006',0x07:'\u0007',0x08:'\u0008',0x09:'\u0009',0x0a:'\u000a',0x0b:'\u000b',0x0c:'\u000c',0x0d:'\u000d',0x0e:'\u000e',0x0f:'\u000f',0x10:'\u0010',0x11:'\u0011',0x12:'\u0012',0x13:'\u0013',0x14:'\u0014',0x15:'\u0015',0x16:'\u0017',0x17:'\u0017',0x18:'\u02d8',0x19:'\u02c7',0x1a:'\u02c6',0x1b:'\u02d9',0x1c:'\u02dd',0x1d:'\u02db',0x1e:'\u02da',0x1f:'\u02dc',0x20:'\u0020',0x21:'\u0021',0x22:'\u0022',0x23:'\u0023',0x24:'\u0024',0x25:'\u0025',0x26:'\u0026',0x27:'\u0027',0x28:'\u0028',0x29:'\u0029',0x2a:'\u002a',0x2b:'\u002b',0x2c:'\u002c',0x2d:'\u002d',0x2e:'\u002e',0x2f:'\u002f',0x30:'\u0030',0x31:'\u0031',0x32:'\u0032',0x33:'\u0033',0x34:'\u0034',0x35:'\u0035',0x36:'\u0036',0x37:'\u0037',0x38:'\u0038',0x39:'\u0039',0x3a:'\u003a',0x3b:'\u003b',0x3c:'\u003c',0x3d:'\u003d',0x3e:'\u003e',0x3f:'\u003f',0x40:'\u0040',0x41:'\u0041',0x42:'\u0042',0x43:'\u0043',0x44:'\u0044',0x45:'\u0045',0x46:'\u0046',0x47:'\u0047',0x48:'\u0048',0x49:'\u0049',0x4a:'\u004a',0x4b:'\u004b',0x4c:'\u004c',0x4d:'\u004d',0x4e:'\u004e',0x4f:'\u004f',0x50:'\u0050',0x51:'\u0051',0x52:'\u0052',0x53:'\u0053',0x54:'\u0054',0x55:'\u0055',0x56:'\u0056',0x57:'\u0057',0x58:'\u0058',0x59:'\u0059',0x5a:'\u005a',0x5b:'\u005b',0x5c:'\u005c',0x5d:'\u005d',0x5e:'\u005e',0x5f:'\u005f',0x60:'\u0060',0x61:'\u0061',0x62:'\u0062',0x63:'\u0063',0x64:'\u0064',0x65:'\u0065',0x66:'\u0066',0x67:'\u0067',0x68:'\u0068',0x69:'\u0069',0x6a:'\u006a',0x6b:'\u006b',0x6c:'\u006c',0x6d:'\u006d',0x6e:'\u006e',0x6f:'\u006f',0x70:'\u0070',0x71:'\u0071',0x72:'\u0072',0x73:'\u0073',0x74:'\u0074',0x75:'\u0075',0x76:'\u0076',0x77:'\u0077',0x78:'\u0078',0x79:'\u0079',0x7a:'\u007a',0x7b:'\u007b',0x7c:'\u007c',0x7d:'\u007d',0x7e:'\u007e',0x80:'\u2022',0x81:'\u2020',0x82:'\u2021',0x83:'\u2026',0x84:'\u2014',0x85:'\u2013',0x86:'\u0192',0x87:'\u2044',0x88:'\u2039',0x89:'\u203a',0x8a:'\u2212',0x8b:'\u2030',0x8c:'\u201e',0x8d:'\u201c',0x8e:'\u201d',0x8f:'\u2018',0x90:'\u2019',0x91:'\u201a',0x92:'\u2122',0x93:'\ufb01',0x94:'\ufb02',0x95:'\u0141',0x96:'\u0152',0x97:'\u0160',0x98:'\u0178',0x99:'\u017d',0x9a:'\u0131',0x9b:'\u0142',0x9c:'\u0153',0x9d:'\u0161',0x9e:'\u017e',0xa0:'\u20ac',0xa1:'\u00a1',0xa2:'\u00a2',0xa3:'\u00a3',0xa4:'\u00a4',0xa5:'\u00a5',0xa6:'\u00a6',0xa7:'\u00a7',0xa8:'\u00a8',0xa9:'\u00a9',0xaa:'\u00aa',0xab:'\u00ab',0xac:'\u00ac',0xae:'\u00ae',0xaf:'\u00af',0xb0:'\u00b0',0xb1:'\u00b1',0xb2:'\u00b2',0xb3:'\u00b3',0xb4:'\u00b4',0xb5:'\u00b5',0xb6:'\u00b6',0xb7:'\u00b7',0xb8:'\u00b8',0xb9:'\u00b9',0xba:'\u00ba',0xbb:'\u00bb',0xbc:'\u00bc',0xbd:'\u00bd',0xbe:'\u00be',0xbf:'\u00bf',0xc0:'\u00c0',0xc1:'\u00c1',0xc2:'\u00c2',0xc3:'\u00c3',0xc4:'\u00c4',0xc5:'\u00c5',0xc6:'\u00c6',0xc7:'\u00c7',0xc8:'\u00c8',0xc9:'\u00c9',0xca:'\u00ca',0xcb:'\u00cb',0xcc:'\u00cc',0xcd:'\u00cd',0xce:'\u00ce',0xcf:'\u00cf',0xd0:'\u00d0',0xd1:'\u00d1',0xd2:'\u00d2',0xd3:'\u00d3',0xd4:'\u00d4',0xd5:'\u00d5',0xd6:'\u00d6',0xd7:'\u00d7',0xd8:'\u00d8',0xd9:'\u00d9',0xda:'\u00da',0xdb:'\u00db',0xdc:'\u00dc',0xdd:'\u00dd',0xde:'\u00de',0xdf:'\u00df',0xe0:'\u00e0',0xe1:'\u00e1',0xe2:'\u00e2',0xe3:'\u00e3',0xe4:'\u00e4',0xe5:'\u00e5',0xe6:'\u00e6',0xe7:'\u00e7',0xe8:'\u00e8',0xe9:'\u00e9',0xea:'\u00ea',0xeb:'\u00eb',0xec:'\u00ec',0xed:'\u00ed',0xee:'\u00ee',0xef:'\u00ef',0xf0:'\u00f0',0xf1:'\u00f1',0xf2:'\u00f2',0xf3:'\u00f3',0xf4:'\u00f4',0xf5:'\u00f5',0xf6:'\u00f6',0xf7:'\u00f7',0xf8:'\u00f8',0xf9:'\u00f9',0xfa:'\u00fa',0xfb:'\u00fb',0xfc:'\u00fc',0xfd:'\u00fd',0xfe:'\u00fe',0xff:'\u00ff'};
16 | func PDFDocEncodingToRunes (b []byte )[]rune {var _fea []rune ;for _ ,_fb :=range b {_ba ,_fg :=_ee [_fb ];if !_fg {_f .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u003a\u0020P\u0044\u0046\u0044o\u0063\u0045\u006ec\u006f\u0064i\u006e\u0067\u0020\u0069\u006e\u0070u\u0074 m\u0061\u0070\u0070\u0069\u006e\u0067\u0020\u0065\u0072\u0072\u006f\u0072\u0020\u0025\u0064\u0020\u002d\u0020\u0073\u006b\u0069\u0070\u0070\u0069\u006e\u0067",_fb );
17 | continue ;};_fea =append (_fea ,_ba );};return _fea ;};func UTF16ToRunes (b []byte )[]rune {if len (b )==1{return []rune {rune (b [0])};};if len (b )%2!=0{b =append (b ,0);_f .Log .Debug ("E\u0052\u0052\u004f\u0052\u003a\u0020\u0055\u0054\u0046\u0031\u0036\u0054\u006f\u0052\u0075\u006e\u0065\u0073.\u0020\u0050\u0061\u0064\u0064\u0069\u006e\u0067\u0020\u0077it\u0068\u0020\u007ae\u0072o\u0073\u002e");
18 | };_gf :=len (b )>>1;_cg :=make ([]uint16 ,_gf );for _bc :=0;_bc < _gf ;_bc ++{_cg [_bc ]=uint16 (b [_bc <<1])<<8+uint16 (b [_bc <<1+1]);};_fd :=_b .Decode (_cg );return _fd ;};func PDFDocEncodingToString (b []byte )string {return string (PDFDocEncodingToRunes (b ))};
19 | func UTF16ToString (b []byte )string {return string (UTF16ToRunes (b ))};


--------------------------------------------------------------------------------
/internal/testutils/testutils.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | package testutils ;import (_e "crypto/md5";_gb "encoding/hex";_eed "errors";_df "fmt";_da "github.com/unidoc/unipdf/v4/common";_ea "github.com/unidoc/unipdf/v4/core";_fe "image";_eeg "image/png";_d "io";_cc "os";_ee "os/exec";_a "path/filepath";_f "strings";
13 | _c "testing";);func RunRenderTest (t *_c .T ,pdfPath ,outputDir ,baselineRenderPath string ,saveBaseline bool ){_cg :=_f .TrimSuffix (_a .Base (pdfPath ),_a .Ext (pdfPath ));t .Run ("\u0072\u0065\u006e\u0064\u0065\u0072",func (_dd *_c .T ){_bc :=_a .Join (outputDir ,_cg );
14 | _gdb :=_bc +"\u002d%\u0064\u002e\u0070\u006e\u0067";if _ba :=RenderPDFToPNGs (pdfPath ,0,_gdb );_ba !=nil {_dd .Skip (_ba );};for _ec :=1;true ;_ec ++{_bdf :=_df .Sprintf ("\u0025s\u002d\u0025\u0064\u002e\u0070\u006eg",_bc ,_ec );_bdb :=_a .Join (baselineRenderPath ,_df .Sprintf ("\u0025\u0073\u002d\u0025\u0064\u005f\u0065\u0078\u0070\u002e\u0070\u006e\u0067",_cg ,_ec ));
15 | if _ ,_cgc :=_cc .Stat (_bdf );_cgc !=nil {break ;};_dd .Logf ("\u0025\u0073",_bdb );if saveBaseline {_dd .Logf ("\u0043\u006fp\u0079\u0069\u006eg\u0020\u0025\u0073\u0020\u002d\u003e\u0020\u0025\u0073",_bdf ,_bdb );_cga :=CopyFile (_bdf ,_bdb );if _cga !=nil {_dd .Fatalf ("\u0045\u0052\u0052OR\u0020\u0063\u006f\u0070\u0079\u0069\u006e\u0067\u0020\u0074\u006f\u0020\u0025\u0073\u003a\u0020\u0025\u0076",_bdb ,_cga );
16 | };continue ;};_dd .Run (_df .Sprintf ("\u0070\u0061\u0067\u0065\u0025\u0064",_ec ),func (_gf *_c .T ){_gf .Logf ("\u0043o\u006dp\u0061\u0072\u0069\u006e\u0067 \u0025\u0073 \u0076\u0073\u0020\u0025\u0073",_bdf ,_bdb );_gg ,_fca :=ComparePNGFiles (_bdf ,_bdb );
17 | if _cc .IsNotExist (_fca ){_gf .Fatal ("\u0069m\u0061g\u0065\u0020\u0066\u0069\u006ce\u0020\u006di\u0073\u0073\u0069\u006e\u0067");}else if !_gg {_gf .Fatal ("\u0077\u0072\u006f\u006eg \u0070\u0061\u0067\u0065\u0020\u0072\u0065\u006e\u0064\u0065\u0072\u0065\u0064");
18 | };});};});};func CopyFile (src ,dst string )error {_ce ,_fg :=_cc .Open (src );if _fg !=nil {return _fg ;};defer _ce .Close ();_ac ,_fg :=_cc .Create (dst );if _fg !=nil {return _fg ;};defer _ac .Close ();_ ,_fg =_d .Copy (_ac ,_ce );return _fg ;};func ParseIndirectObjects (rawpdf string )(map[int64 ]_ea .PdfObject ,error ){_dbb :=_ea .NewParserFromString (rawpdf );
19 | _aca :=map[int64 ]_ea .PdfObject {};for {_cf ,_afa :=_dbb .ParseIndirectObject ();if _afa !=nil {if _afa ==_d .EOF {break ;};return nil ,_afa ;};switch _cce :=_cf .(type ){case *_ea .PdfIndirectObject :_aca [_cce .ObjectNumber ]=_cf ;case *_ea .PdfObjectStream :_aca [_cce .ObjectNumber ]=_cf ;
20 | };};for _ ,_dff :=range _aca {_fa (_dff ,_aca );};return _aca ,nil ;};func CompareDictionariesDeep (d1 ,d2 *_ea .PdfObjectDictionary )bool {if len (d1 .Keys ())!=len (d2 .Keys ()){_da .Log .Debug ("\u0044\u0069\u0063\u0074\u0020\u0065\u006e\u0074\u0072\u0069\u0065\u0073\u0020\u006d\u0069s\u006da\u0074\u0063\u0068\u0020\u0028\u0025\u0064\u0020\u0021\u003d\u0020\u0025\u0064\u0029",len (d1 .Keys ()),len (d2 .Keys ()));
21 | _da .Log .Debug ("\u0057\u0061s\u0020\u0027\u0025s\u0027\u0020\u0076\u0073\u0020\u0027\u0025\u0073\u0027",d1 .Write (),d2 .Write ());return false ;};for _ ,_gda :=range d1 .Keys (){if _gda =="\u0050\u0061\u0072\u0065\u006e\u0074"{continue ;};_ga :=_ea .TraceToDirectObject (d1 .Get (_gda ));
22 | _gae :=_ea .TraceToDirectObject (d2 .Get (_gda ));if _ga ==nil {_da .Log .Debug ("\u00761\u0020\u0069\u0073\u0020\u006e\u0069l");return false ;};if _gae ==nil {_da .Log .Debug ("\u00762\u0020\u0069\u0073\u0020\u006e\u0069l");return false ;};switch _ada :=_ga .(type ){case *_ea .PdfObjectDictionary :_fad ,_bca :=_gae .(*_ea .PdfObjectDictionary );
23 | if !_bca {_da .Log .Debug ("\u0054\u0079\u0070\u0065 m\u0069\u0073\u006d\u0061\u0074\u0063\u0068\u0020\u0025\u0054\u0020\u0076\u0073\u0020%\u0054",_ga ,_gae );return false ;};if !CompareDictionariesDeep (_ada ,_fad ){return false ;};continue ;case *_ea .PdfObjectArray :_aa ,_ddd :=_gae .(*_ea .PdfObjectArray );
24 | if !_ddd {_da .Log .Debug ("\u00762\u0020n\u006f\u0074\u0020\u0061\u006e\u0020\u0061\u0072\u0072\u0061\u0079");return false ;};if _ada .Len ()!=_aa .Len (){_da .Log .Debug ("\u0061\u0072\u0072\u0061\u0079\u0020\u006c\u0065\u006e\u0067\u0074\u0068\u0020\u006d\u0069s\u006da\u0074\u0063\u0068\u0020\u0028\u0025\u0064\u0020\u0021\u003d\u0020\u0025\u0064\u0029",_ada .Len (),_aa .Len ());
25 | return false ;};for _dae :=0;_dae < _ada .Len ();_dae ++{_efc :=_ea .TraceToDirectObject (_ada .Get (_dae ));_fd :=_ea .TraceToDirectObject (_aa .Get (_dae ));if _cbd ,_dfb :=_efc .(*_ea .PdfObjectDictionary );_dfb {_fab ,_cd :=_fd .(*_ea .PdfObjectDictionary );
26 | if !_cd {return false ;};if !CompareDictionariesDeep (_cbd ,_fab ){return false ;};}else {_fda :=_efc .Write ();_daf :=_fd .Write ();if string (_fda )!=string (_daf ){_da .Log .Debug ("M\u0069\u0073\u006d\u0061tc\u0068 \u0027\u0025\u0073\u0027\u0020!\u003d\u0020\u0027\u0025\u0073\u0027",_fda ,_daf );
27 | return false ;};};};continue ;};if _ga .String ()!=_gae .String (){_da .Log .Debug ("\u006b\u0065y\u003d\u0025\u0073\u0020\u004d\u0069\u0073\u006d\u0061\u0074\u0063\u0068\u0021\u0020\u0027\u0025\u0073\u0027\u0020\u0021\u003d\u0020'%\u0073\u0027",_gda ,_ga .String (),_gae .String ());
28 | _da .Log .Debug ("\u0046o\u0072 \u0027\u0025\u0054\u0027\u0020\u002d\u0020\u0027\u0025\u0054\u0027",_ga ,_gae );_da .Log .Debug ("\u0046\u006f\u0072\u0020\u0027\u0025\u002b\u0076\u0027\u0020\u002d\u0020'\u0025\u002b\u0076\u0027",_ga ,_gae );return false ;
29 | };};return true ;};func ReadPNG (file string )(_fe .Image ,error ){_ff ,_ad :=_cc .Open (file );if _ad !=nil {return nil ,_ad ;};defer _ff .Close ();return _eeg .Decode (_ff );};func _fa (_be _ea .PdfObject ,_dac map[int64 ]_ea .PdfObject )error {switch _ced :=_be .(type ){case *_ea .PdfIndirectObject :_eea :=_ced ;
30 | _fa (_eea .PdfObject ,_dac );case *_ea .PdfObjectDictionary :_gfb :=_ced ;for _ ,_bac :=range _gfb .Keys (){_cbg :=_gfb .Get (_bac );if _afb ,_ecb :=_cbg .(*_ea .PdfObjectReference );_ecb {_cgb ,_eac :=_dac [_afb .ObjectNumber ];if !_eac {return _eed .New ("r\u0065\u0066\u0065\u0072\u0065\u006ec\u0065\u0020\u0074\u006f\u0020\u006f\u0075\u0074\u0073i\u0064\u0065\u0020o\u0062j\u0065\u0063\u0074");
31 | };_gfb .Set (_bac ,_cgb );}else {_fa (_cbg ,_dac );};};case *_ea .PdfObjectArray :_ebd :=_ced ;for _fcd ,_adg :=range _ebd .Elements (){if _bg ,_bfg :=_adg .(*_ea .PdfObjectReference );_bfg {_fga ,_ccd :=_dac [_bg .ObjectNumber ];if !_ccd {return _eed .New ("r\u0065\u0066\u0065\u0072\u0065\u006ec\u0065\u0020\u0074\u006f\u0020\u006f\u0075\u0074\u0073i\u0064\u0065\u0020o\u0062j\u0065\u0063\u0074");
32 | };_ebd .Set (_fcd ,_fga );}else {_fa (_adg ,_dac );};};};return nil ;};func HashFile (file string )(string ,error ){_gd ,_gbc :=_cc .Open (file );if _gbc !=nil {return "",_gbc ;};defer _gd .Close ();_cea :=_e .New ();if _ ,_gbc =_d .Copy (_cea ,_gd );_gbc !=nil {return "",_gbc ;
33 | };return _gb .EncodeToString (_cea .Sum (nil )),nil ;};func CompareImages (img1 ,img2 _fe .Image )(bool ,error ){_eb :=img1 .Bounds ();_fc :=0;for _b :=0;_b < _eb .Size ().X ;_b ++{for _fcc :=0;_fcc < _eb .Size ().Y ;_fcc ++{_bd ,_bb ,_eef ,_ :=img1 .At (_b ,_fcc ).RGBA ();
34 | _db ,_ffe ,_af ,_ :=img2 .At (_b ,_fcc ).RGBA ();if _bd !=_db ||_bb !=_ffe ||_eef !=_af {_fc ++;};};};_bf :=float64 (_fc )/float64 (_eb .Dx ()*_eb .Dy ());if _bf > 0.0001{_df .Printf ("\u0064\u0069\u0066f \u0066\u0072\u0061\u0063\u0074\u0069\u006f\u006e\u003a\u0020\u0025\u0076\u0020\u0028\u0025\u0064\u0029\u000a",_bf ,_fc );
35 | return false ,nil ;};return true ,nil ;};func ComparePNGFiles (file1 ,file2 string )(bool ,error ){_dg ,_bbd :=HashFile (file1 );if _bbd !=nil {return false ,_bbd ;};_eg ,_bbd :=HashFile (file2 );if _bbd !=nil {return false ,_bbd ;};if _dg ==_eg {return true ,nil ;
36 | };_afd ,_bbd :=ReadPNG (file1 );if _bbd !=nil {return false ,_bbd ;};_gc ,_bbd :=ReadPNG (file2 );if _bbd !=nil {return false ,_bbd ;};if _afd .Bounds ()!=_gc .Bounds (){return false ,nil ;};return CompareImages (_afd ,_gc );};func RenderPDFToPNGs (pdfPath string ,dpi int ,outpathTpl string )error {if dpi <=0{dpi =100;
37 | };if _ ,_egb :=_ee .LookPath ("\u0067\u0073");_egb !=nil {return ErrRenderNotSupported ;};return _ee .Command ("\u0067\u0073","\u002d\u0073\u0044\u0045\u0056\u0049\u0043\u0045\u003d\u0070\u006e\u0067a\u006c\u0070\u0068\u0061","\u002d\u006f",outpathTpl ,_df .Sprintf ("\u002d\u0072\u0025\u0064",dpi ),pdfPath ).Run ();
38 | };var (ErrRenderNotSupported =_eed .New ("\u0072\u0065\u006e\u0064\u0065r\u0069\u006e\u0067\u0020\u0050\u0044\u0046\u0020\u0066\u0069\u006c\u0065\u0073 \u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064\u0020\u006f\u006e\u0020\u0074\u0068\u0069\u0073\u0020\u0073\u0079\u0073\u0074\u0065m");
39 | );


--------------------------------------------------------------------------------
/internal/textencoding/internal/syncmap/syncmap.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | package syncmap ;import _c "sync";func (_eg *StringsMap )Write (g1 ,g2 string ){_eg ._cagf .Lock ();defer _eg ._cagf .Unlock ();_eg ._cag [g1 ]=g2 ;};func (_fd *RuneSet )Exists (r rune )bool {_fd ._gc .RLock ();defer _fd ._gc .RUnlock ();_ ,_gfb :=_fd ._gbb [r ];
13 | return _gfb ;};func MakeRuneSet (length int )*RuneSet {return &RuneSet {_gbb :make (map[rune ]struct{},length )}};func (_gb *ByteRuneMap )Read (b byte )(rune ,bool ){_gb ._a .RLock ();defer _gb ._a .RUnlock ();_f ,_cf :=_gb ._b [b ];return _f ,_cf ;};func (_ba *RuneByteMap )Read (r rune )(byte ,bool ){_ba ._dgb .RLock ();
14 | defer _ba ._dgb .RUnlock ();_ff ,_ac :=_ba ._ae [r ];return _ff ,_ac ;};func (_gd *RuneStringMap )Range (f func (_ed rune ,_aac string )(_cea bool )){_gd ._cc .RLock ();defer _gd ._cc .RUnlock ();for _ffg ,_fcd :=range _gd ._gg {if f (_ffg ,_fcd ){break ;
15 | };};};func (_cd *RuneUint16Map )Read (r rune )(uint16 ,bool ){_cd ._aee .RLock ();defer _cd ._aee .RUnlock ();_ggb ,_bb :=_cd ._ef [r ];return _ggb ,_bb ;};type RuneByteMap struct{_ae map[rune ]byte ;_dgb _c .RWMutex ;};func (_baa *RuneByteMap )Write (r rune ,b byte ){_baa ._dgb .Lock ();
16 | defer _baa ._dgb .Unlock ();_baa ._ae [r ]=b ;};func (_cae *RuneSet )Write (r rune ){_cae ._gc .Lock ();defer _cae ._gc .Unlock ();_cae ._gbb [r ]=struct{}{};};func (_dde *RuneUint16Map )Delete (r rune ){_dde ._aee .Lock ();defer _dde ._aee .Unlock ();
17 | delete (_dde ._ef ,r );};func NewStringRuneMap (m map[string ]rune )*StringRuneMap {return &StringRuneMap {_fce :m }};func MakeRuneByteMap (length int )*RuneByteMap {_dd :=make (map[rune ]byte ,length );return &RuneByteMap {_ae :_dd };};func (_bac *StringRuneMap )Read (g string )(rune ,bool ){_bac ._bad .RLock ();
18 | defer _bac ._bad .RUnlock ();_gge ,_eda :=_bac ._fce [g ];return _gge ,_eda ;};func (_cg *RuneStringMap )Write (r rune ,s string ){_cg ._cc .Lock ();defer _cg ._cc .Unlock ();_cg ._gg [r ]=s ;};type ByteRuneMap struct{_b map[byte ]rune ;_a _c .RWMutex ;
19 | };func MakeByteRuneMap (length int )*ByteRuneMap {return &ByteRuneMap {_b :make (map[byte ]rune ,length )}};type RuneStringMap struct{_gg map[rune ]string ;_cc _c .RWMutex ;};func (_ca *ByteRuneMap )Write (b byte ,r rune ){_ca ._a .Lock ();defer _ca ._a .Unlock ();
20 | _ca ._b [b ]=r };func (_efa *StringRuneMap )Write (g string ,r rune ){_efa ._bad .Lock ();defer _efa ._bad .Unlock ();_efa ._fce [g ]=r ;};func NewStringsMap (tuples []StringsTuple )*StringsMap {_de :=map[string ]string {};for _ ,_agf :=range tuples {_de [_agf .Key ]=_agf .Value ;
21 | };return &StringsMap {_cag :_de };};func MakeRuneUint16Map (length int )*RuneUint16Map {return &RuneUint16Map {_ef :make (map[rune ]uint16 ,length )};};func (_dcg *StringsMap )Read (g string )(string ,bool ){_dcg ._cagf .RLock ();defer _dcg ._cagf .RUnlock ();
22 | _cbc ,_bcf :=_dcg ._cag [g ];return _cbc ,_bcf ;};func (_fde *RuneStringMap )Read (r rune )(string ,bool ){_fde ._cc .RLock ();defer _fde ._cc .RUnlock ();_gbf ,_ga :=_fde ._gg [r ];return _gbf ,_ga ;};func (_gba *StringsMap )Range (f func (_cgg ,_cgc string )(_aaeg bool )){_gba ._cagf .RLock ();
23 | defer _gba ._cagf .RUnlock ();for _cec ,_bcb :=range _gba ._cag {if f (_cec ,_bcb ){break ;};};};func (_ccf *StringsMap )Copy ()*StringsMap {_ccf ._cagf .RLock ();defer _ccf ._cagf .RUnlock ();_caef :=map[string ]string {};for _dbd ,_eaf :=range _ccf ._cag {_caef [_dbd ]=_eaf ;
24 | };return &StringsMap {_cag :_caef };};func (_cef *RuneUint16Map )RangeDelete (f func (_ddd rune ,_gca uint16 )(_ge bool ,_bcc bool )){_cef ._aee .Lock ();defer _cef ._aee .Unlock ();for _gbbb ,_da :=range _cef ._ef {_dc ,_fb :=f (_gbbb ,_da );if _dc {delete (_cef ._ef ,_gbbb );
25 | };if _fb {break ;};};};func (_cbb *RuneSet )Length ()int {_cbb ._gc .RLock ();defer _cbb ._gc .RUnlock ();return len (_cbb ._gbb )};func (_bgf *RuneByteMap )Length ()int {_bgf ._dgb .RLock ();defer _bgf ._dgb .RUnlock ();return len (_bgf ._ae );};func NewRuneStringMap (m map[rune ]string )*RuneStringMap {return &RuneStringMap {_gg :m }};
26 | type RuneUint16Map struct{_ef map[rune ]uint16 ;_aee _c .RWMutex ;};type StringRuneMap struct{_fce map[string ]rune ;_bad _c .RWMutex ;};func (_df *StringRuneMap )Range (f func (_cdd string ,_baf rune )(_cgd bool )){_df ._bad .RLock ();defer _df ._bad .RUnlock ();
27 | for _ad ,_fbd :=range _df ._fce {if f (_ad ,_fbd ){break ;};};};func (_db *RuneStringMap )Length ()int {_db ._cc .RLock ();defer _db ._cc .RUnlock ();return len (_db ._gg )};type StringsMap struct{_cag map[string ]string ;_cagf _c .RWMutex ;};func (_ea *RuneUint16Map )Write (r rune ,g uint16 ){_ea ._aee .Lock ();
28 | defer _ea ._aee .Unlock ();_ea ._ef [r ]=g ;};func (_gdd *RuneUint16Map )Range (f func (_aae rune ,_fe uint16 )(_abg bool )){_gdd ._aee .RLock ();defer _gdd ._aee .RUnlock ();for _ag ,_bbb :=range _gdd ._ef {if f (_ag ,_bbb ){break ;};};};func NewByteRuneMap (m map[byte ]rune )*ByteRuneMap {return &ByteRuneMap {_b :m }};
29 | func (_be *RuneByteMap )Range (f func (_ab rune ,_aa byte )(_cb bool )){_be ._dgb .RLock ();defer _be ._dgb .RUnlock ();for _beg ,_cad :=range _be ._ae {if f (_beg ,_cad ){break ;};};};type RuneSet struct{_gbb map[rune ]struct{};_gc _c .RWMutex ;};func (_dg *ByteRuneMap )Length ()int {_dg ._a .RLock ();
30 | defer _dg ._a .RUnlock ();return len (_dg ._b )};type StringsTuple struct{Key ,Value string ;};func (_gf *ByteRuneMap )Range (f func (_bd byte ,_d rune )(_fc bool )){_gf ._a .RLock ();defer _gf ._a .RUnlock ();for _bg ,_bc :=range _gf ._b {if f (_bg ,_bc ){break ;
31 | };};};func (_bf *RuneSet )Range (f func (_fff rune )(_bce bool )){_bf ._gc .RLock ();defer _bf ._gc .RUnlock ();for _ce :=range _bf ._gbb {if f (_ce ){break ;};};};func (_cce *StringRuneMap )Length ()int {_cce ._bad .RLock ();defer _cce ._bad .RUnlock ();
32 | return len (_cce ._fce );};func (_cbe *RuneUint16Map )Length ()int {_cbe ._aee .RLock ();defer _cbe ._aee .RUnlock ();return len (_cbe ._ef );};


--------------------------------------------------------------------------------
/internal/timeutils/timeutils.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | package timeutils ;import (_d "errors";_fd "fmt";_dfa "regexp";_df "strconv";_f "time";);func FormatPdfTime (in _f .Time )string {_c :=in .Format ("\u002d\u0030\u0037\u003a\u0030\u0030");_a ,_ :=_df .ParseInt (_c [1:3],10,32);_db ,_ :=_df .ParseInt (_c [4:6],10,32);
13 | _bg :=int64 (in .Year ());_fed :=int64 (in .Month ());_g :=int64 (in .Day ());_ad :=int64 (in .Hour ());_bc :=int64 (in .Minute ());_aa :=int64 (in .Second ());_bgf :=_c [0];return _fd .Sprintf ("\u0044\u003a\u0025\u002e\u0034\u0064\u0025\u002e\u0032\u0064\u0025\u002e\u0032\u0064\u0025\u002e\u0032\u0064\u0025\u002e\u0032\u0064\u0025\u002e2\u0064\u0025\u0063\u0025\u002e2\u0064\u0027%\u002e\u0032\u0064\u0027",_bg ,_fed ,_g ,_ad ,_bc ,_aa ,_bgf ,_a ,_db );
14 | };var _eb =_dfa .MustCompile ("\u005cs\u002a\u0044\u005cs\u002a\u003a\u005cs\u002a(\\\u0064\u007b\u0034\u007d\u0029\u0028\u005cd\u007b\u0032\u007d\u0029\u0028\u005c\u0064\u007b\u0032\u007d\u0029\u0028\u005c\u0064\u007b\u0032\u007d\u0029\u0028\u005c\u0064\u007b\u0032\u007d\u0029\u0028\u005c\u0064{2\u007d)\u003f\u0028\u005b\u002b\u002d\u005a]\u0029\u003f\u0028\u005c\u0064{\u0032\u007d\u0029\u003f\u0027\u003f\u0028\u005c\u0064\u007b\u0032}\u0029\u003f");
15 | func ParsePdfTime (pdfTime string )(_f .Time ,error ){_fde :=_eb .FindAllStringSubmatch (pdfTime ,1);if len (_fde )< 1{if len (pdfTime )> 0&&pdfTime [0]!='D'{pdfTime =_fd .Sprintf ("\u0044\u003a\u0025\u0073",pdfTime );return ParsePdfTime (pdfTime );};return _f .Time {},_fd .Errorf ("\u0069n\u0076\u0061\u006c\u0069\u0064\u0020\u0064\u0061\u0074\u0065\u0020s\u0074\u0072\u0069\u006e\u0067\u0020\u0028\u0025\u0073\u0029",pdfTime );
16 | };if len (_fde [0])!=10{return _f .Time {},_d .New ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0072\u0065\u0067\u0065\u0078p\u0020\u0067\u0072\u006f\u0075\u0070 \u006d\u0061\u0074\u0063\u0068\u0020\u006c\u0065\u006e\u0067\u0074\u0068\u0020!\u003d\u0020\u0031\u0030");
17 | };_eg ,_ :=_df .ParseInt (_fde [0][1],10,32);_bcf ,_ :=_df .ParseInt (_fde [0][2],10,32);_ae ,_ :=_df .ParseInt (_fde [0][3],10,32);_ba ,_ :=_df .ParseInt (_fde [0][4],10,32);_de ,_ :=_df .ParseInt (_fde [0][5],10,32);_ea ,_ :=_df .ParseInt (_fde [0][6],10,32);
18 | var (_fdb byte ;_fg int64 ;_ed int64 ;);_fdb ='+';if len (_fde [0][7])> 0{if _fde [0][7]=="\u002d"{_fdb ='-';}else if _fde [0][7]=="\u005a"{_fdb ='Z';};};if len (_fde [0][8])> 0{_fg ,_ =_df .ParseInt (_fde [0][8],10,32);}else {_fg =0;};if len (_fde [0][9])> 0{_ed ,_ =_df .ParseInt (_fde [0][9],10,32);
19 | }else {_ed =0;};_cb :=int (_fg *60*60+_ed *60);switch _fdb {case '-':_cb =-_cb ;case 'Z':_cb =0;};_gcg :=_fd .Sprintf ("\u0055\u0054\u0043\u0025\u0063\u0025\u002e\u0032\u0064\u0025\u002e\u0032\u0064",_fdb ,_fg ,_ed );_ca :=_f .FixedZone (_gcg ,_cb );return _f .Date (int (_eg ),_f .Month (_bcf ),int (_ae ),int (_ba ),int (_de ),int (_ea ),0,_ca ),nil ;
20 | };


--------------------------------------------------------------------------------
/internal/transform/transform.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | package transform ;import (_g "fmt";_bc "github.com/unidoc/unipdf/v4/common";_d "math";);func (_db *Matrix )Shear (x ,y float64 ){_db .Concat (ShearMatrix (x ,y ))};func (_dd *Point )Transform (a ,b ,c ,d ,tx ,ty float64 ){_dc :=NewMatrix (a ,b ,c ,d ,tx ,ty );
13 | _dd .transformByMatrix (_dc );};const _cgf =1e-10;func (_ge Matrix )String ()string {_gb ,_e ,_df ,_eg ,_ae ,_cgg :=_ge [0],_ge [1],_ge [3],_ge [4],_ge [6],_ge [7];return _g .Sprintf ("\u005b\u00257\u002e\u0034\u0066\u002c%\u0037\u002e4\u0066\u002c\u0025\u0037\u002e\u0034\u0066\u002c%\u0037\u002e\u0034\u0066\u003a\u0025\u0037\u002e\u0034\u0066\u002c\u00257\u002e\u0034\u0066\u005d",_gb ,_e ,_df ,_eg ,_ae ,_cgg );
14 | };type Point struct{X float64 ;Y float64 ;};func (_gbc Matrix )Mult (b Matrix )Matrix {_gbc .Concat (b );return _gbc };func ScaleMatrix (x ,y float64 )Matrix {return NewMatrix (x ,0,0,y ,0,0)};func (_ed *Matrix )clampRange (){for _ce ,_gg :=range _ed {if _gg > _gba {_bc .Log .Debug ("\u0043L\u0041M\u0050\u003a\u0020\u0025\u0067\u0020\u002d\u003e\u0020\u0025\u0067",_gg ,_gba );
15 | _ed [_ce ]=_gba ;}else if _gg < -_gba {_bc .Log .Debug ("\u0043L\u0041M\u0050\u003a\u0020\u0025\u0067\u0020\u002d\u003e\u0020\u0025\u0067",_gg ,-_gba );_ed [_ce ]=-_gba ;};};};func (_gf Matrix )Scale (xScale ,yScale float64 )Matrix {return _gf .Mult (ScaleMatrix (xScale ,yScale ))};
16 | func (_a Matrix )Identity ()bool {return _a [0]==1&&_a [1]==0&&_a [2]==0&&_a [3]==0&&_a [4]==1&&_a [5]==0&&_a [6]==0&&_a [7]==0&&_a [8]==1;};func (_ga Matrix )Translate (tx ,ty float64 )Matrix {return _ga .Mult (TranslationMatrix (tx ,ty ))};func (_bf *Matrix )Concat (b Matrix ){*_bf =Matrix {b [0]*_bf [0]+b [1]*_bf [3],b [0]*_bf [1]+b [1]*_bf [4],0,b [3]*_bf [0]+b [4]*_bf [3],b [3]*_bf [1]+b [4]*_bf [4],0,b [6]*_bf [0]+b [7]*_bf [3]+_bf [6],b [6]*_bf [1]+b [7]*_bf [4]+_bf [7],1};
17 | _bf .clampRange ();};func (_gaf Matrix )Angle ()float64 {_cc :=_d .Atan2 (-_gaf [1],_gaf [0]);if _cc < 0.0{_cc +=2*_d .Pi ;};return _cc /_d .Pi *180.0;};const _gba =1e9;func (_bg *Matrix )Set (a ,b ,c ,d ,tx ,ty float64 ){_bg [0],_bg [1]=a ,b ;_bg [3],_bg [4]=c ,d ;
18 | _bg [6],_bg [7]=tx ,ty ;_bg .clampRange ();};type Matrix [9]float64 ;func (_ecg Matrix )ScalingFactorY ()float64 {return _d .Hypot (_ecg [3],_ecg [4])};func (_gag Matrix )Inverse ()(Matrix ,bool ){_ea ,_f :=_gag [0],_gag [1];_da ,_ecb :=_gag [3],_gag [4];
19 | _aa ,_gfc :=_gag [6],_gag [7];_bcg :=_ea *_ecb -_f *_da ;if _d .Abs (_bcg )< _gdf {return Matrix {},false ;};_gea ,_fb :=_ecb /_bcg ,-_f /_bcg ;_dbe ,_cd :=-_da /_bcg ,_ea /_bcg ;_bfe :=-(_gea *_aa +_dbe *_gfc );_bac :=-(_fb *_aa +_cd *_gfc );return NewMatrix (_gea ,_fb ,_dbe ,_cd ,_bfe ,_bac ),true ;
20 | };func IdentityMatrix ()Matrix {return NewMatrix (1,0,0,1,0,0)};func NewPoint (x ,y float64 )Point {return Point {X :x ,Y :y }};func ShearMatrix (x ,y float64 )Matrix {return NewMatrix (1,y ,x ,1,0,0)};func (_geab *Point )transformByMatrix (_fc Matrix ){_geab .X ,_geab .Y =_fc .Transform (_geab .X ,_geab .Y )};
21 | func TranslationMatrix (tx ,ty float64 )Matrix {return NewMatrix (1,0,0,1,tx ,ty )};func (_ca Point )Interpolate (b Point ,t float64 )Point {return Point {X :(1-t )*_ca .X +t *b .X ,Y :(1-t )*_ca .Y +t *b .Y };};func (_cf *Matrix )Clone ()Matrix {return NewMatrix (_cf [0],_cf [1],_cf [3],_cf [4],_cf [6],_cf [7])};
22 | func (_c Matrix )Round (precision float64 )Matrix {for _be :=range _c {_c [_be ]=_d .Round (_c [_be ]/precision )*precision ;};return _c ;};func (_ege Point )Displace (delta Point )Point {return Point {_ege .X +delta .X ,_ege .Y +delta .Y }};func (_ba Matrix )Singular ()bool {return _d .Abs (_ba [0]*_ba [4]-_ba [1]*_ba [3])< _cgf };
23 | const _gdf =1.0e-6;const _ebd =1e-6;func (_aea Point )String ()string {return _g .Sprintf ("(\u0025\u002e\u0032\u0066\u002c\u0025\u002e\u0032\u0066\u0029",_aea .X ,_aea .Y );};func (_dbeg Matrix )Unrealistic ()bool {_bb ,_de ,_eb ,_deb :=_d .Abs (_dbeg [0]),_d .Abs (_dbeg [1]),_d .Abs (_dbeg [3]),_d .Abs (_dbeg [4]);
24 | _bed :=_bb > _ebd &&_deb > _ebd ;_gdd :=_de > _ebd &&_eb > _ebd ;return !(_bed ||_gdd );};func RotationMatrix (angle float64 )Matrix {_gd :=_d .Cos (angle );_beb :=_d .Sin (angle );return NewMatrix (_gd ,_beb ,-_beb ,_gd ,0,0);};func NewMatrixFromTransforms (xScale ,yScale ,theta ,tx ,ty float64 )Matrix {return IdentityMatrix ().Scale (xScale ,yScale ).Rotate (theta ).Translate (tx ,ty );
25 | };func NewMatrix (a ,b ,c ,d ,tx ,ty float64 )Matrix {_cg :=Matrix {a ,b ,0,c ,d ,0,tx ,ty ,1};_cg .clampRange ();return _cg ;};func (_cgc Matrix )Rotate (theta float64 )Matrix {return _cgc .Mult (RotationMatrix (theta ))};func (_gec Point )Distance (b Point )float64 {return _d .Hypot (_gec .X -b .X ,_gec .Y -b .Y )};
26 | func (_bfd Matrix )Transform (x ,y float64 )(float64 ,float64 ){_bd :=x *_bfd [0]+y *_bfd [3]+_bfd [6];_bcf :=x *_bfd [1]+y *_bfd [4]+_bfd [7];return _bd ,_bcf ;};func (_aef Matrix )Translation ()(float64 ,float64 ){return _aef [6],_aef [7]};func (_ad Point )Rotate (theta float64 )Point {_ede :=_d .Hypot (_ad .X ,_ad .Y );
27 | _dba :=_d .Atan2 (_ad .Y ,_ad .X );_egb ,_ecgc :=_d .Sincos (_dba +theta /180.0*_d .Pi );return Point {_ede *_ecgc ,_ede *_egb };};func (_ec Matrix )ScalingFactorX ()float64 {return _d .Hypot (_ec [0],_ec [1])};func (_dbg *Point )Set (x ,y float64 ){_dbg .X ,_dbg .Y =x ,y };
28 | 


--------------------------------------------------------------------------------
/internal/uuid/uuid.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | package uuid ;import (_f "crypto/rand";_ec "encoding/hex";_fc "io";);var Nil =_fb ;func (_a UUID )String ()string {var _ef [36]byte ;_bg (_ef [:],_a );return string (_ef [:])};func _bg (_ad []byte ,_c UUID ){_ec .Encode (_ad ,_c [:4]);_ad [8]='-';_ec .Encode (_ad [9:13],_c [4:6]);
13 | _ad [13]='-';_ec .Encode (_ad [14:18],_c [6:8]);_ad [18]='-';_ec .Encode (_ad [19:23],_c [8:10]);_ad [23]='-';_ec .Encode (_ad [24:],_c [10:]);};func NewUUID ()(UUID ,error ){var uuid UUID ;_ ,_d :=_fc .ReadFull (_g ,uuid [:]);if _d !=nil {return _fb ,_d ;
14 | };uuid [6]=(uuid [6]&0x0f)|0x40;uuid [8]=(uuid [8]&0x3f)|0x80;return uuid ,nil ;};type UUID [16]byte ;func MustUUID ()UUID {uuid ,_fd :=NewUUID ();if _fd !=nil {panic (_fd );};return uuid ;};var _fb UUID ;var _g =_f .Reader ;


--------------------------------------------------------------------------------
/model/internal/docutil/docutil.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | package docutil ;import (_f "errors";_c "fmt";_a "github.com/unidoc/unipdf/v4/common";_b "github.com/unidoc/unipdf/v4/core";);func (_abf *Document )AddStream (stream *_b .PdfObjectStream ){for _ ,_agdf :=range _abf .Objects {if _agdf ==stream {return ;
13 | };};_abf .Objects =append (_abf .Objects ,stream );};func (_eg *Catalog )GetMetadata ()(*_b .PdfObjectStream ,bool ){return _b .GetStream (_eg .Object .Get ("\u004d\u0065\u0074\u0061\u0064\u0061\u0074\u0061"));};func (_gfb *Page )Number ()int {return _gfb ._bbf };
14 | func (_ab *Catalog )SetMetadata (data []byte )error {_gf ,_ga :=_b .MakeStream (data ,nil );if _ga !=nil {return _ga ;};_gf .Set ("\u0054\u0079\u0070\u0065",_b .MakeName ("\u004d\u0065\u0074\u0061\u0064\u0061\u0074\u0061"));_gf .Set ("\u0053u\u0062\u0074\u0079\u0070\u0065",_b .MakeName ("\u0058\u004d\u004c"));
15 | _ab .Object .Set ("\u004d\u0065\u0074\u0061\u0064\u0061\u0074\u0061",_gf );_ab ._fd .Objects =append (_ab ._fd .Objects ,_gf );return nil ;};func (_fbe *Document )FindCatalog ()(*Catalog ,bool ){var _gaa *_b .PdfObjectDictionary ;for _ ,_ge :=range _fbe .Objects {_dcf ,_egd :=_b .GetDict (_ge );
16 | if !_egd {continue ;};if _eef ,_cd :=_b .GetName (_dcf .Get ("\u0054\u0079\u0070\u0065"));_cd &&*_eef =="\u0043a\u0074\u0061\u006c\u006f\u0067"{_gaa =_dcf ;break ;};};if _gaa ==nil {return nil ,false ;};return &Catalog {Object :_gaa ,_fd :_fbe },true ;
17 | };func (_ddb *OutputIntents )Get (i int )(OutputIntent ,bool ){if _ddb ._eb ==nil {return OutputIntent {},false ;};if i >=_ddb ._eb .Len (){return OutputIntent {},false ;};_gbb :=_ddb ._eb .Get (i );_ddbf ,_bbe :=_b .GetIndirect (_gbb );if !_bbe {_ebb ,_fda :=_b .GetDict (_gbb );
18 | return OutputIntent {Object :_ebb },_fda ;};_ced ,_cf :=_b .GetDict (_ddbf .PdfObject );return OutputIntent {Object :_ced },_cf ;};func (_ece *Document )GetPages ()([]Page ,bool ){_dad ,_aed :=_ece .FindCatalog ();if !_aed {return nil ,false ;};return _dad .GetPages ();
19 | };func (_cdad *Document )AddIndirectObject (indirect *_b .PdfIndirectObject ){for _ ,_ea :=range _cdad .Objects {if _ea ==indirect {return ;};};_cdad .Objects =append (_cdad .Objects ,indirect );};func _bac (_fc _b .PdfObject )(_b .PdfObjectName ,error ){var _fe *_b .PdfObjectName ;
20 | var _gc *_b .PdfObjectArray ;if _ggd ,_ca :=_fc .(*_b .PdfIndirectObject );_ca {if _gaaa ,_ebg :=_ggd .PdfObject .(*_b .PdfObjectArray );_ebg {_gc =_gaaa ;}else if _aea ,_dcg :=_ggd .PdfObject .(*_b .PdfObjectName );_dcg {_fe =_aea ;};}else if _dca ,_adad :=_fc .(*_b .PdfObjectArray );
21 | _adad {_gc =_dca ;}else if _fee ,_ebe :=_fc .(*_b .PdfObjectName );_ebe {_fe =_fee ;};if _fe !=nil {switch *_fe {case "\u0044\u0065\u0076\u0069\u0063\u0065\u0047\u0072\u0061\u0079","\u0044e\u0076\u0069\u0063\u0065\u0052\u0047B","\u0044\u0065\u0076\u0069\u0063\u0065\u0043\u004d\u0059\u004b":return *_fe ,nil ;
22 | case "\u0050a\u0074\u0074\u0065\u0072\u006e":return *_fe ,nil ;};};if _gc !=nil &&_gc .Len ()> 0{if _ffa ,_bad :=_gc .Get (0).(*_b .PdfObjectName );_bad {switch *_ffa {case "\u0044\u0065\u0076\u0069\u0063\u0065\u0047\u0072\u0061\u0079","\u0044e\u0076\u0069\u0063\u0065\u0052\u0047B","\u0044\u0065\u0076\u0069\u0063\u0065\u0043\u004d\u0059\u004b":if _gc .Len ()==1{return *_ffa ,nil ;
23 | };case "\u0043a\u006c\u0047\u0072\u0061\u0079","\u0043\u0061\u006c\u0052\u0047\u0042","\u004c\u0061\u0062":return *_ffa ,nil ;case "\u0049\u0043\u0043\u0042\u0061\u0073\u0065\u0064","\u0050a\u0074\u0074\u0065\u0072\u006e","\u0049n\u0064\u0065\u0078\u0065\u0064":return *_ffa ,nil ;
24 | case "\u0053\u0065\u0070\u0061\u0072\u0061\u0074\u0069\u006f\u006e","\u0044e\u0076\u0069\u0063\u0065\u004e":return *_ffa ,nil ;};};};return "",nil ;};func (_gdaf Page )FindXObjectImages ()([]*Image ,error ){_ffc ,_edb :=_gdaf .GetResourcesXObject ();if !_edb {return nil ,nil ;
25 | };var _cg []*Image ;var _cef error ;_gcd :=map[*_b .PdfObjectStream ]int {};_fa :=map[*_b .PdfObjectStream ]struct{}{};var _gga int ;for _ ,_ef :=range _ffc .Keys (){_baf ,_bacf :=_b .GetStream (_ffc .Get (_ef ));if !_bacf {continue ;};if _ ,_ade :=_gcd [_baf ];
26 | _ade {continue ;};_feee ,_efd :=_b .GetName (_baf .Get ("\u0053u\u0062\u0074\u0079\u0070\u0065"));if !_efd ||_feee .String ()!="\u0049\u006d\u0061g\u0065"{continue ;};_aafc :=Image {BitsPerComponent :8,Stream :_baf ,Name :string (_ef )};if _aafc .Colorspace ,_cef =_bac (_baf .PdfObjectDictionary .Get ("\u0043\u006f\u006c\u006f\u0072\u0053\u0070\u0061\u0063\u0065"));
27 | _cef !=nil {_a .Log .Error ("\u0045\u0072\u0072\u006f\u0072\u0020\u0064\u0065\u0074\u0065r\u006d\u0069\u006e\u0065\u0020\u0063\u006fl\u006f\u0072\u0020\u0073\u0070\u0061\u0063\u0065\u0020\u0025\u0073",_cef );continue ;};if _cfa ,_dda :=_b .GetIntVal (_baf .PdfObjectDictionary .Get ("\u0042\u0069t\u0073\u0050\u0065r\u0043\u006f\u006d\u0070\u006f\u006e\u0065\u006e\u0074"));
28 | _dda {_aafc .BitsPerComponent =_cfa ;};if _ebf ,_bg :=_b .GetIntVal (_baf .PdfObjectDictionary .Get ("\u0057\u0069\u0064t\u0068"));_bg {_aafc .Width =_ebf ;};if _gfed ,_gffa :=_b .GetIntVal (_baf .PdfObjectDictionary .Get ("\u0048\u0065\u0069\u0067\u0068\u0074"));
29 | _gffa {_aafc .Height =_gfed ;};if _cae ,_eff :=_b .GetStream (_baf .Get ("\u0053\u004d\u0061s\u006b"));_eff {_aafc .SMask =&ImageSMask {Image :&_aafc ,Stream :_cae };_fa [_cae ]=struct{}{};};switch _aafc .Colorspace {case "\u0044e\u0076\u0069\u0063\u0065\u0052\u0047B":_aafc .ColorComponents =3;
30 | case "\u0044\u0065\u0076\u0069\u0063\u0065\u0047\u0072\u0061\u0079":_aafc .ColorComponents =1;case "\u0044\u0065\u0076\u0069\u0063\u0065\u0043\u004d\u0059\u004b":_aafc .ColorComponents =4;default:_aafc .ColorComponents =-1;};_gcd [_baf ]=_gga ;_cg =append (_cg ,&_aafc );
31 | _gga ++;};var _cea []int ;for _ ,_aede :=range _cg {if _aede .SMask !=nil {_fea ,_df :=_gcd [_aede .SMask .Stream ];if _df {_cea =append (_cea ,_fea );};};};_feg :=make ([]*Image ,len (_cg )-len (_cea ));_gga =0;_edg :for _bdb ,_fed :=range _cg {for _ ,_ebfc :=range _cea {if _bdb ==_ebfc {continue _edg ;
32 | };};_feg [_gga ]=_fed ;_gga ++;};return _cg ,nil ;};func (_abg *Catalog )SetOutputIntents (outputIntents *OutputIntents ){if _ae :=_abg .Object .Get ("\u004f\u0075\u0074\u0070\u0075\u0074\u0049\u006e\u0074\u0065\u006e\u0074\u0073");_ae !=nil {for _da ,_agd :=range _abg ._fd .Objects {if _agd ==_ae {if outputIntents ._afea ==_ae {return ;
33 | };_abg ._fd .Objects =append (_abg ._fd .Objects [:_da ],_abg ._fd .Objects [_da +1:]...);break ;};};};_aa :=outputIntents ._afea ;if _aa ==nil {_aa =_b .MakeIndirectObject (outputIntents ._eb );};_abg .Object .Set ("\u004f\u0075\u0074\u0070\u0075\u0074\u0049\u006e\u0074\u0065\u006e\u0074\u0073",_aa );
34 | _abg ._fd .Objects =append (_abg ._fd .Objects ,_aa );};func (_bb *Catalog )GetStructTreeRoot ()(*_b .PdfObjectDictionary ,bool ){return _b .GetDict (_bb .Object .Get ("\u0053\u0074\u0072\u0075\u0063\u0074\u0054\u0072\u0065e\u0052\u006f\u006f\u0074"));
35 | };type Content struct{Stream *_b .PdfObjectStream ;_dcd int ;_dgf Page ;};func (_db *Catalog )GetMarkInfo ()(*_b .PdfObjectDictionary ,bool ){_ce ,_cb :=_b .GetDict (_db .Object .Get ("\u004d\u0061\u0072\u006b\u0049\u006e\u0066\u006f"));return _ce ,_cb ;
36 | };func (_cee Page )GetContents ()([]Content ,bool ){_eeb ,_fcg :=_b .GetArray (_cee .Object .Get ("\u0043\u006f\u006e\u0074\u0065\u006e\u0074\u0073"));if !_fcg {_aaf ,_gff :=_b .GetStream (_cee .Object .Get ("\u0043\u006f\u006e\u0074\u0065\u006e\u0074\u0073"));
37 | if !_gff {return nil ,false ;};return []Content {{Stream :_aaf ,_dgf :_cee ,_dcd :0}},true ;};_add :=make ([]Content ,_eeb .Len ());for _gaad ,_ddd :=range _eeb .Elements (){_fdd ,_edc :=_b .GetStream (_ddd );if !_edc {continue ;};_add [_gaad ]=Content {Stream :_fdd ,_dgf :_cee ,_dcd :_gaad };
38 | };return _add ,true ;};func (_gda *Catalog )HasMetadata ()bool {_de :=_gda .Object .Get ("\u004d\u0065\u0074\u0061\u0064\u0061\u0074\u0061");return _de !=nil ;};type Catalog struct{Object *_b .PdfObjectDictionary ;_fd *Document ;};func (_fb *Catalog )SetStructTreeRoot (structTreeRoot _b .PdfObject ){if structTreeRoot ==nil {_fb .Object .Remove ("\u0053\u0074\u0072\u0075\u0063\u0074\u0054\u0072\u0065e\u0052\u006f\u006f\u0074");
39 | return ;};_bd :=_b .MakeIndirectObject (structTreeRoot );_fb .Object .Set ("\u0053\u0074\u0072\u0075\u0063\u0074\u0054\u0072\u0065e\u0052\u006f\u006f\u0074",_bd );_fb ._fd .Objects =append (_fb ._fd .Objects ,_bd );};func (_ggc Content )GetData ()([]byte ,error ){_acg ,_gcde :=_b .NewEncoderFromStream (_ggc .Stream );
40 | if _gcde !=nil {return nil ,_gcde ;};_dcae ,_gcde :=_acg .DecodeStream (_ggc .Stream );if _gcde !=nil {return nil ,_gcde ;};return _dcae ,nil ;};type OutputIntents struct{_eb *_b .PdfObjectArray ;_ggf *Document ;_afea *_b .PdfIndirectObject ;};func (_ee *OutputIntents )Len ()int {return _ee ._eb .Len ()};
41 | type Document struct{ID [2]string ;Version _b .Version ;Objects []_b .PdfObject ;Info _b .PdfObject ;Crypt *_b .PdfCrypt ;UseHashBasedID bool ;};func (_ffd *Content )SetData (data []byte )error {_dea ,_bgd :=_b .MakeStream (data ,_b .NewFlateEncoder ());
42 | if _bgd !=nil {return _bgd ;};_fec ,_dfe :=_b .GetArray (_ffd ._dgf .Object .Get ("\u0043\u006f\u006e\u0074\u0065\u006e\u0074\u0073"));if !_dfe &&_ffd ._dcd ==0{_ffd ._dgf .Object .Set ("\u0043\u006f\u006e\u0074\u0065\u006e\u0074\u0073",_dea );}else {if _bgd =_fec .Set (_ffd ._dcd ,_dea );
43 | _bgd !=nil {return _bgd ;};};_ffd ._dgf ._gdc .Objects =append (_ffd ._dgf ._gdc .Objects ,_dea );return nil ;};func (_ada *OutputIntents )Add (oi _b .PdfObject )error {_ec ,_egf :=oi .(*_b .PdfObjectDictionary );if !_egf {return _f .New ("\u0069\u006e\u0070\u0075\u0074\u0020\u006f\u0075\u0074\u0070\u0075\u0074\u0020\u0069\u006e\u0074\u0065\u006et\u0020\u0073\u0068\u006f\u0075\u006c\u0064 \u0062\u0065\u0020\u0061\u006e\u0020\u006f\u0062\u006a\u0065\u0063t\u0020\u0064\u0069\u0063\u0074\u0069\u006f\u006e\u0061\u0072\u0079");
44 | };if _gde ,_aaa :=_b .GetStream (_ec .Get ("\u0044\u0065\u0073\u0074\u004f\u0075\u0074\u0070\u0075\u0074\u0050\u0072o\u0066\u0069\u006c\u0065"));_aaa {_ada ._ggf .Objects =append (_ada ._ggf .Objects ,_gde );};_dgg ,_afg :=oi .(*_b .PdfIndirectObject );
45 | if !_afg {_dgg =_b .MakeIndirectObject (oi );};if _ada ._eb ==nil {_ada ._eb =_b .MakeArray (_dgg );}else {_ada ._eb .Append (_dgg );};_ada ._ggf .Objects =append (_ada ._ggf .Objects ,_dgg );return nil ;};type OutputIntent struct{Object *_b .PdfObjectDictionary ;
46 | };func (_cac Page )FindXObjectForms ()[]*_b .PdfObjectStream {_aca ,_fab :=_cac .GetResourcesXObject ();if !_fab {return nil ;};_feab :=map[*_b .PdfObjectStream ]struct{}{};var _gfg func (_cge *_b .PdfObjectDictionary ,_dba map[*_b .PdfObjectStream ]struct{});
47 | _gfg =func (_fg *_b .PdfObjectDictionary ,_bgc map[*_b .PdfObjectStream ]struct{}){for _ ,_cgc :=range _fg .Keys (){_cde ,_cc :=_b .GetStream (_fg .Get (_cgc ));if !_cc {continue ;};if _ ,_cgf :=_bgc [_cde ];_cgf {continue ;};_acf ,_cfd :=_b .GetName (_cde .Get ("\u0053u\u0062\u0074\u0079\u0070\u0065"));
48 | if !_cfd ||_acf .String ()!="\u0046\u006f\u0072\u006d"{continue ;};_bgc [_cde ]=struct{}{};_cadd ,_cfd :=_b .GetDict (_cde .Get ("\u0052e\u0073\u006f\u0075\u0072\u0063\u0065s"));if !_cfd {continue ;};_gbf ,_dfc :=_b .GetDict (_cadd .Get ("\u0058O\u0062\u006a\u0065\u0063\u0074"));
49 | if _dfc {_gfg (_gbf ,_bgc );};};};_gfg (_aca ,_feab );var _gbe []*_b .PdfObjectStream ;for _fgg :=range _feab {_gbe =append (_gbe ,_fgg );};return _gbe ;};func (_afc Page )GetResourcesXObject ()(*_b .PdfObjectDictionary ,bool ){_cdc ,_aeb :=_afc .GetResources ();
50 | if !_aeb {return nil ,false ;};return _b .GetDict (_cdc .Get ("\u0058O\u0062\u006a\u0065\u0063\u0074"));};type Page struct{_bbf int ;Object *_b .PdfObjectDictionary ;_gdc *Document ;};func (_af *Catalog )NewOutputIntents ()*OutputIntents {return &OutputIntents {_ggf :_af ._fd }};
51 | func (_gd *Catalog )GetPages ()([]Page ,bool ){_dc ,_ag :=_b .GetDict (_gd .Object .Get ("\u0050\u0061\u0067e\u0073"));if !_ag {return nil ,false ;};_dd ,_dg :=_b .GetArray (_dc .Get ("\u004b\u0069\u0064\u0073"));if !_dg {return nil ,false ;};_ad :=make ([]Page ,_dd .Len ());
52 | for _ff ,_gg :=range _dd .Elements (){_e ,_ed :=_b .GetDict (_gg );if !_ed {continue ;};_ad [_ff ]=Page {Object :_e ,_bbf :_ff +1,_gdc :_gd ._fd };};return _ad ,true ;};type Image struct{Name string ;Width int ;Height int ;Colorspace _b .PdfObjectName ;
53 | ColorComponents int ;BitsPerComponent int ;SMask *ImageSMask ;Stream *_b .PdfObjectStream ;};func (_gb *Catalog )SetMarkInfo (mi _b .PdfObject ){if mi ==nil {_gb .Object .Remove ("\u004d\u0061\u0072\u006b\u0049\u006e\u0066\u006f");return ;};_gfe :=_b .MakeIndirectObject (mi );
54 | _gb .Object .Set ("\u004d\u0061\u0072\u006b\u0049\u006e\u0066\u006f",_gfe );_gb ._fd .Objects =append (_gb ._fd .Objects ,_gfe );};func (_bdd *Catalog )GetOutputIntents ()(*OutputIntents ,bool ){_cec :=_bdd .Object .Get ("\u004f\u0075\u0074\u0070\u0075\u0074\u0049\u006e\u0074\u0065\u006e\u0074\u0073");
55 | if _cec ==nil {return nil ,false ;};_ac ,_eda :=_b .GetIndirect (_cec );if !_eda {return nil ,false ;};_ba ,_afe :=_b .GetArray (_ac .PdfObject );if !_afe {return nil ,false ;};return &OutputIntents {_afea :_ac ,_eb :_ba ,_ggf :_bdd ._fd },true ;};type ImageSMask struct{Image *Image ;
56 | Stream *_b .PdfObjectStream ;};func (_g *Catalog )SetVersion (){_g .Object .Set ("\u0056e\u0072\u0073\u0069\u006f\u006e",_b .MakeName (_c .Sprintf ("\u0025\u0064\u002e%\u0064",_g ._fd .Version .Major ,_g ._fd .Version .Minor )));};func (_cad Page )GetResources ()(*_b .PdfObjectDictionary ,bool ){return _b .GetDict (_cad .Object .Get ("\u0052e\u0073\u006f\u0075\u0072\u0063\u0065s"));
57 | };


--------------------------------------------------------------------------------
/model/optimize/tests/tests.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | // Package tests provides integration tests for the UniPDF optimizer. The test requires environment variable
13 | // UNIDOC_OPTIMIZE_TESTDATA to be set for the directory with `.pdf` files, otherwise the test is skipped.
14 | package tests ;


--------------------------------------------------------------------------------
/model/sigutil/sigutil.go:
--------------------------------------------------------------------------------
  1 | //
  2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
  3 | //
  4 | // This is a commercial product and requires a license to operate.
  5 | // A trial license can be obtained at https://unidoc.io
  6 | //
  7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
  8 | //
  9 | // Use of this source code is governed by the UniDoc End User License Agreement
 10 | // terms that can be accessed at https://unidoc.io/eula/
 11 | 
 12 | package sigutil ;import (_ff "bytes";_bd "crypto";_a "crypto/x509";_fb "encoding/asn1";_fd "encoding/pem";_d "errors";_c "fmt";_bc "github.com/unidoc/timestamp";_g "github.com/unidoc/unipdf/v4/common";_bg "golang.org/x/crypto/ocsp";_bf "io";_df "net/http";
 13 | _b "time";);
 14 | 
 15 | // MakeRequest makes a OCSP request to the specified server and returns
 16 | // the parsed and raw responses. If a server URL is not provided, it is
 17 | // extracted from the certificate.
 18 | func (_ge *OCSPClient )MakeRequest (serverURL string ,cert ,issuer *_a .Certificate )(*_bg .Response ,[]byte ,error ){if _ge .HTTPClient ==nil {_ge .HTTPClient =_cb ();};if serverURL ==""{if len (cert .OCSPServer )==0{return nil ,nil ,_d .New ("\u0063e\u0072\u0074i\u0066\u0069\u0063a\u0074\u0065\u0020\u0064\u006f\u0065\u0073 \u006e\u006f\u0074\u0020\u0073\u0070e\u0063\u0069\u0066\u0079\u0020\u0061\u006e\u0079\u0020\u004f\u0043S\u0050\u0020\u0073\u0065\u0072\u0076\u0065\u0072\u0073");
 19 | };serverURL =cert .OCSPServer [0];};_dfc ,_eb :=_bg .CreateRequest (cert ,issuer ,&_bg .RequestOptions {Hash :_ge .Hash });if _eb !=nil {return nil ,nil ,_eb ;};_ae ,_eb :=_ge .HTTPClient .Post (serverURL ,"\u0061p\u0070\u006c\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u002f\u006fc\u0073\u0070\u002d\u0072\u0065\u0071\u0075\u0065\u0073\u0074",_ff .NewReader (_dfc ));
 20 | if _eb !=nil {return nil ,nil ,_eb ;};defer _ae .Body .Close ();_cd ,_eb :=_bf .ReadAll (_ae .Body );if _eb !=nil {return nil ,nil ,_eb ;};if _ec ,_ :=_fd .Decode (_cd );_ec !=nil {_cd =_ec .Bytes ;};_gca ,_eb :=_bg .ParseResponseForCert (_cd ,cert ,issuer );
 21 | if _eb !=nil {return nil ,nil ,_eb ;};return _gca ,_cd ,nil ;};
 22 | 
 23 | // CertClient represents a X.509 certificate client. Its primary purpose
 24 | // is to download certificates.
 25 | type CertClient struct{
 26 | 
 27 | // HTTPClient is the HTTP client used to make certificate requests.
 28 | // By default, an HTTP client with a 5 second timeout per request is used.
 29 | HTTPClient *_df .Client ;};
 30 | 
 31 | // TimestampClient represents a RFC 3161 timestamp client.
 32 | // It is used to obtain signed tokens from timestamp authority servers.
 33 | type TimestampClient struct{
 34 | 
 35 | // HTTPClient is the HTTP client used to make timestamp requests.
 36 | // By default, an HTTP client with a 5 second timeout per request is used.
 37 | HTTPClient *_df .Client ;
 38 | 
 39 | // Callbacks.
 40 | BeforeHTTPRequest func (_ebc *_df .Request )error ;};
 41 | 
 42 | // NewTimestampClient returns a new timestamp client.
 43 | func NewTimestampClient ()*TimestampClient {return &TimestampClient {HTTPClient :_cb ()}};func _cb ()*_df .Client {return &_df .Client {Timeout :5*_b .Second }};
 44 | 
 45 | // CRLClient represents a CRL (Certificate revocation list) client.
 46 | // It is used to request revocation data from CRL servers.
 47 | type CRLClient struct{
 48 | 
 49 | // HTTPClient is the HTTP client used to make CRL requests.
 50 | // By default, an HTTP client with a 5 second timeout per request is used.
 51 | HTTPClient *_df .Client ;};
 52 | 
 53 | // NewCRLClient returns a new CRL client.
 54 | func NewCRLClient ()*CRLClient {return &CRLClient {HTTPClient :_cb ()}};
 55 | 
 56 | // MakeRequest makes a CRL request to the specified server and returns the
 57 | // response. If a server URL is not provided, it is extracted from the certificate.
 58 | func (_ac *CRLClient )MakeRequest (serverURL string ,cert *_a .Certificate )([]byte ,error ){if _ac .HTTPClient ==nil {_ac .HTTPClient =_cb ();};if serverURL ==""{if len (cert .CRLDistributionPoints )==0{return nil ,_d .New ("\u0063e\u0072\u0074i\u0066\u0069\u0063\u0061t\u0065\u0020\u0064o\u0065\u0073\u0020\u006e\u006f\u0074\u0020\u0073\u0070ec\u0069\u0066\u0079 \u0061\u006ey\u0020\u0043\u0052\u004c\u0020\u0073e\u0072\u0076e\u0072\u0073");
 59 | };serverURL =cert .CRLDistributionPoints [0];};_daf ,_ed :=_ac .HTTPClient .Get (serverURL );if _ed !=nil {return nil ,_ed ;};defer _daf .Body .Close ();_bgb ,_ed :=_bf .ReadAll (_daf .Body );if _ed !=nil {return nil ,_ed ;};if _ca ,_ :=_fd .Decode (_bgb );
 60 | _ca !=nil {_bgb =_ca .Bytes ;};return _bgb ,nil ;};
 61 | 
 62 | // NewCertClient returns a new certificate client.
 63 | func NewCertClient ()*CertClient {return &CertClient {HTTPClient :_cb ()}};
 64 | 
 65 | // GetEncodedToken executes the timestamp request and returns the DER encoded
 66 | // timestamp token bytes.
 67 | func (_ffa *TimestampClient )GetEncodedToken (serverURL string ,req *_bc .Request )([]byte ,error ){if serverURL ==""{return nil ,_c .Errorf ("\u006d\u0075\u0073\u0074\u0020\u0070r\u006f\u0076\u0069\u0064\u0065\u0020\u0074\u0069\u006d\u0065\u0073\u0074\u0061m\u0070\u0020\u0073\u0065\u0072\u0076\u0065r\u0020\u0055\u0052\u004c");
 68 | };if req ==nil {return nil ,_c .Errorf ("\u0074\u0069\u006de\u0073\u0074\u0061\u006dp\u0020\u0072\u0065\u0071\u0075\u0065\u0073t\u0020\u0063\u0061\u006e\u006e\u006f\u0074\u0020\u0062\u0065\u0020\u006e\u0069\u006c");};_gd ,_de :=req .Marshal ();if _de !=nil {return nil ,_de ;
 69 | };_acd ,_de :=_df .NewRequest ("\u0050\u004f\u0053\u0054",serverURL ,_ff .NewBuffer (_gd ));if _de !=nil {return nil ,_de ;};_acd .Header .Set ("\u0043\u006f\u006et\u0065\u006e\u0074\u002d\u0054\u0079\u0070\u0065","a\u0070\u0070\u006c\u0069\u0063\u0061t\u0069\u006f\u006e\u002f\u0074\u0069\u006d\u0065\u0073t\u0061\u006d\u0070-\u0071u\u0065\u0072\u0079");
 70 | if _ffa .BeforeHTTPRequest !=nil {if _bbe :=_ffa .BeforeHTTPRequest (_acd );_bbe !=nil {return nil ,_bbe ;};};_gcb :=_ffa .HTTPClient ;if _gcb ==nil {_gcb =_cb ();};_gg ,_de :=_gcb .Do (_acd );if _de !=nil {return nil ,_de ;};defer _gg .Body .Close ();
 71 | _aee ,_de :=_bf .ReadAll (_gg .Body );if _de !=nil {return nil ,_de ;};if _gg .StatusCode !=_df .StatusOK {return nil ,_c .Errorf ("\u0075\u006e\u0065x\u0070\u0065\u0063\u0074e\u0064\u0020\u0048\u0054\u0054\u0050\u0020s\u0074\u0061\u0074\u0075\u0073\u0020\u0063\u006f\u0064\u0065\u003a\u0020\u0025\u0064",_gg .StatusCode );
 72 | };var _bad struct{Version _fb .RawValue ;Content _fb .RawValue ;};if _ ,_de =_fb .Unmarshal (_aee ,&_bad );_de !=nil {return nil ,_de ;};return _bad .Content .FullBytes ,nil ;};
 73 | 
 74 | // OCSPClient represents a OCSP (Online Certificate Status Protocol) client.
 75 | // It is used to request revocation data from OCSP servers.
 76 | type OCSPClient struct{
 77 | 
 78 | // HTTPClient is the HTTP client used to make OCSP requests.
 79 | // By default, an HTTP client with a 5 second timeout per request is used.
 80 | HTTPClient *_df .Client ;
 81 | 
 82 | // Hash is the hash function  used when constructing the OCSP
 83 | // requests. If zero, SHA-1 will be used.
 84 | Hash _bd .Hash ;};
 85 | 
 86 | // NewOCSPClient returns a new OCSP client.
 87 | func NewOCSPClient ()*OCSPClient {return &OCSPClient {HTTPClient :_cb (),Hash :_bd .SHA1 }};
 88 | 
 89 | // GetIssuer retrieves the issuer of the provided certificate.
 90 | func (_bb *CertClient )GetIssuer (cert *_a .Certificate )(*_a .Certificate ,error ){for _ ,_ffg :=range cert .IssuingCertificateURL {_fgc ,_dbd :=_bb .Get (_ffg );if _dbd !=nil {_g .Log .Debug ("\u0057\u0041\u0052\u004e\u003a\u0020\u0063\u006f\u0075\u006c\u0064\u0020\u006e\u006f\u0074 \u0064\u006f\u0077\u006e\u006c\u006f\u0061\u0064\u0020\u0069\u0073\u0073\u0075e\u0072\u0020\u0066\u006f\u0072\u0020\u0063\u0065\u0072\u0074\u0069\u0066ic\u0061\u0074\u0065\u0020\u0025\u0076\u003a\u0020\u0025\u0076",cert .Subject .CommonName ,_dbd );
 91 | continue ;};return _fgc ,nil ;};return nil ,_c .Errorf ("\u0069\u0073\u0073\u0075e\u0072\u0020\u0063\u0065\u0072\u0074\u0069\u0066\u0069\u0063a\u0074e\u0020\u006e\u006f\u0074\u0020\u0066\u006fu\u006e\u0064");};
 92 | 
 93 | // IsCA returns true if the provided certificate appears to be a CA certificate.
 94 | func (_gc *CertClient )IsCA (cert *_a .Certificate )bool {return cert .IsCA &&_ff .Equal (cert .RawIssuer ,cert .RawSubject );};
 95 | 
 96 | // Get retrieves the certificate at the specified URL.
 97 | func (_fg *CertClient )Get (url string )(*_a .Certificate ,error ){if _fg .HTTPClient ==nil {_fg .HTTPClient =_cb ();};_e ,_da :=_fg .HTTPClient .Get (url );if _da !=nil {return nil ,_da ;};defer _e .Body .Close ();_fdf ,_da :=_bf .ReadAll (_e .Body );
 98 | if _da !=nil {return nil ,_da ;};if _ffe ,_ :=_fd .Decode (_fdf );_ffe !=nil {_fdf =_ffe .Bytes ;};_db ,_da :=_a .ParseCertificate (_fdf );if _da !=nil {return nil ,_da ;};return _db ,nil ;};
 99 | 
100 | // NewTimestampRequest returns a new timestamp request based
101 | // on the specified options.
102 | func NewTimestampRequest (body _bf .Reader ,opts *_bc .RequestOptions )(*_bc .Request ,error ){if opts ==nil {opts =&_bc .RequestOptions {};};if opts .Hash ==0{opts .Hash =_bd .SHA256 ;};if !opts .Hash .Available (){return nil ,_a .ErrUnsupportedAlgorithm ;
103 | };_dg :=opts .Hash .New ();if _ ,_ffef :=_bf .Copy (_dg ,body );_ffef !=nil {return nil ,_ffef ;};return &_bc .Request {HashAlgorithm :opts .Hash ,HashedMessage :_dg .Sum (nil ),Certificates :opts .Certificates ,TSAPolicyOID :opts .TSAPolicyOID ,Nonce :opts .Nonce },nil ;
104 | };


--------------------------------------------------------------------------------
/model/xmputil/pdfaid/pdfaid.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | package pdfaid ;import (_f "fmt";_b "github.com/trimmer-io/go-xmp/xmp";_g "github.com/unidoc/unipdf/v4/model/xmputil/pdfaextension";);var Schema =_g .Schema {NamespaceURI :Namespace .URI ,Prefix :Namespace .Name ,Schema :"\u0050D\u0046/\u0041\u0020\u0049\u0044\u0020\u0053\u0063\u0068\u0065\u006d\u0061",Property :[]_g .Property {{Category :_g .PropertyCategoryInternal ,Description :"\u0050\u0061\u0072\u0074 o\u0066\u0020\u0050\u0044\u0046\u002f\u0041\u0020\u0073\u0074\u0061\u006e\u0064\u0061r\u0064",Name :"\u0070\u0061\u0072\u0074",ValueType :_g .ValueTypeNameInteger },{Category :_g .PropertyCategoryInternal ,Description :"A\u006d\u0065\u006e\u0064\u006d\u0065n\u0074\u0020\u006f\u0066\u0020\u0050\u0044\u0046\u002fA\u0020\u0073\u0074a\u006ed\u0061\u0072\u0064",Name :"\u0061\u006d\u0064",ValueType :_g .ValueTypeNameText },{Category :_g .PropertyCategoryInternal ,Description :"C\u006f\u006e\u0066\u006f\u0072\u006da\u006e\u0063\u0065\u0020\u006c\u0065v\u0065\u006c\u0020\u006f\u0066\u0020\u0050D\u0046\u002f\u0041\u0020\u0073\u0074\u0061\u006e\u0064\u0061r\u0064",Name :"c\u006f\u006e\u0066\u006f\u0072\u006d\u0061\u006e\u0063\u0065",ValueType :_g .ValueTypeNameText }},ValueType :nil };
13 | func init (){_b .Register (Namespace ,_b .XmpMetadata );_g .RegisterSchema (Namespace ,&Schema )};
14 | 
15 | // CanTag implements xmp.Model interface.
16 | func (_ab *Model )CanTag (tag string )bool {_ ,_ge :=_b .GetNativeField (_ab ,tag );return _ge ==nil };
17 | 
18 | // Can implements xmp.Model interface.
19 | func (_a *Model )Can (nsName string )bool {return Namespace .GetName ()==nsName };
20 | 
21 | // NewModel creates a new model.
22 | func NewModel (name string )_b .Model {return &Model {}};
23 | 
24 | // Model is the XMP model for the PdfA metadata.
25 | type Model struct{Part int `xmp:"pdfaid:part"`;Conformance string `xmp:"pdfaid:conformance"`;};
26 | 
27 | // SyncFromXMP implements xmp.Model interface.
28 | func (_ebg *Model )SyncFromXMP (d *_b .Document )error {return nil };var Namespace =_b .NewNamespace ("\u0070\u0064\u0066\u0061\u0069\u0064","\u0068\u0074\u0074p\u003a\u002f\u002f\u0077w\u0077\u002e\u0061\u0069\u0069\u006d\u002eo\u0072\u0067\u002f\u0070\u0064\u0066\u0061\u002f\u006e\u0073\u002f\u0069\u0064\u002f",NewModel );
29 | 
30 | 
31 | // SyncToXMP implements xmp.Model interface.
32 | func (_bb *Model )SyncToXMP (d *_b .Document )error {return nil };
33 | 
34 | // GetTag implements xmp.Model interface.
35 | func (_ec *Model )GetTag (tag string )(string ,error ){_ee ,_ed :=_b .GetNativeField (_ec ,tag );if _ed !=nil {return "",_f .Errorf ("\u0025\u0073\u003a\u0020\u0025\u0076",Namespace .GetName (),_ed );};return _ee ,nil ;};
36 | 
37 | // SetTag implements xmp.Model interface.
38 | func (_ged *Model )SetTag (tag ,value string )error {if _ag :=_b .SetNativeField (_ged ,tag ,value );_ag !=nil {return _f .Errorf ("\u0025\u0073\u003a\u0020\u0025\u0076",Namespace .GetName (),_ag );};return nil ;};var _ _b .Model =(*Model )(nil );
39 | 
40 | // MakeModel gets or create sa new model for PDF/A ID namespace.
41 | func MakeModel (d *_b .Document )(*Model ,error ){_ba ,_gd :=d .MakeModel (Namespace );if _gd !=nil {return nil ,_gd ;};return _ba .(*Model ),nil ;};
42 | 
43 | // Namespaces implements xmp.Model interface.
44 | func (_eb *Model )Namespaces ()_b .NamespaceList {return _b .NamespaceList {Namespace }};
45 | 
46 | // SyncModel implements xmp.Model interface.
47 | func (_fdc *Model )SyncModel (d *_b .Document )error {return nil };


--------------------------------------------------------------------------------
/render/internal/context/context.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | package context ;import (_fg "errors";_g "github.com/unidoc/freetype/truetype";_dg "github.com/unidoc/unipdf/v4/core";_ba "github.com/unidoc/unipdf/v4/internal/cmap";_da "github.com/unidoc/unipdf/v4/internal/textencoding";_fb "github.com/unidoc/unipdf/v4/internal/transform";
13 | _bg "github.com/unidoc/unipdf/v4/model";_db "golang.org/x/image/font";_a "image";_d "image/color";_f "strconv";_c "strings";);func (_bec *TextState )Reset (){_bec .Tm =_fb .IdentityMatrix ();_bec .Tlm =_fb .IdentityMatrix ()};func NewTextFontFromPath (filePath string ,size float64 )(*TextFont ,error ){_ca ,_cfa :=_bg .NewPdfFontFromTTFFile (filePath );
14 | if _cfa !=nil {return nil ,_cfa ;};return NewTextFont (_ca ,size );};func (_fae *TextState )Translate (tx ,ty float64 ){_fae .Tm =_fae .Tm .Mult (_fb .TranslationMatrix (tx ,ty ));};type LineCap int ;func (_gff *TextState )ProcTD (tx ,ty float64 ){_gff .Tl =-ty ;
15 | _gff .ProcTd (tx ,ty )};type Pattern interface{ColorAt (_gc ,_baa int )_d .Color ;};type TextFont struct{Font *_bg .PdfFont ;Size float64 ;_cfbf *_g .Font ;_eab *_bg .PdfFont ;};func (_efe *TextFont )charcodeToRunesSimple (_dd _da .CharCode )(_da .CharCode ,[]rune ){_ffd :=[]_da .CharCode {_dd };
16 | if _efe .Font .IsSimple ()&&_efe ._cfbf !=nil {if _ge :=_efe ._cfbf .Index (rune (_dd ));_ge > 0{return _dd ,[]rune {rune (_dd )};};};if _efe ._cfbf !=nil &&!_efe ._cfbf .HasCmap ()&&_c .Contains (_efe .Font .Encoder ().String (),"\u0049d\u0065\u006e\u0074\u0069\u0074\u0079-"){if _aag :=_efe ._cfbf .Index (rune (_dd ));
17 | _aag > 0{return _dd ,[]rune {rune (_dd )};};};return _dd ,_efe .Font .CharcodesToUnicode (_ffd );};const (LineJoinRound LineJoin =iota ;LineJoinBevel ;);func (_eba *TextState )ProcTj (data []byte ,ctx Context ){_ege :=_eba .Tf .Size ;_faf :=_eba .Th /100.0;
18 | _gaga :=_eba .GlobalScale ;_ebb :=_fb .NewMatrix (_ege *_faf ,0,0,_ege ,0,_eba .Ts );_bge :=ctx .Matrix ();_acd :=_bge .Clone ().Mult (_eba .Tm .Clone ().Mult (_ebb )).ScalingFactorY ();_dba :=_eba .Tf .NewFace (_acd );_bgf :=_eba .Tf .BytesToCharcodes (data );
19 | for _ ,_cad :=range _bgf {_gd ,_fbb :=_eba .Tf .CharcodeToRunes (_cad );_ee :=string (_fbb );if _ee =="\u0000"{continue ;};_cda :=_bge .Clone ().Mult (_eba .Tm .Clone ().Mult (_ebb ));_ce :=_cda .ScalingFactorY ();_cda =_cda .Scale (1/_ce ,-1/_ce );if _eba .Tr !=TextRenderingModeInvisible {ctx .SetMatrix (_cda );
20 | ctx .DrawString (_ee ,_dba ,0,0);ctx .SetMatrix (_bge );};_dde :=0.0;if _ee =="\u0020"{_dde =_eba .Tw ;};_dec ,_ ,_gge :=_eba .Tf .GetCharMetrics (_gd );if _gge {_dec =_dec *0.001*_ege ;}else {_dec ,_ =ctx .MeasureString (_ee ,_dba );_dec =_dec /_gaga ;
21 | };_cgd :=(_dec +_eba .Tc +_dde )*_faf ;_eba .Tm =_eba .Tm .Mult (_fb .TranslationMatrix (_cgd ,0));};};func (_aaa *TextFont )WithSize (size float64 ,originalFont *_bg .PdfFont )*TextFont {return &TextFont {Font :_aaa .Font ,Size :size ,_cfbf :_aaa ._cfbf ,_eab :originalFont };
22 | };func (_fef *TextState )ProcTf (font *TextFont ){_fef .Tf =font };func (_cfbe *TextFont )NewFace (size float64 )_db .Face {return _g .NewFace (_cfbe ._cfbf ,&_g .Options {Size :size });};func (_cfbb *TextState )ProcDQ (data []byte ,aw ,ac float64 ,ctx Context ){_cfbb .Tw =aw ;
23 | _cfbb .Tc =ac ;_cfbb .ProcQ (data ,ctx );};func (_agg *TextFont )CharcodeToRunes (charcode _da .CharCode )(_da .CharCode ,[]rune ){_dfe :=[]_da .CharCode {charcode };if _agg ._eab ==nil ||_agg ._eab ==_agg .Font {return _agg .charcodeToRunesSimple (charcode );
24 | };_bdf :=_agg ._eab .CharcodesToUnicode (_dfe );_fdf ,_ :=_agg .Font .RunesToCharcodeBytes (_bdf );_gaf :=_agg .Font .BytesToCharcodes (_fdf );_be :=charcode ;if len (_gaf )> 0&&_gaf [0]!=0{_be =_gaf [0];};if string (_bdf )==string (_ba .MissingCodeRune )&&_agg ._eab .BaseFont ()==_agg .Font .BaseFont (){return _agg .charcodeToRunesSimple (charcode );
25 | };return _be ,_bdf ;};func (_cgec *TextState )ProcTStar (){_cgec .ProcTd (0,-_cgec .Tl )};const (FillRuleWinding FillRule =iota ;FillRuleEvenOdd ;);type Gradient interface{Pattern ;AddColorStop (_ac float64 ,_fbg _d .Color );};const (LineCapRound LineCap =iota ;
26 | LineCapButt ;LineCapSquare ;);type Context interface{Push ();Pop ();Matrix ()_fb .Matrix ;SetMatrix (_bgg _fb .Matrix );Translate (_cf ,_ag float64 );Scale (_de ,_e float64 );Rotate (_af float64 );MoveTo (_gg ,_eb float64 );LineTo (_fc ,_ad float64 );CubicTo (_df ,_dgc ,_ggf ,_cg ,_bc ,_ae float64 );
27 | QuadraticTo (_eg ,_ec ,_fd ,_cfb float64 );NewSubPath ();ClosePath ();ClearPath ();Clip ();ClipPreserve ();ResetClip ();LineWidth ()float64 ;SetLineWidth (_ef float64 );SetLineCap (_ggd LineCap );SetLineJoin (_fa LineJoin );SetDash (_ga ...float64 );SetDashOffset (_cb float64 );
28 | Fill ();FillPreserve ();Stroke ();StrokePreserve ();SetRGBA (_dc ,_bac ,_gf ,_bacg float64 );SetFillRGBA (_bd ,_dgcb ,_dga ,_adb float64 );SetFillStyle (_dag Pattern );SetFillRule (_deg FillRule );SetStrokeRGBA (_dab ,_ff ,_cd ,_dff float64 );SetStrokeStyle (_cge Pattern );
29 | FillPattern ()Pattern ;StrokePattern ()Pattern ;TextState ()*TextState ;DrawString (_gb string ,_aa _db .Face ,_adc ,_fgc float64 );MeasureString (_gfb string ,_ea _db .Face )(_dfc ,_fe float64 );DrawRectangle (_aef ,_fbd ,_bca ,_bab float64 );DrawImage (_bf _a .Image ,_ece ,_gcc int );
30 | DrawImageAnchored (_bfa _a .Image ,_ed ,_gfe int ,_fcc ,_bggg float64 );Height ()int ;Width ()int ;};type FillRule int ;func (_cdb *TextState )ProcTm (a ,b ,c ,d ,e ,f float64 ){_cdb .Tm =_fb .NewMatrix (a ,b ,c ,d ,e ,f );_cdb .Tlm =_cdb .Tm .Clone ();
31 | };func (_fdfc *TextFont )GetCharMetrics (code _da .CharCode )(float64 ,float64 ,bool ){if _cfd ,_cgb :=_fdfc .Font .GetCharMetrics (code );_cgb &&_cfd .Wx !=0{return _cfd .Wx ,_cfd .Wy ,_cgb ;};if _fdfc ._eab ==nil {return 0,0,false ;};_gag ,_fgd :=_fdfc ._eab .GetCharMetrics (code );
32 | return _gag .Wx ,_gag .Wy ,_fgd &&_gag .Wx !=0;};type TextRenderingMode int ;func NewTextFont (font *_bg .PdfFont ,size float64 )(*TextFont ,error ){_daf :=font .FontDescriptor ();if _daf ==nil {return nil ,_fg .New ("\u0063\u006fu\u006c\u0064\u0020\u006e\u006f\u0074\u0020\u0067\u0065\u0074\u0020\u0066\u006f\u006e\u0074\u0020\u0064\u0065\u0073\u0063\u0072\u0069pt\u006f\u0072");
33 | };_age ,_fab :=_dg .GetStream (_daf .FontFile2 );if !_fab {return nil ,_fg .New ("\u006di\u0073\u0073\u0069\u006e\u0067\u0020\u0066\u006f\u006e\u0074\u0020f\u0069\u006c\u0065\u0020\u0073\u0074\u0072\u0065\u0061\u006d");};_fbda ,_ebc :=_dg .DecodeStream (_age );
34 | if _ebc !=nil {return nil ,_ebc ;};_fag ,_ebc :=_g .Parse (_fbda );if _ebc !=nil {return nil ,_ebc ;};_bgc :=font .FontDescriptor ().FontName .String ();_aged :=len (_bgc )> 7&&_bgc [6]=='+';if _daf .Flags !=nil {_efd ,_fce :=_f .Atoi (_daf .Flags .String ());
35 | if _fce ==nil &&_efd ==32{_aged =false ;};};if !_fag .HasCmap ()&&(!_c .Contains (font .Encoder ().String (),"\u0049d\u0065\u006e\u0074\u0069\u0074\u0079-")||!_aged ){return nil ,_fg .New ("\u006e\u006f c\u006d\u0061\u0070 \u0061\u006e\u0064\u0020enc\u006fdi\u006e\u0067\u0020\u0069\u0073\u0020\u006eot\u0020\u0069\u0064\u0065\u006e\u0074\u0069t\u0079");
36 | };return &TextFont {Font :font ,Size :size ,_cfbf :_fag },nil ;};func (_gbg *TextState )ProcQ (data []byte ,ctx Context ){_gbg .ProcTStar ();_gbg .ProcTj (data ,ctx )};func (_dcc *TextFont )BytesToCharcodes (data []byte )[]_da .CharCode {if _dcc ._eab !=nil {return _dcc ._eab .BytesToCharcodes (data );
37 | };return _dcc .Font .BytesToCharcodes (data );};func NewTextState ()TextState {return TextState {Th :100,Tm :_fb .IdentityMatrix (),Tlm :_fb .IdentityMatrix ()};};func (_dffe *TextState )ProcTd (tx ,ty float64 ){_dffe .Tlm .Concat (_fb .TranslationMatrix (tx ,ty ));
38 | _dffe .Tm =_dffe .Tlm .Clone ();};type LineJoin int ;const (TextRenderingModeFill TextRenderingMode =iota ;TextRenderingModeStroke ;TextRenderingModeFillStroke ;TextRenderingModeInvisible ;TextRenderingModeFillClip ;TextRenderingModeStrokeClip ;TextRenderingModeFillStrokeClip ;
39 | TextRenderingModeClip ;);type TextState struct{Tc float64 ;Tw float64 ;Th float64 ;Tl float64 ;Tf *TextFont ;Ts float64 ;Tm _fb .Matrix ;Tlm _fb .Matrix ;Tr TextRenderingMode ;GlobalScale float64 ;};


--------------------------------------------------------------------------------
/sanitize/sanitize.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | package sanitize ;import (_f "github.com/unidoc/unipdf/v4/common";_bg "github.com/unidoc/unipdf/v4/core";);func (_d *Sanitizer )processObjects (_fc []_bg .PdfObject )([]_bg .PdfObject ,error ){_ba :=[]_bg .PdfObject {};_ga :=_d ._be ;for _ ,_baf :=range _fc {switch _e :=_baf .(type ){case *_bg .PdfIndirectObject :_cg ,_a :=_bg .GetDict (_e );
13 | if _a {if _gd ,_cf :=_bg .GetName (_cg .Get ("\u0054\u0079\u0070\u0065"));_cf &&*_gd =="\u0043a\u0074\u0061\u006c\u006f\u0067"{if _ ,_fe :=_bg .GetIndirect (_cg .Get ("\u004f\u0070\u0065\u006e\u0041\u0063\u0074\u0069\u006f\u006e"));_fe &&_ga .OpenAction {_cg .Remove ("\u004f\u0070\u0065\u006e\u0041\u0063\u0074\u0069\u006f\u006e");
14 | };}else if _ab ,_beb :=_bg .GetName (_cg .Get ("\u0053"));_beb {switch *_ab {case "\u004a\u0061\u0076\u0061\u0053\u0063\u0072\u0069\u0070\u0074":if _ga .JavaScript {if _da ,_bb :=_bg .GetStream (_cg .Get ("\u004a\u0053"));_bb {_fcb :=[]byte {};_ff ,_baa :=_bg .MakeStream (_fcb ,nil );
15 | if _baa ==nil {*_da =*_ff ;};};_f .Log .Debug ("\u004a\u0061\u0076\u0061\u0073\u0063\u0072\u0069\u0070\u0074\u0020a\u0063\u0074\u0069\u006f\u006e\u0020\u0073\u006b\u0069\u0070p\u0065\u0064\u002e");continue ;};case "\u0055\u0052\u0049":if _ga .URI {_f .Log .Debug ("\u0055\u0052\u0049\u0020ac\u0074\u0069\u006f\u006e\u0020\u0073\u006b\u0069\u0070\u0070\u0065\u0064\u002e");
16 | continue ;};case "\u0047\u006f\u0054\u006f":if _ga .GoTo {_f .Log .Debug ("G\u004fT\u004f\u0020\u0061\u0063\u0074\u0069\u006f\u006e \u0073\u006b\u0069\u0070pe\u0064\u002e");continue ;};case "\u0047\u006f\u0054o\u0052":if _ga .GoToR {_f .Log .Debug ("R\u0065\u006d\u006f\u0074\u0065\u0020G\u006f\u0054\u004f\u0020\u0061\u0063\u0074\u0069\u006fn\u0020\u0073\u006bi\u0070p\u0065\u0064\u002e");
17 | continue ;};case "\u004c\u0061\u0075\u006e\u0063\u0068":if _ga .Launch {_f .Log .Debug ("\u004a\u0061\u0076\u0061\u0073\u0063\u0072\u0069\u0070\u0074\u0020a\u0063\u0074\u0069\u006f\u006e\u0020\u0073\u006b\u0069\u0070p\u0065\u0064\u002e");continue ;};case "\u0052e\u006e\u0064\u0069\u0074\u0069\u006fn":if _bc ,_ae :=_bg .GetStream (_cg .Get ("\u004a\u0053"));
18 | _ae {_ec :=[]byte {};_gb ,_ad :=_bg .MakeStream (_ec ,nil );if _ad ==nil {*_bc =*_gb ;};};};}else if _ca :=_cg .Get ("\u004a\u0061\u0076\u0061\u0053\u0063\u0072\u0069\u0070\u0074");_ca !=nil &&_ga .JavaScript {continue ;}else if _daf ,_ecg :=_bg .GetName (_cg .Get ("\u0054\u0079\u0070\u0065"));
19 | _ecg &&*_daf =="\u0041\u006e\u006eo\u0074"&&_ga .JavaScript {if _abc ,_dg :=_bg .GetIndirect (_cg .Get ("\u0050\u0061\u0072\u0065\u006e\u0074"));_dg {if _ffd ,_abcd :=_bg .GetDict (_abc .PdfObject );_abcd {if _cd ,_bbe :=_bg .GetDict (_ffd .Get ("\u0041\u0041"));
20 | _bbe {_gf ,_cb :=_bg .GetIndirect (_cd .Get ("\u004b"));if _cb {if _dgc ,_cge :=_bg .GetDict (_gf .PdfObject );_cge {if _gae ,_fg :=_bg .GetName (_dgc .Get ("\u0053"));_fg &&*_gae =="\u004a\u0061\u0076\u0061\u0053\u0063\u0072\u0069\u0070\u0074"{_dgc .Clear ();
21 | }else if _ag :=_cd .Get ("\u0046");_ag !=nil {if _bbec ,_ffb :=_bg .GetIndirect (_ag );_ffb {if _bf ,_cfa :=_bg .GetDict (_bbec .PdfObject );_cfa {if _feb ,_bd :=_bg .GetName (_bf .Get ("\u0053"));_bd &&*_feb =="\u004a\u0061\u0076\u0061\u0053\u0063\u0072\u0069\u0070\u0074"{_bf .Clear ();
22 | };};};};};};};};};};};case *_bg .PdfObjectStream :_f .Log .Debug ("\u0070d\u0066\u0020\u006f\u0062j\u0065\u0063\u0074\u0020\u0073t\u0072e\u0061m\u0020\u0074\u0079\u0070\u0065\u0020\u0025T",_e );case *_bg .PdfObjectStreams :_f .Log .Debug ("\u0070\u0064\u0066\u0020\u006f\u0062\u006a\u0065\u0063\u0074\u0020s\u0074\u0072\u0065\u0061\u006d\u0073\u0020\u0074\u0079\u0070e\u0020\u0025\u0054",_e );
23 | default:_f .Log .Debug ("u\u006e\u006b\u006e\u006fwn\u0020p\u0064\u0066\u0020\u006f\u0062j\u0065\u0063\u0074\u0020\u0025\u0054",_e );};_ba =append (_ba ,_baf );};_d .analyze (_ba );return _ba ,nil ;};func (_bcf *Sanitizer )analyze (_cce []_bg .PdfObject ){_cff :=map[string ]int {};
24 | for _ ,_bee :=range _cce {switch _bgb :=_bee .(type ){case *_bg .PdfIndirectObject :_fa ,_db :=_bg .GetDict (_bgb .PdfObject );if _db {if _gc ,_cba :=_bg .GetName (_fa .Get ("\u0054\u0079\u0070\u0065"));_cba &&*_gc =="\u0043a\u0074\u0061\u006c\u006f\u0067"{if _ ,_dba :=_bg .GetIndirect (_fa .Get ("\u004f\u0070\u0065\u006e\u0041\u0063\u0074\u0069\u006f\u006e"));
25 | _dba {_cff ["\u004f\u0070\u0065\u006e\u0041\u0063\u0074\u0069\u006f\u006e"]++;};}else if _cdd ,_adb :=_bg .GetName (_fa .Get ("\u0053"));_adb {_feg :=_cdd .String ();if _feg =="\u004a\u0061\u0076\u0061\u0053\u0063\u0072\u0069\u0070\u0074"||_feg =="\u0055\u0052\u0049"||_feg =="\u0047\u006f\u0054\u006f"||_feg =="\u0047\u006f\u0054o\u0052"||_feg =="\u004c\u0061\u0075\u006e\u0063\u0068"{_cff [_feg ]++;
26 | }else if _feg =="\u0052e\u006e\u0064\u0069\u0074\u0069\u006fn"{if _ ,_dbf :=_bg .GetStream (_fa .Get ("\u004a\u0053"));_dbf {_cff [_feg ]++;};};}else if _cbc :=_fa .Get ("\u004a\u0061\u0076\u0061\u0053\u0063\u0072\u0069\u0070\u0074");_cbc !=nil {_cff ["\u004a\u0061\u0076\u0061\u0053\u0063\u0072\u0069\u0070\u0074"]++;
27 | }else if _fab ,_bebc :=_bg .GetIndirect (_fa .Get ("\u0050\u0061\u0072\u0065\u006e\u0074"));_bebc {if _gg ,_af :=_bg .GetDict (_fab .PdfObject );_af {if _ee ,_abf :=_bg .GetDict (_gg .Get ("\u0041\u0041"));_abf {_adc :=_ee .Get ("\u004b");_bfb ,_afg :=_bg .GetIndirect (_adc );
28 | if _afg {if _daff ,_fcba :=_bg .GetDict (_bfb .PdfObject );_fcba {if _df ,_aef :=_bg .GetName (_daff .Get ("\u0053"));_aef &&*_df =="\u004a\u0061\u0076\u0061\u0053\u0063\u0072\u0069\u0070\u0074"{_cff ["\u004a\u0061\u0076\u0061\u0053\u0063\u0072\u0069\u0070\u0074"]++;
29 | }else if _ ,_dfg :=_bg .GetString (_daff .Get ("\u004a\u0053"));_dfg {_cff ["\u004a\u0061\u0076\u0061\u0053\u0063\u0072\u0069\u0070\u0074"]++;}else {_eb :=_ee .Get ("\u0046");if _eb !=nil {_gce ,_bac :=_bg .GetIndirect (_eb );if _bac {if _bea ,_gfb :=_bg .GetDict (_gce .PdfObject );
30 | _gfb {if _ef ,_aa :=_bg .GetName (_bea .Get ("\u0053"));_aa {_gge :=_ef .String ();_cff [_gge ]++;};};};};};};};};};};};};};_bcf ._g =_cff ;};
31 | 
32 | // SanitizationOpts specifies the objects to be removed during sanitization.
33 | type SanitizationOpts struct{
34 | 
35 | // JavaScript specifies wether JavaScript action should be removed. JavaScript Actions, section 12.6.4.16 of PDF32000_2008
36 | JavaScript bool ;
37 | 
38 | // URI specifies if URI actions should be removed. 12.6.4.7 URI Actions, PDF32000_2008.
39 | URI bool ;
40 | 
41 | // GoToR removes remote GoTo actions. 12.6.4.3 Remote Go-To Actions, PDF32000_2008.
42 | GoToR bool ;
43 | 
44 | // GoTo specifies wether GoTo actions should be removed. 12.6.4.2 Go-To Actions, PDF32000_2008.
45 | GoTo bool ;
46 | 
47 | // RenditionJS enables removing of `JS` entry from a Rendition Action.
48 | // The `JS` entry has a value of text string or stream containing a JavaScript script that shall be executed when the action is triggered.
49 | // 12.6.4.13 Rendition Actions Table 214, PDF32000_2008.
50 | RenditionJS bool ;
51 | 
52 | // OpenAction removes OpenAction entry from the document catalog.
53 | OpenAction bool ;
54 | 
55 | // Launch specifies wether Launch Action should be removed.
56 | // A launch action launches an application or opens or prints a document.
57 | // 12.6.4.5 Launch Actions, PDF32000_2008.
58 | Launch bool ;};
59 | 
60 | // Optimize optimizes `objects` and returns updated list of objects.
61 | func (_c *Sanitizer )Optimize (objects []_bg .PdfObject )([]_bg .PdfObject ,error ){return _c .processObjects (objects );};
62 | 
63 | // New returns a new sanitizer object.
64 | func New (opts SanitizationOpts )*Sanitizer {return &Sanitizer {_be :opts }};
65 | 
66 | // Sanitizer represents a sanitizer object.
67 | // It implements the Optimizer interface to access the objects field from the writer.
68 | type Sanitizer struct{_be SanitizationOpts ;_g map[string ]int ;};
69 | 
70 | // GetSuspiciousObjects returns a count of each detected suspicious object.
71 | func (_cbb *Sanitizer )GetSuspiciousObjects ()map[string ]int {return _cbb ._g };


--------------------------------------------------------------------------------
/textshaping/textshaping.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | package textshaping ;import (_e "github.com/unidoc/garabic";_de "golang.org/x/text/unicode/bidi";_d "strings";);
13 | 
14 | // ArabicShape returns shaped arabic glyphs string.
15 | func ArabicShape (text string )(string ,error ){_da :=_de .Paragraph {};_da .SetString (text );_b ,_fc :=_da .Order ();if _fc !=nil {return "",_fc ;};for _ea :=0;_ea < _b .NumRuns ();_ea ++{_a :=_b .Run (_ea );_af :=_a .String ();if _a .Direction ()==_de .RightToLeft {var (_ad =_e .Shape (_af );
16 | _eg =[]rune (_ad );_ec =make ([]rune ,len (_eg )););_fd :=0;for _ba :=len (_eg )-1;_ba >=0;_ba --{_ec [_fd ]=_eg [_ba ];_fd ++;};_af =string (_ec );text =_d .Replace (text ,_d .TrimSpace (_a .String ()),_af ,1);};};return text ,nil ;};


--------------------------------------------------------------------------------
/unipdf.go:
--------------------------------------------------------------------------------
 1 | //
 2 | // Copyright 2020 FoxyUtils ehf. All rights reserved.
 3 | //
 4 | // This is a commercial product and requires a license to operate.
 5 | // A trial license can be obtained at https://unidoc.io
 6 | //
 7 | // DO NOT EDIT: generated by unitwist Go source code obfuscator.
 8 | //
 9 | // Use of this source code is governed by the UniDoc End User License Agreement
10 | // terms that can be accessed at https://unidoc.io/eula/
11 | 
12 | // Package unipdf is a comprehensive PDF library for Go (golang). The library has advanced capabilities for generating,
13 | // processing and modifying PDFs. UniPDF is written and supported by the owners of the
14 | // FoxyUtils.com website, where the library is used to power many of the PDF services offered.
15 | //
16 | // # Getting More Information
17 | //
18 | // Check out the Getting Started and Example sections, which showcase how to install unipdf and provide numerous
19 | // examples of using unipdf to generate, process or modify PDF files.
20 | // https://unidoc.io/examples/getting_started/
21 | //
22 | // The GoDoc for unipdf provides a detailed breakdown of the API and documentation for packages, types and methods.
23 | // https://godoc.org/github.com/unidoc/unipdf
24 | //
25 | // # Overview of Major Packages
26 | //
27 | // The API is composed of a few major packages:
28 | //
29 | //   - common: Provides common shared types such as Logger and utilities to check
30 | //     license validity.
31 | //
32 | //   - core: The core package defines the primitive PDF object types and handles
33 | //     the file reading I/O and parsing the primitive objects.
34 | //
35 | //   - model: The model package builds on the core package, to represent the PDF as
36 | //     a structured model of the PDF primitive types. It has a reader and a writer to
37 | //     read and process a PDF file based on the structured model. This serves as a basis
38 | //     to perform a number of numerous tasks and can be used to work with a PDF in a
39 | //     medium to high level interface, although it does require an understanding of the
40 | //     PDF format and structure.
41 | //
42 | //   - creator: The PDF creator makes it easy to create new PDFs or modify existing
43 | //     PDFs. It can also enable loading a template PDF, adding text/images and
44 | //     generating an output PDF. It can be used to add text, images, and generate text
45 | //     and graphical reports. It is designed with simplicity in mind, with the goal of
46 | //     making it easy to create reports without needing any knowledge about the PDF
47 | //     format or specifications.
48 | //
49 | //   - extractor: Package extractor is used for quickly extracting PDF content
50 | //     through a simple interface. Currently offers functionality for extracting textual
51 | //     content.
52 | package unipdf ;


--------------------------------------------------------------------------------