ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 CreatePDFFile Not Opening Document
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PaulF

United Kingdom
9 Posts

Posted - Sep 05 2024 :  05:51:43  Show Profile  Reply
Hi,
I'm having a bit of trouble creating a blank PDF document and adding pages using PDF Viewer. I get an exception document is not open. See source code below. Am I not using it correctly? Is there is a work around that would be great.
thanks very much.
regards
Paul


    { Load source image into IEView. }
    IEViewSrc := TImageEnView.Create( PnlLft );
    IEViewSrc.Parent := PnlLft;
    IEViewSrc.Align := TAlign.alClient;
    IEViewSrc.IO.LoadFromFile( FileOpenDlg.FileName );

    { Create doc generator IEView, create the PDF doc and add the loaded image as a page. }
    IEViewDocGen := TImageEnView.Create( PnlRht );
    IEViewDocGen.Parent := PnlRht;
    IEViewDocGen.Align := TAlign.alClient;
    IEViewDocGen.PdfViewer.Enabled := True;
    IEViewDocGen.IO.CreatePDFFile( 'D:\Projects\FOCUS\Media\Test\GenTestDoc.PDF' );
    IEViewDocGen.PdfViewer.AddPage( IEViewSrc.IEBitMap, TIOPDFPaperSize.iepA4, TIEPageLayout.ielPortrait, -1, 0, True, True );
    IEViewDocGen.IO.SaveToPDF;



aleatprog

132 Posts

Posted - Sep 05 2024 :  12:14:28  Show Profile  Reply
Hi Paul,

did you valuated using TIEPDFBuilder to create PDF documents from scratch?

https://www.imageen.com/help/TIEPDFBuilder.html

Ale
Go to Top of Page

xequte

38530 Posts

Posted - Sep 05 2024 :  16:20:18  Show Profile  Reply
Hi

Unfortunately you are using two different methods here:
- PDFViewer (built on PDFium)
- IO.SaveToPDF (TIEPDFBuilder: native PDF saving).

They should not be used together.

Is your intention to create a multi-page PDF built on images only?

If so, try the TIEPDFBuilder demos:

PDF\PDFBuilder\PDFBuilder.dpr
PDF\PDFBuilder2\PDFBuilder2.dpr


If you want some level of interactive editing, then a solution built on PDFViewer might be better.

Sorry, that is confusing. See the notes regarding PDF at:

https://www.imageen.com/help/File_Formats.html#PDF


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

PaulF

United Kingdom
9 Posts

Posted - Sep 06 2024 :  02:16:50  Show Profile  Reply
Thanks for your replies. Thought that might be the case.
As a workaround I've used PDFBuilder to create a single page blank document, then after loading into PDFViewer, I've used PdfViewer.ImportPages to import pages from another PDF doc and also PdfViewer.AddPage to add screenshot images. Finally I've deleted the blank page. So all good.

That said I did have an issue with PdfViewer.AddPage trying to add a TIEPageLayout.ielLandscape TIOPDFPaperSize.iepA4 page kept coming out as portrait. Need to do a bit more testing.

kind regards
Paul

Go to Top of Page

xequte

38530 Posts

Posted - Sep 07 2024 :  00:39:58  Show Profile  Reply
Hi Paul

You can create a new document within PdfViewer using:

ImageEnView1.PdfViewer.Document.NewDocument();

And new pages using:

http://www.imageen.com/help/TIEPdfViewer.AddPage.html


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

PaulF

United Kingdom
9 Posts

Posted - Sep 09 2024 :  04:53:29  Show Profile  Reply
Thanks Nigel - Just the job.
Paul
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: