Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Creation of a PDF/A1-b document from an image scan
  FAQ FAQ  Forum Search   Register Register  Login Login

Creation of a PDF/A1-b document from an image scan

 Post Reply Post Reply
Author
Message
dsch View Drop Down
Beginner
Beginner


Joined: 09 Aug 13
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote dsch Quote  Post ReplyReply Direct Link To This Post Topic: Creation of a PDF/A1-b document from an image scan
    Posted: 09 Aug 13 at 10:55AM
Hi there,

I have to create a PDF/A1-b doc from a tif file, which comes from a scanner. I've read in the developers guide how to create such a doc from the scratch using SetPDFAMode(2) and DrawText, but I cannot find a description of how to involve the image file.

Of cause, I did an OCR on the image and so I know the characters and words of the scan and also their positions. But what now?

Thanks for help!

Dirk

Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 09 Aug 13 at 11:05AM
Hi Dirk!
 
You should read here:
AddImageFromFile:
http://www.debenu.com/docs/pdf_library_reference/AddImageFromFile.php
With this function you can write all tif-pages into a pdf using a loop.
 
Cheers and welcome here,
Ingo
Back to Top
dsch View Drop Down
Beginner
Beginner


Joined: 09 Aug 13
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote dsch Quote  Post ReplyReply Direct Link To This Post Posted: 09 Aug 13 at 12:28PM
Hi Ingo,

thanks for the warm welcome! I already read about that, but still I'm not sure about the way how to do. Am I right with the following? And is that the best practice?

1. Create a pdf document
2. Calling SetPDFAMode(2)
3. Add scan page with "AddImageFromFile"
4. Add all words (or all characters? What's best?) to the page using "DrawText"
5. continue with 3. until there is no page left

Thank you,

Dirk
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 09 Aug 13 at 12:40PM
Hi Dirk!
 
Don't use visible DrawText 'cause one of the a1-b-specs
tells me not to change the original layout and it
will be very difficult to create absolutely identical
pages.
So you should use your points 1-3 to create similar
visible pages.
But the a1-b-specs wants the searchable textcontent, too.
So "i" would use the DrawText with the same colour as
the background colour on a separate layer/content group.
Another idea: Use the DrawText with 100% transparency.
I don't know if this would be absolute a1-b-specs-like ;-)
 
Perhaps there are experts dealing with PDF/A here to
post a more professional help ;-)
 
Cheers, Ingo
 
Back to Top
dsch View Drop Down
Beginner
Beginner


Joined: 09 Aug 13
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote dsch Quote  Post ReplyReply Direct Link To This Post Posted: 09 Aug 13 at 2:50PM
Hi Ingo,

it seems to me that "SetTextMode(3)" will do the job for invisible text. But I still don't know, if the result will be (really) pdf/a1-b compliant. One Question i.e. is, whether I need a special layer (contentstream/-group) for the text data or not?

It would be nice to have a short (pseudo-) code snippet for the creation of such a type of document. Strange, that no one from quickpdf deals with this subject...

Thank you,

Dirk
Back to Top
dsch View Drop Down
Beginner
Beginner


Joined: 09 Aug 13
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote dsch Quote  Post ReplyReply Direct Link To This Post Posted: 09 Aug 13 at 3:16PM
I just tried some code that seems to be correct (in my opinion). It will result in a searchable pdf but all the online validators don't like the output file and they agree in the fact, that it is NOT a pdf/a1-b file. Any idea what's wrong?

    PDFLib.SetPDFAMode(2);

    iImgID := PDFLib.AddImageFromFile(ImageFileName, 1);
    PDFLib.SelectImage(iImgID);

    iWidth := PDFLib.ImageWidth;
    iHeight := PDFLib.ImageHeight;

    PDFLib.SetPageDimensions(iWidth, iHeight);
    PDFLib.SetOrigin(1);
    PDFLib.DrawImage(0, 0, iWidth, iHeight);

    PDFLib.SetTextMode(3);
    PDFLib.SetTextSize(20);
    PDFLib.DrawText(100, 200, 'Hallo');

    PDFLib.SaveToFile('xxx.pdf');
Back to Top
dsch View Drop Down
Beginner
Beginner


Joined: 09 Aug 13
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote dsch Quote  Post ReplyReply Direct Link To This Post Posted: 09 Aug 13 at 4:02PM
One more interresting thing: the sample code for pdf/a1-b creation, provided by the QuickPDF developers guide, also produces a file, that is NOT pdf/a1-b compliant (as said by various online-validator-tools):

/* Create a new PDF/A document */
// Call SetPDFAMode to tell Quick PDF Library that you want to
// create a PDF/A document. Specify which version of PDF/A it
// should use.
QP.SetPDFAMode(2);
// Add some simple text
QP.DrawText(100, 600, “This document is PDF/A-1b compliant.”);
// Save the PDF/A compliant doc to disk
QP.SaveToFile(“my_pdf-a_doc.pdf”);

Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 10 Aug 13 at 9:35PM
Seems there's no other way than read the specs regarding attached files ;-)

Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 12 Aug 13 at 5:12AM
Dirk,

The 14 base fonts are not allowed to be used in a PDF/A1b file.  All fonts need to be embedded in the PDF/A1b file so the following code change should improve things.

    PDFLib.SetPDFAMode(2);

    iImgID := PDFLib.AddImageFromFile(ImageFileName, 1);
    PDFLib.SelectImage(iImgID);

    iWidth := PDFLib.ImageWidth;
    iHeight := PDFLib.ImageHeight;

    PDFLib.SetPageDimensions(iWidth, iHeight);
    PDFLib.SetOrigin(1);
    PDFLib.DrawImage(0, 0, iWidth, iHeight);

    PDFLib.SetTextMode(3);                          // Invisible text mode

    PDFLib.AddTrueTypeFont("Arial", 1);       // ADDED : Embed the Arial font.

    PDFLib.SetTextSize(20);
    PDFLib.DrawText(100, 200, 'Hallo');

    PDFLib.SaveToFile('xxx.pdf');


Andrew.

Back to Top
dsch View Drop Down
Beginner
Beginner


Joined: 09 Aug 13
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote dsch Quote  Post ReplyReply Direct Link To This Post Posted: 12 Aug 13 at 5:51PM
Thank you Andrew and Ingo. It seems that the version 8.15 was unable to produce correct pdf/a-1b files. It's ok with 9.15

Regards,

Dirk
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store