@@ -57,7 +57,8 @@ This file is part of the iText (R) project.
5757import com .itextpdf .layout .font .FontProvider ;
5858import com .itextpdf .layout .properties .TextAlignment ;
5959import com .itextpdf .pdfa .PdfADocument ;
60- import com .itextpdf .pdfocr .exceptions .OcrException ;
60+ import com .itextpdf .pdfocr .exceptions .PdfOcrException ;
61+ import com .itextpdf .pdfocr .exceptions .PdfOcrExceptionMessageConstant ;
6162import com .itextpdf .pdfocr .logs .PdfOcrLogMessageConstant ;
6263import com .itextpdf .pdfocr .statistics .PdfOcrOutputType ;
6364import com .itextpdf .pdfocr .statistics .PdfOcrOutputTypeStatisticsEvent ;
@@ -165,14 +166,14 @@ public final void setOcrPdfCreatorProperties(
165166 * @return result PDF/A-3u {@link com.itextpdf.kernel.pdf.PdfDocument}
166167 * object
167168 *
168- * @throws OcrException if it was not possible to read provided or
169+ * @throws PdfOcrException if it was not possible to read provided or
169170 * default font
170171 */
171172 public final PdfDocument createPdfA (final List <File > inputImages ,
172173 final PdfWriter pdfWriter ,
173174 final DocumentProperties documentProperties ,
174175 final PdfOutputIntent pdfOutputIntent )
175- throws OcrException {
176+ throws PdfOcrException {
176177 LOGGER .info (MessageFormatUtil .format (
177178 PdfOcrLogMessageConstant .START_OCR_FOR_IMAGES ,
178179 inputImages .size ()));
@@ -220,13 +221,13 @@ public final PdfDocument createPdfA(final List<File> inputImages,
220221 * @return result PDF/A-3u {@link com.itextpdf.kernel.pdf.PdfDocument}
221222 * object
222223 *
223- * @throws OcrException if it was not possible to read provided or
224+ * @throws PdfOcrException if it was not possible to read provided or
224225 * default font
225226 */
226227 public final PdfDocument createPdfA (final List <File > inputImages ,
227228 final PdfWriter pdfWriter ,
228229 final PdfOutputIntent pdfOutputIntent )
229- throws OcrException {
230+ throws PdfOcrException {
230231 return createPdfA (inputImages , pdfWriter , new DocumentProperties (), pdfOutputIntent );
231232 }
232233
@@ -247,12 +248,12 @@ public final PdfDocument createPdfA(final List<File> inputImages,
247248 *
248249 * @return result {@link com.itextpdf.kernel.pdf.PdfDocument} object
249250 *
250- * @throws OcrException if provided font is incorrect
251+ * @throws PdfOcrException if provided font is incorrect
251252 */
252253 public final PdfDocument createPdf (final List <File > inputImages ,
253254 final PdfWriter pdfWriter ,
254255 final DocumentProperties documentProperties )
255- throws OcrException {
256+ throws PdfOcrException {
256257 return createPdfA (inputImages , pdfWriter , documentProperties , null );
257258 }
258259
@@ -272,11 +273,11 @@ public final PdfDocument createPdf(final List<File> inputImages,
272273 *
273274 * @return result {@link com.itextpdf.kernel.pdf.PdfDocument} object
274275 *
275- * @throws OcrException if provided font is incorrect
276+ * @throws PdfOcrException if provided font is incorrect
276277 */
277278 public final PdfDocument createPdf (final List <File > inputImages ,
278279 final PdfWriter pdfWriter )
279- throws OcrException {
280+ throws PdfOcrException {
280281 return createPdfA (inputImages , pdfWriter , new DocumentProperties (), null );
281282 }
282283
@@ -288,12 +289,12 @@ public final PdfDocument createPdf(final List<File> inputImages,
288289 * @param outPdfFile the {@link java.io.File} object to write final PDF document to
289290 *
290291 * @throws IOException signals that an I/O exception of some sort has occurred.
291- * @throws OcrException if it was not possible to read provided or
292+ * @throws PdfOcrException if it was not possible to read provided or
292293 * default font
293294 */
294295 public void createPdfFile (final List <File > inputImages ,
295296 final File outPdfFile )
296- throws OcrException , IOException {
297+ throws PdfOcrException , IOException {
297298 createPdfAFile (inputImages , outPdfFile , null );
298299 }
299300
@@ -308,13 +309,13 @@ public void createPdfFile(final List<File> inputImages,
308309 * for PDF/A-3u document
309310 *
310311 * @throws IOException signals that an I/O exception of some sort has occurred
311- * @throws OcrException if it was not possible to read provided or
312+ * @throws PdfOcrException if it was not possible to read provided or
312313 * default font
313314 */
314315 public void createPdfAFile (final List <File > inputImages ,
315316 final File outPdfFile ,
316317 final PdfOutputIntent pdfOutputIntent )
317- throws OcrException , IOException {
318+ throws PdfOcrException , IOException {
318319 DocumentProperties documentProperties = new DocumentProperties ();
319320 if (ocrPdfCreatorProperties .getMetaInfo () != null ) {
320321 documentProperties .setEventCountingMetaInfo (ocrPdfCreatorProperties .getMetaInfo ());
@@ -356,13 +357,13 @@ public final void setOcrEngine(final IOcrEngine reader) {
356357 * @param imageData input image if it is a single page or its one page if
357358 * this is a multi-page image
358359 * @param createPdfA3u true if PDF/A3u document is being created
359- * @throws OcrException if PDF/A3u document is being created and provided
360+ * @throws PdfOcrException if PDF/A3u document is being created and provided
360361 * font contains notdef glyphs
361362 */
362363 private void addToCanvas (final PdfDocument pdfDocument ,
363364 final Rectangle imageSize ,
364365 final List <TextInfo > pageText , final ImageData imageData ,
365- final boolean createPdfA3u ) throws OcrException {
366+ final boolean createPdfA3u ) throws PdfOcrException {
366367 final Rectangle rectangleSize =
367368 ocrPdfCreatorProperties .getPageSize () == null
368369 ? imageSize : ocrPdfCreatorProperties .getPageSize ();
@@ -393,11 +394,11 @@ private void addToCanvas(final PdfDocument pdfDocument,
393394 try {
394395 addTextToCanvas (imageSize , pageText , canvas , multiplier ,
395396 pdfPage .getMediaBox ());
396- } catch (OcrException e ) {
397+ } catch (PdfOcrException e ) {
397398 LOGGER .error (MessageFormatUtil .format (
398- OcrException .CANNOT_CREATE_PDF_DOCUMENT ,
399+ PdfOcrExceptionMessageConstant .CANNOT_CREATE_PDF_DOCUMENT ,
399400 e .getMessage ()));
400- throw new OcrException ( OcrException .CANNOT_CREATE_PDF_DOCUMENT )
401+ throw new PdfOcrException ( PdfOcrExceptionMessageConstant .CANNOT_CREATE_PDF_DOCUMENT )
401402 .setMessageParams (e .getMessage ());
402403 }
403404 if (layers [1 ] != null ) {
@@ -427,9 +428,9 @@ private PdfDocument createPdfDocument(final PdfWriter pdfWriter,
427428 && !ocrPdfCreatorProperties .getPdfLang ().equals ("" );
428429 if (createPdfA3u && !hasPdfLangProperty ) {
429430 LOGGER .error (MessageFormatUtil .format (
430- OcrException .CANNOT_CREATE_PDF_DOCUMENT ,
431+ PdfOcrExceptionMessageConstant .CANNOT_CREATE_PDF_DOCUMENT ,
431432 PdfOcrLogMessageConstant .PDF_LANGUAGE_PROPERTY_IS_NOT_SET ));
432- throw new OcrException ( OcrException .CANNOT_CREATE_PDF_DOCUMENT )
433+ throw new PdfOcrException ( PdfOcrExceptionMessageConstant .CANNOT_CREATE_PDF_DOCUMENT )
433434 .setMessageParams (PdfOcrLogMessageConstant .PDF_LANGUAGE_PROPERTY_IS_NOT_SET );
434435 }
435436
@@ -472,13 +473,13 @@ private PdfDocument createPdfDocument(final PdfWriter pdfWriter,
472473 * map pageNumber -> text for the page
473474 * @param pdfDocument result {@link com.itextpdf.kernel.pdf.PdfDocument}
474475 * @param createPdfA3u true if PDF/A3u document is being created
475- * @throws OcrException if input image cannot be read or provided font
476+ * @throws PdfOcrException if input image cannot be read or provided font
476477 * contains NOTDEF glyphs
477478 */
478479 private void addDataToPdfDocument (
479480 final Map <File , Map <Integer , List <TextInfo >>> imagesTextData ,
480481 final PdfDocument pdfDocument ,
481- final boolean createPdfA3u ) throws OcrException {
482+ final boolean createPdfA3u ) throws PdfOcrException {
482483 for (Map .Entry <File , Map <Integer , List <TextInfo >>> entry
483484 : imagesTextData .entrySet ()) {
484485 File inputImage = entry .getKey ();
@@ -545,7 +546,7 @@ private void addImageToCanvas(final ImageData imageData,
545546 * @param pdfCanvas canvas to place the text
546547 * @param multiplier coefficient to adjust text placing on canvas
547548 * @param pageMediaBox page parameters
548- * @throws OcrException if PDF/A3u document is being created and provided
549+ * @throws PdfOcrException if PDF/A3u document is being created and provided
549550 * font contains notdef glyphs
550551 */
551552 private void addTextToCanvas (
@@ -554,7 +555,7 @@ private void addTextToCanvas(
554555 final PdfCanvas pdfCanvas ,
555556 final float multiplier ,
556557 final Rectangle pageMediaBox )
557- throws OcrException {
558+ throws PdfOcrException {
558559 if (pageText != null && pageText .size () > 0 ) {
559560 final Point imageCoordinates =
560561 PdfCreatorUtil .calculateImageCoordinates (
@@ -750,7 +751,7 @@ public PdfCanvas showText(GlyphLine text) {
750751 if (this .createPdfA3u ) {
751752 // exception is thrown only if PDF/A document is
752753 // being created
753- throw new OcrException (message );
754+ throw new PdfOcrException (message );
754755 }
755756 // setting actual text to NotDef glyph
756757 glyphLine .setActualTextToGlyph (i ,
0 commit comments