We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Add text with dynamic length to a PdfLoadedDocument

Thread ID:

Created:

Updated:

Platform:

Replies:

118554 Mar 18,2015 09:38 AM Mar 24,2015 10:06 AM ASP.NET Web Forms (Classic) 3
loading
Tags: PDF
glenn paulsen
Asked On March 18, 2015 09:38 AM

We have a program that reads an existing PDF from disc. That PDF tempalte contains text and form elements and converts it to a PDF/A document. We draw some text to the position where the form elements are positioned and then we delete the form elements. Then we do a PdfDocument.Merge(destPdfADoc, sourcePdfLoadedDoc) to merge the the PDF template with a PDF/A document. And that works great! The problem occurs when the text has dynamic length and it won’t fit into the available area.

  1. Is it possible to detect when the content does not fit the available area?
  2. Is there a nice solution to extend the number of pages (or similar) to fit the content?


Karthik Krishnaraj [Syncfusion]
Replied On March 19, 2015 11:04 AM

Hi Glenn,

Thank you for using syncfusion products,

It is possible to “Extend the number of pages to fit the content”, for this you need to set PdfLayout type as Paginate, this will extend the pages until your content is fit. I have attached a simple sample regarding this in the below link, please check it.

Sample link:

http://www.syncfusion.com/downloads/support/forum/118554/WebApplication131145370741.zip

For your another query about “Need to detect when the content doesn’t fit available area”, I have attached a simple sample, here we can get the bounds of the text after drawn in the page by using PdfTextElement class. By comparing the bounds of the text with page bounds we can able to detect whether the content will be fit into it. Can you please check with this and let me know if these helps.

Sample Link:

http://www.syncfusion.com/downloads/support/forum/118554/WebApplication141213754924.zip

Thanks,

Karthik.


glenn paulsen
Replied On March 23, 2015 11:05 AM

Thank you for your response.
I manage to fit the content now, but I get an InvalidCastException ("Unable to cast the object of type 'Syncfusion.Pdf.PdfPage' to type 'Syncfusion.Pdf.PdfLoadedPage’.") when trying to do a PdfDocument.Merge(destLoadedDocument, sourceLoadedDocument). The newly added page to the sourceLoadedDocument gets the type PdfPage while the other pages has the type PdfLoadedPage.

Is there a way to merge/append/insert pages from the sourceLoadedDocument to the destLoadedDocument when one of the pages is of type PdfPage while the rest of the pages is of type PdfLoadedDocument?

Karthik Krishnaraj [Syncfusion]
Replied On March 24, 2015 10:06 AM

Hi Glenn,

Thank you for your patience,

Yes, It is possible to Merge “sourceLoadedDocument to the destLoadedDocument”, I have attached a simple sample regarding this, can you please check with this and let us know if these helps.

And for your query regarding “Exception occurs while trying to Merge Loaded documents”, can you please provide us the code snippet which causes the exception, this will help us to provide better solution.

Sample Link:

http://www.syncfusion.com/downloads/support/directtrac/132886/MergingLoadedDocument-1818664082.zip

Thanks,

Karthik.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;